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

axios-cache-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-cache-interceptor - npm Package Compare versions

Comparing version 0.8.10 to 0.9.0

2

cjs/dev.js

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

(()=>{"use strict";var e={d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Header:()=>r,buildKeyGenerator:()=>S,buildMemoryStorage:()=>w,buildStorage:()=>m,buildWebStorage:()=>x,createCacheResponse:()=>c,createValidateStatus:()=>o,defaultHeaderInterpreter:()=>s,defaultKeyGenerator:()=>I,defaultRequestInterceptor:()=>u,defaultResponseInterceptor:()=>f,isMethodIn:()=>n,isStorage:()=>p,setupCache:()=>C,testCachePredicate:()=>g,updateCache:()=>h,updateStaleRequest:()=>d});const a=require("cache-parser"),r=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),s=e=>{if(!e)return"not enough headers";const t=e[r.CacheControl];if(t){const{noCache:s,noStore:i,mustRevalidate:o,maxAge:n,immutable:d}=(0,a.parse)(String(t));if(s||i)return"dont cache";if(d)return 31536e6;if(o)return 0;if(n){const t=e[r.Age];return t?1e3*(n-Number(t)):1e3*n}}const s=e[r.Expires];if(s){const e=Date.parse(String(s))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"},i=require("fast-defer");function o(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function n(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function d(e,t){t.headers||(t.headers={});const{etag:a,modifiedSince:s}=t.cache;if(a){const s=!0===a?e.data?.headers[r.ETag]:a;s&&(t.headers[r.IfNoneMatch]=s)}s&&(t.headers[r.IfModifiedSince]=!0===s?e.data.headers[r.LastModified]||new Date(e.createdAt).toUTCString():s.toUTCString())}function c(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers={...t.headers,...e.headers},t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function u(e){const t=async t=>{if(!1===t.cache)return e.debug?.({msg:"Ignoring cache because config.cache is false",data:t}),t;if(t.cache={...e.defaults.cache,...t.cache},!n(t.method,t.cache.methods))return e.debug?.({msg:`Ignored because method (${t.method}) is not in cache.methods (${t.cache.methods})`}),t;const a=t.id=e.generateKey(t);let r,s=await e.storage.get(a);e:if("empty"===s.state||"stale"===s.state){if(e.waiting[a]){s=await e.storage.get(a),e.debug?.({id:a,msg:"Waiting list had an deferred for this key, waiting for it to finish"});break e}return e.waiting[a]=(0,i.deferred)(),e.waiting[a]?.catch((()=>{})),await e.storage.set(a,{state:"loading",previous:s.state,data:s.data,createdAt:s.createdAt}),"stale"===s.state&&(d(s,t),e.debug?.({id:a,msg:"Updated stale request"})),t.validateStatus=o(t.validateStatus),e.debug?.({id:a,msg:"Sending request, waiting for response"}),t}if("loading"===s.state){const s=e.waiting[a];if(!s)return await e.storage.remove(a),t;e.debug?.({id:a,msg:"Detected concurrent request, waiting for it to finish"});try{r=await s}catch(r){return e.debug?.({id:a,msg:"Deferred rejected, requesting again",data:r}),t}}else r=s.data;return t.adapter=()=>Promise.resolve({config:t,data:r.data,headers:r.headers,status:r.status,statusText:r.statusText,cached:!0,id:a}),e.debug?.({id:a,msg:"Returning cached response"}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function g(e,t){if("function"==typeof t)return t(e);const{statusCheck:a,responseMatch:r,containsHeaders:s}=t;if(a&&!await a(e.status)||r&&!await r(e))return!1;if(s)for(const t in s){const a=s[t];if(a&&!await a(e.headers[t.toLowerCase()]??e.headers[t]))return!1}return!0}async function h(e,t,a){for(const r in a){const s=a[r];if("delete"===s){await e.remove(r);continue}const i=await e.get(r);if("loading"===i.state)continue;const o=await s(i,t);"delete"!==o?"ignore"!==o&&await e.set(r,o):await e.remove(r)}}function f(e){const t=async t=>{await e.storage.remove(t),e.waiting[t]?.reject(null),delete e.waiting[t]},a=async a=>{var s;if(a.id=(s=a.config).id??(s.id=e.generateKey(a.config)),a.cached??(a.cached=!1),a.cached)return e.debug?.({id:a.id,msg:"Returned cached response"}),a;if(!a.config.cache)return e.debug?.({id:a.id,msg:"Response with config.cache === false",data:a}),{...a,cached:!1};const i=a.config.cache,o=await e.storage.get(a.id);if("stale"===o.state||"empty"===o.state||"cached"===o.state)return e.debug?.({id:a.id,msg:"Response not cached but storage is not loading",data:{cache:o,response:a}}),a;if(!o.data&&!await g(a,i.cachePredicate))return await t(a.id),e.debug?.({id:a.id,msg:"Cache predicate rejected this response"}),a;for(const e in r)e.startsWith("XAxiosCache")&&delete a.headers[e];i.etag&&!0!==i.etag&&(a.headers[r.XAxiosCacheEtag]=i.etag),i.modifiedSince&&(a.headers[r.XAxiosCacheLastModified]=!0===i.modifiedSince?"use-cache-timestamp":i.modifiedSince.toUTCString());let n=i.ttl||-1;if(i?.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),e.debug?.({id:a.id,msg:"Cache header interpreted as 'dont cache'",data:{cache:o,response:a,expirationTime:r}}),a;n="not enough headers"===r?n:r}const d=c(a,o.data);"function"==typeof n&&(n=await n(a)),i.staleIfError&&(a.headers[r.XAxiosCacheStaleIfError]=String(n)),e.debug?.({id:a.id,msg:"Useful response configuration found",data:{cacheConfig:i,ttl:n,cacheResponse:d}}),i?.update&&await h(e.storage,a,i.update);const u={state:"cached",ttl:n,createdAt:Date.now(),data:d},f=e.waiting[a.id];return f&&(f.resolve(u.data),delete e.waiting[a.id],e.debug?.({id:a.id,msg:"Found waiting deferred(s) and resolved them"})),await e.storage.set(a.id,u),e.debug?.({id:a.id,msg:"Response cached",data:{cache:u,response:a}}),a},s=async a=>{const r=a.config;if(!r||!1===r.cache||!r.id)throw e.debug?.({msg:"Web request returned an error but cache handling is not enabled",data:{error:a,config:r}}),a;const s=await e.storage.get(r.id),i=r.cache;if("loading"!==s.state||"stale"!==s.previous)throw await t(r.id),e.debug?.({msg:"Caught an error in the request interceptor",data:{error:a,config:r}}),a;if(i?.staleIfError){const t="function"==typeof i.staleIfError?await i.staleIfError(a.response,s,a):i.staleIfError;if(e.debug?.({msg:"Found cache if stale config for rejected response",data:{error:a,config:r,staleIfError:t}}),!0===t||"number"==typeof t&&s.createdAt+t>Date.now())return e.waiting[r.id]?.resolve(s.data),delete e.waiting[r.id],await e.storage.set(r.id,{state:"stale",createdAt:Date.now(),data:s.data}),e.debug?.({msg:"staleIfError resolved this response with cached data",data:{error:a,config:r,cache:s}}),{cached:!0,config:r,id:r.id,data:s.data.data,headers:s.data.headers,status:s.data.status,statusText:s.data.statusText}}throw e.debug?.({msg:"Received an unknown error that could not be handled",data:{error:a,config:r}}),a};return{onFulfilled:a,onRejected:s,apply:()=>e.interceptors.response.use(a,s)}}const l=Symbol(),p=e=>!!e&&!!e[l];function m({set:e,find:t,remove:a}){return{[l]:1,set:e,remove:a,get:async s=>{const i=await t(s);if(!i)return{state:"empty"};if("cached"!==i.state||i.createdAt+i.ttl>Date.now())return i;if(i.data.headers&&(r.ETag in i.data.headers||r.LastModified in i.data.headers||r.XAxiosCacheEtag in i.data.headers||r.XAxiosCacheStaleIfError in i.data.headers||r.XAxiosCacheLastModified in i.data.headers)){const t={state:"stale",createdAt:i.createdAt,data:i.data};return await e(s,t),t}return await a(s),{state:"empty"}}}}function w(){const e=m({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}const b=require("object-code"),y=/^\/|\/$/g;function S(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(y,"")),a.url&&(a.url=a.url.replace(y,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,b.code)(r).toString():r}}const I=S(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:s})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:s})));function C(e,t={}){const a=e;if(a.storage=t.storage||w(),!p(a.storage))throw new Error("Use buildStorage() function");return a.generateKey=t.generateKey||I,a.waiting=t.waiting||{},a.headerInterpreter=t.headerInterpreter||s,a.requestInterceptor=t.requestInterceptor||u(a),a.responseInterceptor=t.responseInterceptor||f(a),a.debug=t.debug,a.defaults.cache={ttl:t.ttl??3e5,interpretHeader:t.interpretHeader??!1,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:t.etag??!1,modifiedSince:t.modifiedSince??!1,staleIfError:t.staleIfError??!1,update:t.update||{}},a.requestInterceptor.apply(),a.responseInterceptor.apply(),a}function x(e,t=""){return m({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},set:(a,r)=>{e.setItem(t+a,JSON.stringify(r))},remove:a=>{e.removeItem(t+a)}})}console.error("You are using a development build. Make sure to use the correct build in production"),console.error("https://axios-cache-interceptor.js.org/#/pages/installing"),module.exports=t})();
(()=>{"use strict";var e={d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Header:()=>r,buildKeyGenerator:()=>C,buildMemoryStorage:()=>y,buildStorage:()=>b,buildWebStorage:()=>A,canStale:()=>m,createCacheResponse:()=>c,createValidateStatus:()=>o,defaultHeaderInterpreter:()=>s,defaultKeyGenerator:()=>x,defaultRequestInterceptor:()=>u,defaultResponseInterceptor:()=>h,isExpired:()=>w,isMethodIn:()=>n,isStorage:()=>p,setupCache:()=>v,testCachePredicate:()=>g,updateCache:()=>f,updateStaleRequest:()=>d});const a=require("cache-parser"),r=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),s=e=>{if(!e)return"not enough headers";const t=e[r.CacheControl];if(t){const{noCache:s,noStore:i,mustRevalidate:o,maxAge:n,immutable:d}=(0,a.parse)(String(t));if(s||i)return"dont cache";if(d)return 31536e6;if(o)return 0;if(n){const t=e[r.Age];return t?1e3*(n-Number(t)):1e3*n}}const s=e[r.Expires];if(s){const e=Date.parse(String(s))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"},i=require("fast-defer");function o(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function n(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function d(e,t){t.headers||(t.headers={});const{etag:a,modifiedSince:s}=t.cache;if(a){const s=!0===a?e.data?.headers[r.ETag]:a;s&&(t.headers[r.IfNoneMatch]=s)}s&&(t.headers[r.IfModifiedSince]=!0===s?e.data.headers[r.LastModified]||new Date(e.createdAt).toUTCString():s.toUTCString())}function c(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers={...t.headers,...e.headers},t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function u(e){const t=async t=>{if(!1===t.cache)return e.debug?.({msg:"Ignoring cache because config.cache is false",data:t}),t;if(t.cache={...e.defaults.cache,...t.cache},!n(t.method,t.cache.methods))return e.debug?.({msg:`Ignored because method (${t.method}) is not in cache.methods (${t.cache.methods})`}),t;const a=t.id=e.generateKey(t);let r,s=await e.storage.get(a);e:if("empty"===s.state||"stale"===s.state){if(e.waiting[a]){s=await e.storage.get(a),e.debug?.({id:a,msg:"Waiting list had an deferred for this key, waiting for it to finish"});break e}return e.waiting[a]=(0,i.deferred)(),e.waiting[a]?.catch((()=>{})),await e.storage.set(a,{state:"loading",previous:s.state,data:s.data,createdAt:s.createdAt}),"stale"===s.state&&(d(s,t),e.debug?.({id:a,msg:"Updated stale request"})),t.validateStatus=o(t.validateStatus),e.debug?.({id:a,msg:"Sending request, waiting for response"}),t}if("loading"===s.state){const s=e.waiting[a];if(!s)return await e.storage.remove(a),t;e.debug?.({id:a,msg:"Detected concurrent request, waiting for it to finish"});try{r=await s}catch(r){return e.debug?.({id:a,msg:"Deferred rejected, requesting again",data:r}),t}}else r=s.data;return t.adapter=()=>Promise.resolve({config:t,data:r.data,headers:r.headers,status:r.status,statusText:r.statusText,cached:!0,id:a}),e.debug?.({id:a,msg:"Returning cached response"}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function g(e,t){if("function"==typeof t)return t(e);const{statusCheck:a,responseMatch:r,containsHeaders:s}=t;if(a&&!await a(e.status)||r&&!await r(e))return!1;if(s)for(const t in s){const a=s[t];if(a&&!await a(e.headers[t.toLowerCase()]??e.headers[t]))return!1}return!0}async function f(e,t,a){for(const r in a){const s=a[r];if("delete"===s){await e.remove(r);continue}const i=await e.get(r);if("loading"===i.state)continue;const o=await s(i,t);"delete"!==o?"ignore"!==o&&await e.set(r,o):await e.remove(r)}}function h(e){const t=async t=>{await e.storage.remove(t),e.waiting[t]?.reject(null),delete e.waiting[t]},a=async a=>{var s;if(a.id=(s=a.config).id??(s.id=e.generateKey(a.config)),a.cached??(a.cached=!1),a.cached)return e.debug?.({id:a.id,msg:"Returned cached response"}),a;if(!a.config.cache)return e.debug?.({id:a.id,msg:"Response with config.cache === false",data:a}),{...a,cached:!1};const i=a.config.cache,o=await e.storage.get(a.id);if("stale"===o.state||"empty"===o.state||"cached"===o.state)return e.debug?.({id:a.id,msg:"Response not cached but storage is not loading",data:{cache:o,response:a}}),a;if(!o.data&&!await g(a,i.cachePredicate))return await t(a.id),e.debug?.({id:a.id,msg:"Cache predicate rejected this response"}),a;for(const e in r)e.startsWith("XAxiosCache")&&delete a.headers[e];i.etag&&!0!==i.etag&&(a.headers[r.XAxiosCacheEtag]=i.etag),i.modifiedSince&&(a.headers[r.XAxiosCacheLastModified]=!0===i.modifiedSince?"use-cache-timestamp":i.modifiedSince.toUTCString());let n=i.ttl||-1;if(i?.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),e.debug?.({id:a.id,msg:"Cache header interpreted as 'dont cache'",data:{cache:o,response:a,expirationTime:r}}),a;n="not enough headers"===r?n:r}const d=c(a,o.data);"function"==typeof n&&(n=await n(a)),i.staleIfError&&(a.headers[r.XAxiosCacheStaleIfError]=String(n)),e.debug?.({id:a.id,msg:"Useful response configuration found",data:{cacheConfig:i,ttl:n,cacheResponse:d}}),i?.update&&await f(e.storage,a,i.update);const u={state:"cached",ttl:n,createdAt:Date.now(),data:d},h=e.waiting[a.id];return h&&(h.resolve(u.data),delete e.waiting[a.id],e.debug?.({id:a.id,msg:"Found waiting deferred(s) and resolved them"})),await e.storage.set(a.id,u),e.debug?.({id:a.id,msg:"Response cached",data:{cache:u,response:a}}),a},s=async a=>{const r=a.config;if(!r||!1===r.cache||!r.id)throw e.debug?.({msg:"Web request returned an error but cache handling is not enabled",data:{error:a,config:r}}),a;const s=await e.storage.get(r.id),i=r.cache;if("loading"!==s.state||"stale"!==s.previous)throw await t(r.id),e.debug?.({msg:"Caught an error in the request interceptor",data:{error:a,config:r}}),a;if(i?.staleIfError){const t="function"==typeof i.staleIfError?await i.staleIfError(a.response,s,a):i.staleIfError;if(e.debug?.({msg:"Found cache if stale config for rejected response",data:{error:a,config:r,staleIfError:t}}),!0===t||"number"==typeof t&&s.createdAt+t>Date.now())return e.waiting[r.id]?.resolve(s.data),delete e.waiting[r.id],await e.storage.set(r.id,{state:"stale",createdAt:Date.now(),data:s.data}),e.debug?.({msg:"staleIfError resolved this response with cached data",data:{error:a,config:r,cache:s}}),{cached:!0,config:r,id:r.id,data:s.data.data,headers:s.data.headers,status:s.data.status,statusText:s.data.statusText}}throw e.debug?.({msg:"Received an unknown error that could not be handled",data:{error:a,config:r}}),a};return{onFulfilled:a,onRejected:s,apply:()=>e.interceptors.response.use(a,s)}}const l=Symbol(),p=e=>!!e&&!!e[l];function m(e){const t=e.data.headers;return r.ETag in t||r.LastModified in t||r.XAxiosCacheEtag in t||r.XAxiosCacheStaleIfError in t||r.XAxiosCacheLastModified in t}function w(e){return e.createdAt+e.ttl<=Date.now()}function b({set:e,find:t,remove:a}){return{[l]:1,set:e,remove:a,get:async r=>{const s=await t(r);if(!s)return{state:"empty"};if("cached"!==s.state||!w(s))return s;if(m(s)){const t={state:"stale",createdAt:s.createdAt,data:s.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function y(){const e=b({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}const S=require("object-code"),I=/^\/|\/$/g;function C(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(I,"")),a.url&&(a.url=a.url.replace(I,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,S.hashCode)(r).toString():r}}const x=C(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:s})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:s})));function v(e,t={}){const a=e;if(a.storage=t.storage||y(),!p(a.storage))throw new Error("Use buildStorage() function");return a.generateKey=t.generateKey||x,a.waiting=t.waiting||{},a.headerInterpreter=t.headerInterpreter||s,a.requestInterceptor=t.requestInterceptor||u(a),a.responseInterceptor=t.responseInterceptor||h(a),a.debug=t.debug,a.defaults.cache={ttl:t.ttl??3e5,interpretHeader:t.interpretHeader??!1,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:t.etag??!1,modifiedSince:t.modifiedSince??!1,staleIfError:t.staleIfError??!1,update:t.update||{}},a.requestInterceptor.apply(),a.responseInterceptor.apply(),a}function A(e,t=""){return b({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},remove:a=>{e.removeItem(t+a)},set:(a,r)=>{const s=()=>e.setItem(t+a,JSON.stringify(r));try{return s()}catch(r){const i=Object.entries(e).filter((([a])=>a.startsWith(t)&&e.getItem(a))).map((([e,t])=>[e,JSON.parse(t)]));for(const[t,a]of i)"cached"===a.state&&w(a)&&!m(a)&&e.removeItem(t);try{return s()}catch(t){const a=i.sort((([,e],[,t])=>(e.createdAt||0)-(t.createdAt||0)));for(const[t]of a){e.removeItem(t);try{return s()}catch(e){}}}e.removeItem(t+a)}}})}console.error("You are using a development build. Make sure to use the correct build in production"),console.error("https://axios-cache-interceptor.js.org/#/pages/installing"),module.exports=t})();
//# sourceMappingURL=dev.map

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

(()=>{"use strict";var e={d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Header:()=>r,buildKeyGenerator:()=>S,buildMemoryStorage:()=>m,buildStorage:()=>w,buildWebStorage:()=>x,createCacheResponse:()=>c,createValidateStatus:()=>n,defaultHeaderInterpreter:()=>i,defaultKeyGenerator:()=>b,defaultRequestInterceptor:()=>u,defaultResponseInterceptor:()=>h,isMethodIn:()=>o,isStorage:()=>p,setupCache:()=>I,testCachePredicate:()=>f,updateCache:()=>l,updateStaleRequest:()=>d});const a=require("cache-parser"),r=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),i=e=>{if(!e)return"not enough headers";const t=e[r.CacheControl];if(t){const{noCache:i,noStore:s,mustRevalidate:n,maxAge:o,immutable:d}=(0,a.parse)(String(t));if(i||s)return"dont cache";if(d)return 31536e6;if(n)return 0;if(o){const t=e[r.Age];return t?1e3*(o-Number(t)):1e3*o}}const i=e[r.Expires];if(i){const e=Date.parse(String(i))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"},s=require("fast-defer");function n(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function o(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function d(e,t){var a;t.headers||(t.headers={});const{etag:i,modifiedSince:s}=t.cache;if(i){const s=!0===i?null===(a=e.data)||void 0===a?void 0:a.headers[r.ETag]:i;s&&(t.headers[r.IfNoneMatch]=s)}s&&(t.headers[r.IfModifiedSince]=!0===s?e.data.headers[r.LastModified]||new Date(e.createdAt).toUTCString():s.toUTCString())}function c(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function u(e){const t=async t=>{var a;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!o(t.method,t.cache.methods))return t;const r=t.id=e.generateKey(t);let i,c=await e.storage.get(r);e:if("empty"===c.state||"stale"===c.state){if(e.waiting[r]){c=await e.storage.get(r);break e}return e.waiting[r]=(0,s.deferred)(),null===(a=e.waiting[r])||void 0===a||a.catch((()=>{})),await e.storage.set(r,{state:"loading",previous:c.state,data:c.data,createdAt:c.createdAt}),"stale"===c.state&&d(c,t),t.validateStatus=n(t.validateStatus),t}if("loading"===c.state){const a=e.waiting[r];if(!a)return await e.storage.remove(r),t;0;try{i=await a}catch(e){return t}}else i=c.data;return t.adapter=()=>Promise.resolve({config:t,data:i.data,headers:i.headers,status:i.status,statusText:i.statusText,cached:!0,id:r}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function f(e,t){var a;if("function"==typeof t)return t(e);const{statusCheck:r,responseMatch:i,containsHeaders:s}=t;if(r&&!await r(e.status)||i&&!await i(e))return!1;if(s)for(const t in s){const r=s[t];if(r&&!await r(null!==(a=e.headers[t.toLowerCase()])&&void 0!==a?a:e.headers[t]))return!1}return!0}async function l(e,t,a){for(const r in a){const i=a[r];if("delete"===i){await e.remove(r);continue}const s=await e.get(r);if("loading"===s.state)continue;const n=await i(s,t);"delete"!==n?"ignore"!==n&&await e.set(r,n):await e.remove(r)}}function h(e){const t=async t=>{var a;await e.storage.remove(t),null===(a=e.waiting[t])||void 0===a||a.reject(null),delete e.waiting[t]},a=async a=>{var i,s,n;if(a.id=null!==(i=(n=a.config).id)&&void 0!==i?i:n.id=e.generateKey(a.config),null!==(s=a.cached)&&void 0!==s||(a.cached=!1),a.cached)return a;if(!a.config.cache)return Object.assign(Object.assign({},a),{cached:!1});const o=a.config.cache,d=await e.storage.get(a.id);if("stale"===d.state||"empty"===d.state||"cached"===d.state)return a;if(!d.data&&!await f(a,o.cachePredicate))return await t(a.id),a;for(const e in r)e.startsWith("XAxiosCache")&&delete a.headers[e];o.etag&&!0!==o.etag&&(a.headers[r.XAxiosCacheEtag]=o.etag),o.modifiedSince&&(a.headers[r.XAxiosCacheLastModified]=!0===o.modifiedSince?"use-cache-timestamp":o.modifiedSince.toUTCString());let u=o.ttl||-1;if(null==o?void 0:o.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),a;u="not enough headers"===r?u:r}const h=c(a,d.data);"function"==typeof u&&(u=await u(a)),o.staleIfError&&(a.headers[r.XAxiosCacheStaleIfError]=String(u)),(null==o?void 0:o.update)&&await l(e.storage,a,o.update);const g={state:"cached",ttl:u,createdAt:Date.now(),data:h},p=e.waiting[a.id];return p&&(p.resolve(g.data),delete e.waiting[a.id]),await e.storage.set(a.id,g),a},i=async a=>{var r;const i=a.config;if(!i||!1===i.cache||!i.id)throw a;const s=await e.storage.get(i.id),n=i.cache;if("loading"!==s.state||"stale"!==s.previous)throw await t(i.id),a;if(null==n?void 0:n.staleIfError){const t="function"==typeof n.staleIfError?await n.staleIfError(a.response,s,a):n.staleIfError;if(!0===t||"number"==typeof t&&s.createdAt+t>Date.now())return null===(r=e.waiting[i.id])||void 0===r||r.resolve(s.data),delete e.waiting[i.id],await e.storage.set(i.id,{state:"stale",createdAt:Date.now(),data:s.data}),{cached:!0,config:i,id:i.id,data:s.data.data,headers:s.data.headers,status:s.data.status,statusText:s.data.statusText}}throw a};return{onFulfilled:a,onRejected:i,apply:()=>e.interceptors.response.use(a,i)}}const g=Symbol(),p=e=>!!e&&!!e[g];function w({set:e,find:t,remove:a}){return{[g]:1,set:e,remove:a,get:async i=>{const s=await t(i);if(!s)return{state:"empty"};if("cached"!==s.state||s.createdAt+s.ttl>Date.now())return s;if(s.data.headers&&(r.ETag in s.data.headers||r.LastModified in s.data.headers||r.XAxiosCacheEtag in s.data.headers||r.XAxiosCacheStaleIfError in s.data.headers||r.XAxiosCacheLastModified in s.data.headers)){const t={state:"stale",createdAt:s.createdAt,data:s.data};return await e(i,t),t}return await a(i),{state:"empty"}}}}function m(){const e=w({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}const v=require("object-code"),y=/^\/|\/$/g;function S(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(y,"")),a.url&&(a.url=a.url.replace(y,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,v.code)(r).toString():r}}const b=S(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:i})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:i})));function I(e,t={}){var a,r,s,n,o;const d=e;if(d.storage=t.storage||m(),!p(d.storage))throw new Error("Use buildStorage() function");return d.generateKey=t.generateKey||b,d.waiting=t.waiting||{},d.headerInterpreter=t.headerInterpreter||i,d.requestInterceptor=t.requestInterceptor||u(d),d.responseInterceptor=t.responseInterceptor||h(d),d.debug=t.debug,d.defaults.cache={ttl:null!==(a=t.ttl)&&void 0!==a?a:3e5,interpretHeader:null!==(r=t.interpretHeader)&&void 0!==r&&r,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(s=t.etag)&&void 0!==s&&s,modifiedSince:null!==(n=t.modifiedSince)&&void 0!==n&&n,staleIfError:null!==(o=t.staleIfError)&&void 0!==o&&o,update:t.update||{}},d.requestInterceptor.apply(),d.responseInterceptor.apply(),d}function x(e,t=""){return w({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},set:(a,r)=>{e.setItem(t+a,JSON.stringify(r))},remove:a=>{e.removeItem(t+a)}})}module.exports=t})();
(()=>{"use strict";var e={d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Header:()=>r,buildKeyGenerator:()=>I,buildMemoryStorage:()=>y,buildStorage:()=>v,buildWebStorage:()=>A,canStale:()=>m,createCacheResponse:()=>d,createValidateStatus:()=>s,defaultHeaderInterpreter:()=>i,defaultKeyGenerator:()=>x,defaultRequestInterceptor:()=>u,defaultResponseInterceptor:()=>h,isExpired:()=>w,isMethodIn:()=>o,isStorage:()=>p,setupCache:()=>C,testCachePredicate:()=>f,updateCache:()=>l,updateStaleRequest:()=>c});const a=require("cache-parser"),r=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),i=e=>{if(!e)return"not enough headers";const t=e[r.CacheControl];if(t){const{noCache:i,noStore:n,mustRevalidate:s,maxAge:o,immutable:c}=(0,a.parse)(String(t));if(i||n)return"dont cache";if(c)return 31536e6;if(s)return 0;if(o){const t=e[r.Age];return t?1e3*(o-Number(t)):1e3*o}}const i=e[r.Expires];if(i){const e=Date.parse(String(i))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"},n=require("fast-defer");function s(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function o(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function c(e,t){var a;t.headers||(t.headers={});const{etag:i,modifiedSince:n}=t.cache;if(i){const n=!0===i?null===(a=e.data)||void 0===a?void 0:a.headers[r.ETag]:i;n&&(t.headers[r.IfNoneMatch]=n)}n&&(t.headers[r.IfModifiedSince]=!0===n?e.data.headers[r.LastModified]||new Date(e.createdAt).toUTCString():n.toUTCString())}function d(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function u(e){const t=async t=>{var a;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!o(t.method,t.cache.methods))return t;const r=t.id=e.generateKey(t);let i,d=await e.storage.get(r);e:if("empty"===d.state||"stale"===d.state){if(e.waiting[r]){d=await e.storage.get(r);break e}return e.waiting[r]=(0,n.deferred)(),null===(a=e.waiting[r])||void 0===a||a.catch((()=>{})),await e.storage.set(r,{state:"loading",previous:d.state,data:d.data,createdAt:d.createdAt}),"stale"===d.state&&c(d,t),t.validateStatus=s(t.validateStatus),t}if("loading"===d.state){const a=e.waiting[r];if(!a)return await e.storage.remove(r),t;0;try{i=await a}catch(e){return t}}else i=d.data;return t.adapter=()=>Promise.resolve({config:t,data:i.data,headers:i.headers,status:i.status,statusText:i.statusText,cached:!0,id:r}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function f(e,t){var a;if("function"==typeof t)return t(e);const{statusCheck:r,responseMatch:i,containsHeaders:n}=t;if(r&&!await r(e.status)||i&&!await i(e))return!1;if(n)for(const t in n){const r=n[t];if(r&&!await r(null!==(a=e.headers[t.toLowerCase()])&&void 0!==a?a:e.headers[t]))return!1}return!0}async function l(e,t,a){for(const r in a){const i=a[r];if("delete"===i){await e.remove(r);continue}const n=await e.get(r);if("loading"===n.state)continue;const s=await i(n,t);"delete"!==s?"ignore"!==s&&await e.set(r,s):await e.remove(r)}}function h(e){const t=async t=>{var a;await e.storage.remove(t),null===(a=e.waiting[t])||void 0===a||a.reject(null),delete e.waiting[t]},a=async a=>{var i,n,s;if(a.id=null!==(i=(s=a.config).id)&&void 0!==i?i:s.id=e.generateKey(a.config),null!==(n=a.cached)&&void 0!==n||(a.cached=!1),a.cached)return a;if(!a.config.cache)return Object.assign(Object.assign({},a),{cached:!1});const o=a.config.cache,c=await e.storage.get(a.id);if("stale"===c.state||"empty"===c.state||"cached"===c.state)return a;if(!c.data&&!await f(a,o.cachePredicate))return await t(a.id),a;for(const e in r)e.startsWith("XAxiosCache")&&delete a.headers[e];o.etag&&!0!==o.etag&&(a.headers[r.XAxiosCacheEtag]=o.etag),o.modifiedSince&&(a.headers[r.XAxiosCacheLastModified]=!0===o.modifiedSince?"use-cache-timestamp":o.modifiedSince.toUTCString());let u=o.ttl||-1;if(null==o?void 0:o.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),a;u="not enough headers"===r?u:r}const h=d(a,c.data);"function"==typeof u&&(u=await u(a)),o.staleIfError&&(a.headers[r.XAxiosCacheStaleIfError]=String(u)),(null==o?void 0:o.update)&&await l(e.storage,a,o.update);const g={state:"cached",ttl:u,createdAt:Date.now(),data:h},p=e.waiting[a.id];return p&&(p.resolve(g.data),delete e.waiting[a.id]),await e.storage.set(a.id,g),a},i=async a=>{var r;const i=a.config;if(!i||!1===i.cache||!i.id)throw a;const n=await e.storage.get(i.id),s=i.cache;if("loading"!==n.state||"stale"!==n.previous)throw await t(i.id),a;if(null==s?void 0:s.staleIfError){const t="function"==typeof s.staleIfError?await s.staleIfError(a.response,n,a):s.staleIfError;if(!0===t||"number"==typeof t&&n.createdAt+t>Date.now())return null===(r=e.waiting[i.id])||void 0===r||r.resolve(n.data),delete e.waiting[i.id],await e.storage.set(i.id,{state:"stale",createdAt:Date.now(),data:n.data}),{cached:!0,config:i,id:i.id,data:n.data.data,headers:n.data.headers,status:n.data.status,statusText:n.data.statusText}}throw a};return{onFulfilled:a,onRejected:i,apply:()=>e.interceptors.response.use(a,i)}}const g=Symbol(),p=e=>!!e&&!!e[g];function m(e){const t=e.data.headers;return r.ETag in t||r.LastModified in t||r.XAxiosCacheEtag in t||r.XAxiosCacheStaleIfError in t||r.XAxiosCacheLastModified in t}function w(e){return e.createdAt+e.ttl<=Date.now()}function v({set:e,find:t,remove:a}){return{[g]:1,set:e,remove:a,get:async r=>{const i=await t(r);if(!i)return{state:"empty"};if("cached"!==i.state||!w(i))return i;if(m(i)){const t={state:"stale",createdAt:i.createdAt,data:i.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function y(){const e=v({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}const S=require("object-code"),b=/^\/|\/$/g;function I(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(b,"")),a.url&&(a.url=a.url.replace(b,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,S.hashCode)(r).toString():r}}const x=I(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:i})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:i})));function C(e,t={}){var a,r,n,s,o;const c=e;if(c.storage=t.storage||y(),!p(c.storage))throw new Error("Use buildStorage() function");return c.generateKey=t.generateKey||x,c.waiting=t.waiting||{},c.headerInterpreter=t.headerInterpreter||i,c.requestInterceptor=t.requestInterceptor||u(c),c.responseInterceptor=t.responseInterceptor||h(c),c.debug=t.debug,c.defaults.cache={ttl:null!==(a=t.ttl)&&void 0!==a?a:3e5,interpretHeader:null!==(r=t.interpretHeader)&&void 0!==r&&r,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(s=t.modifiedSince)&&void 0!==s&&s,staleIfError:null!==(o=t.staleIfError)&&void 0!==o&&o,update:t.update||{}},c.requestInterceptor.apply(),c.responseInterceptor.apply(),c}function A(e,t=""){return v({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},remove:a=>{e.removeItem(t+a)},set:(a,r)=>{const i=()=>e.setItem(t+a,JSON.stringify(r));try{return i()}catch(r){const n=Object.entries(e).filter((([a])=>a.startsWith(t)&&e.getItem(a))).map((([e,t])=>[e,JSON.parse(t)]));for(const[t,a]of n)"cached"===a.state&&w(a)&&!m(a)&&e.removeItem(t);try{return i()}catch(t){const a=n.sort((([,e],[,t])=>(e.createdAt||0)-(t.createdAt||0)));for(const[t]of a){e.removeItem(t);try{return i()}catch(e){}}}e.removeItem(t+a)}}})}module.exports=t})();

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

import*as e from"cache-parser";import*as t from"fast-defer";import*as a from"object-code";var r={d:(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},s={};r.d(s,{h4:()=>d,UN:()=>C,uu:()=>S,Kd:()=>I,ZF:()=>E,p:()=>h,E7:()=>c,NQ:()=>o,xK:()=>v,G6:()=>f,LN:()=>m,Ad:()=>u,$k:()=>b,v8:()=>A,Jk:()=>l,tI:()=>p,iS:()=>g});const i=(e=>{var t={};return r.d(t,e),t})({parse:()=>e.parse}),d=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),o=e=>{if(!e)return"not enough headers";const t=e[d.CacheControl];if(t){const{noCache:a,noStore:r,mustRevalidate:s,maxAge:o,immutable:n}=(0,i.parse)(String(t));if(a||r)return"dont cache";if(n)return 31536e6;if(s)return 0;if(o){const t=e[d.Age];return t?1e3*(o-Number(t)):1e3*o}}const a=e[d.Expires];if(a){const e=Date.parse(String(a))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};const n=(e=>{var t={};return r.d(t,e),t})({deferred:()=>t.deferred});function c(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function u(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function g(e,t){t.headers||(t.headers={});const{etag:a,modifiedSince:r}=t.cache;if(a){const r=!0===a?e.data?.headers[d.ETag]:a;r&&(t.headers[d.IfNoneMatch]=r)}r&&(t.headers[d.IfModifiedSince]=!0===r?e.data.headers[d.LastModified]||new Date(e.createdAt).toUTCString():r.toUTCString())}function h(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers={...t.headers,...e.headers},t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function f(e){const t=async t=>{if(!1===t.cache)return e.debug?.({msg:"Ignoring cache because config.cache is false",data:t}),t;if(t.cache={...e.defaults.cache,...t.cache},!u(t.method,t.cache.methods))return e.debug?.({msg:`Ignored because method (${t.method}) is not in cache.methods (${t.cache.methods})`}),t;const a=t.id=e.generateKey(t);let r,s=await e.storage.get(a);e:if("empty"===s.state||"stale"===s.state){if(e.waiting[a]){s=await e.storage.get(a),e.debug?.({id:a,msg:"Waiting list had an deferred for this key, waiting for it to finish"});break e}return e.waiting[a]=(0,n.deferred)(),e.waiting[a]?.catch((()=>{})),await e.storage.set(a,{state:"loading",previous:s.state,data:s.data,createdAt:s.createdAt}),"stale"===s.state&&(g(s,t),e.debug?.({id:a,msg:"Updated stale request"})),t.validateStatus=c(t.validateStatus),e.debug?.({id:a,msg:"Sending request, waiting for response"}),t}if("loading"===s.state){const s=e.waiting[a];if(!s)return await e.storage.remove(a),t;e.debug?.({id:a,msg:"Detected concurrent request, waiting for it to finish"});try{r=await s}catch(r){return e.debug?.({id:a,msg:"Deferred rejected, requesting again",data:r}),t}}else r=s.data;return t.adapter=()=>Promise.resolve({config:t,data:r.data,headers:r.headers,status:r.status,statusText:r.statusText,cached:!0,id:a}),e.debug?.({id:a,msg:"Returning cached response"}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function l(e,t){if("function"==typeof t)return t(e);const{statusCheck:a,responseMatch:r,containsHeaders:s}=t;if(a&&!await a(e.status)||r&&!await r(e))return!1;if(s)for(const t in s){const a=s[t];if(a&&!await a(e.headers[t.toLowerCase()]??e.headers[t]))return!1}return!0}async function p(e,t,a){for(const r in a){const s=a[r];if("delete"===s){await e.remove(r);continue}const i=await e.get(r);if("loading"===i.state)continue;const d=await s(i,t);"delete"!==d?"ignore"!==d&&await e.set(r,d):await e.remove(r)}}function m(e){const t=async t=>{await e.storage.remove(t),e.waiting[t]?.reject(null),delete e.waiting[t]},a=async a=>{var r;if(a.id=(r=a.config).id??(r.id=e.generateKey(a.config)),a.cached??(a.cached=!1),a.cached)return e.debug?.({id:a.id,msg:"Returned cached response"}),a;if(!a.config.cache)return e.debug?.({id:a.id,msg:"Response with config.cache === false",data:a}),{...a,cached:!1};const s=a.config.cache,i=await e.storage.get(a.id);if("stale"===i.state||"empty"===i.state||"cached"===i.state)return e.debug?.({id:a.id,msg:"Response not cached but storage is not loading",data:{cache:i,response:a}}),a;if(!i.data&&!await l(a,s.cachePredicate))return await t(a.id),e.debug?.({id:a.id,msg:"Cache predicate rejected this response"}),a;for(const e in d)e.startsWith("XAxiosCache")&&delete a.headers[e];s.etag&&!0!==s.etag&&(a.headers[d.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(a.headers[d.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString());let o=s.ttl||-1;if(s?.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),e.debug?.({id:a.id,msg:"Cache header interpreted as 'dont cache'",data:{cache:i,response:a,expirationTime:r}}),a;o="not enough headers"===r?o:r}const n=h(a,i.data);"function"==typeof o&&(o=await o(a)),s.staleIfError&&(a.headers[d.XAxiosCacheStaleIfError]=String(o)),e.debug?.({id:a.id,msg:"Useful response configuration found",data:{cacheConfig:s,ttl:o,cacheResponse:n}}),s?.update&&await p(e.storage,a,s.update);const c={state:"cached",ttl:o,createdAt:Date.now(),data:n},u=e.waiting[a.id];return u&&(u.resolve(c.data),delete e.waiting[a.id],e.debug?.({id:a.id,msg:"Found waiting deferred(s) and resolved them"})),await e.storage.set(a.id,c),e.debug?.({id:a.id,msg:"Response cached",data:{cache:c,response:a}}),a},r=async a=>{const r=a.config;if(!r||!1===r.cache||!r.id)throw e.debug?.({msg:"Web request returned an error but cache handling is not enabled",data:{error:a,config:r}}),a;const s=await e.storage.get(r.id),i=r.cache;if("loading"!==s.state||"stale"!==s.previous)throw await t(r.id),e.debug?.({msg:"Caught an error in the request interceptor",data:{error:a,config:r}}),a;if(i?.staleIfError){const t="function"==typeof i.staleIfError?await i.staleIfError(a.response,s,a):i.staleIfError;if(e.debug?.({msg:"Found cache if stale config for rejected response",data:{error:a,config:r,staleIfError:t}}),!0===t||"number"==typeof t&&s.createdAt+t>Date.now())return e.waiting[r.id]?.resolve(s.data),delete e.waiting[r.id],await e.storage.set(r.id,{state:"stale",createdAt:Date.now(),data:s.data}),e.debug?.({msg:"staleIfError resolved this response with cached data",data:{error:a,config:r,cache:s}}),{cached:!0,config:r,id:r.id,data:s.data.data,headers:s.data.headers,status:s.data.status,statusText:s.data.statusText}}throw e.debug?.({msg:"Received an unknown error that could not be handled",data:{error:a,config:r}}),a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const w=Symbol(),b=e=>!!e&&!!e[w];function I({set:e,find:t,remove:a}){return{[w]:1,set:e,remove:a,get:async r=>{const s=await t(r);if(!s)return{state:"empty"};if("cached"!==s.state||s.createdAt+s.ttl>Date.now())return s;if(s.data.headers&&(d.ETag in s.data.headers||d.LastModified in s.data.headers||d.XAxiosCacheEtag in s.data.headers||d.XAxiosCacheStaleIfError in s.data.headers||d.XAxiosCacheLastModified in s.data.headers)){const t={state:"stale",createdAt:s.createdAt,data:s.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function S(){const e=I({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}const x=(e=>{var t={};return r.d(t,e),t})({code:()=>a.code}),y=/^\/|\/$/g;function C(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(y,"")),a.url&&(a.url=a.url.replace(y,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,x.code)(r).toString():r}}const v=C(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:s})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:s})));function A(e,t={}){const a=e;if(a.storage=t.storage||S(),!b(a.storage))throw new Error("Use buildStorage() function");return a.generateKey=t.generateKey||v,a.waiting=t.waiting||{},a.headerInterpreter=t.headerInterpreter||o,a.requestInterceptor=t.requestInterceptor||f(a),a.responseInterceptor=t.responseInterceptor||m(a),a.debug=t.debug,a.defaults.cache={ttl:t.ttl??3e5,interpretHeader:t.interpretHeader??!1,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:t.etag??!1,modifiedSince:t.modifiedSince??!1,staleIfError:t.staleIfError??!1,update:t.update||{}},a.requestInterceptor.apply(),a.responseInterceptor.apply(),a}function E(e,t=""){return I({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},set:(a,r)=>{e.setItem(t+a,JSON.stringify(r))},remove:a=>{e.removeItem(t+a)}})}console.error("You are using a development build. Make sure to use the correct build in production"),console.error("https://axios-cache-interceptor.js.org/#/pages/installing");var R=s.h4,L=s.UN,T=s.uu,M=s.Kd,q=s.ZF,U=s.p,j=s.E7,N=s.NQ,k=s.xK,K=s.G6,X=s.LN,D=s.Ad,O=s.$k,P=s.v8,F=s.Jk,H=s.tI,$=s.iS;export{R as Header,L as buildKeyGenerator,T as buildMemoryStorage,M as buildStorage,q as buildWebStorage,U as createCacheResponse,j as createValidateStatus,N as defaultHeaderInterpreter,k as defaultKeyGenerator,K as defaultRequestInterceptor,X as defaultResponseInterceptor,D as isMethodIn,O as isStorage,P as setupCache,F as testCachePredicate,H as updateCache,$ as updateStaleRequest};
import*as e from"cache-parser";import*as t from"fast-defer";import*as a from"object-code";var r={d:(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},s={};r.d(s,{h4:()=>n,UN:()=>A,uu:()=>S,Kd:()=>y,ZF:()=>L,nv:()=>I,p:()=>h,E7:()=>c,NQ:()=>o,xK:()=>E,G6:()=>f,LN:()=>m,Bw:()=>v,Ad:()=>u,$k:()=>b,v8:()=>R,Jk:()=>l,tI:()=>p,iS:()=>g});const i=(e=>{var t={};return r.d(t,e),t})({parse:()=>e.parse}),n=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),o=e=>{if(!e)return"not enough headers";const t=e[n.CacheControl];if(t){const{noCache:a,noStore:r,mustRevalidate:s,maxAge:o,immutable:d}=(0,i.parse)(String(t));if(a||r)return"dont cache";if(d)return 31536e6;if(s)return 0;if(o){const t=e[n.Age];return t?1e3*(o-Number(t)):1e3*o}}const a=e[n.Expires];if(a){const e=Date.parse(String(a))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};const d=(e=>{var t={};return r.d(t,e),t})({deferred:()=>t.deferred});function c(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function u(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function g(e,t){t.headers||(t.headers={});const{etag:a,modifiedSince:r}=t.cache;if(a){const r=!0===a?e.data?.headers[n.ETag]:a;r&&(t.headers[n.IfNoneMatch]=r)}r&&(t.headers[n.IfModifiedSince]=!0===r?e.data.headers[n.LastModified]||new Date(e.createdAt).toUTCString():r.toUTCString())}function h(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers={...t.headers,...e.headers},t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function f(e){const t=async t=>{if(!1===t.cache)return e.debug?.({msg:"Ignoring cache because config.cache is false",data:t}),t;if(t.cache={...e.defaults.cache,...t.cache},!u(t.method,t.cache.methods))return e.debug?.({msg:`Ignored because method (${t.method}) is not in cache.methods (${t.cache.methods})`}),t;const a=t.id=e.generateKey(t);let r,s=await e.storage.get(a);e:if("empty"===s.state||"stale"===s.state){if(e.waiting[a]){s=await e.storage.get(a),e.debug?.({id:a,msg:"Waiting list had an deferred for this key, waiting for it to finish"});break e}return e.waiting[a]=(0,d.deferred)(),e.waiting[a]?.catch((()=>{})),await e.storage.set(a,{state:"loading",previous:s.state,data:s.data,createdAt:s.createdAt}),"stale"===s.state&&(g(s,t),e.debug?.({id:a,msg:"Updated stale request"})),t.validateStatus=c(t.validateStatus),e.debug?.({id:a,msg:"Sending request, waiting for response"}),t}if("loading"===s.state){const s=e.waiting[a];if(!s)return await e.storage.remove(a),t;e.debug?.({id:a,msg:"Detected concurrent request, waiting for it to finish"});try{r=await s}catch(r){return e.debug?.({id:a,msg:"Deferred rejected, requesting again",data:r}),t}}else r=s.data;return t.adapter=()=>Promise.resolve({config:t,data:r.data,headers:r.headers,status:r.status,statusText:r.statusText,cached:!0,id:a}),e.debug?.({id:a,msg:"Returning cached response"}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function l(e,t){if("function"==typeof t)return t(e);const{statusCheck:a,responseMatch:r,containsHeaders:s}=t;if(a&&!await a(e.status)||r&&!await r(e))return!1;if(s)for(const t in s){const a=s[t];if(a&&!await a(e.headers[t.toLowerCase()]??e.headers[t]))return!1}return!0}async function p(e,t,a){for(const r in a){const s=a[r];if("delete"===s){await e.remove(r);continue}const i=await e.get(r);if("loading"===i.state)continue;const n=await s(i,t);"delete"!==n?"ignore"!==n&&await e.set(r,n):await e.remove(r)}}function m(e){const t=async t=>{await e.storage.remove(t),e.waiting[t]?.reject(null),delete e.waiting[t]},a=async a=>{var r;if(a.id=(r=a.config).id??(r.id=e.generateKey(a.config)),a.cached??(a.cached=!1),a.cached)return e.debug?.({id:a.id,msg:"Returned cached response"}),a;if(!a.config.cache)return e.debug?.({id:a.id,msg:"Response with config.cache === false",data:a}),{...a,cached:!1};const s=a.config.cache,i=await e.storage.get(a.id);if("stale"===i.state||"empty"===i.state||"cached"===i.state)return e.debug?.({id:a.id,msg:"Response not cached but storage is not loading",data:{cache:i,response:a}}),a;if(!i.data&&!await l(a,s.cachePredicate))return await t(a.id),e.debug?.({id:a.id,msg:"Cache predicate rejected this response"}),a;for(const e in n)e.startsWith("XAxiosCache")&&delete a.headers[e];s.etag&&!0!==s.etag&&(a.headers[n.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(a.headers[n.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString());let o=s.ttl||-1;if(s?.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),e.debug?.({id:a.id,msg:"Cache header interpreted as 'dont cache'",data:{cache:i,response:a,expirationTime:r}}),a;o="not enough headers"===r?o:r}const d=h(a,i.data);"function"==typeof o&&(o=await o(a)),s.staleIfError&&(a.headers[n.XAxiosCacheStaleIfError]=String(o)),e.debug?.({id:a.id,msg:"Useful response configuration found",data:{cacheConfig:s,ttl:o,cacheResponse:d}}),s?.update&&await p(e.storage,a,s.update);const c={state:"cached",ttl:o,createdAt:Date.now(),data:d},u=e.waiting[a.id];return u&&(u.resolve(c.data),delete e.waiting[a.id],e.debug?.({id:a.id,msg:"Found waiting deferred(s) and resolved them"})),await e.storage.set(a.id,c),e.debug?.({id:a.id,msg:"Response cached",data:{cache:c,response:a}}),a},r=async a=>{const r=a.config;if(!r||!1===r.cache||!r.id)throw e.debug?.({msg:"Web request returned an error but cache handling is not enabled",data:{error:a,config:r}}),a;const s=await e.storage.get(r.id),i=r.cache;if("loading"!==s.state||"stale"!==s.previous)throw await t(r.id),e.debug?.({msg:"Caught an error in the request interceptor",data:{error:a,config:r}}),a;if(i?.staleIfError){const t="function"==typeof i.staleIfError?await i.staleIfError(a.response,s,a):i.staleIfError;if(e.debug?.({msg:"Found cache if stale config for rejected response",data:{error:a,config:r,staleIfError:t}}),!0===t||"number"==typeof t&&s.createdAt+t>Date.now())return e.waiting[r.id]?.resolve(s.data),delete e.waiting[r.id],await e.storage.set(r.id,{state:"stale",createdAt:Date.now(),data:s.data}),e.debug?.({msg:"staleIfError resolved this response with cached data",data:{error:a,config:r,cache:s}}),{cached:!0,config:r,id:r.id,data:s.data.data,headers:s.data.headers,status:s.data.status,statusText:s.data.statusText}}throw e.debug?.({msg:"Received an unknown error that could not be handled",data:{error:a,config:r}}),a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const w=Symbol(),b=e=>!!e&&!!e[w];function I(e){const t=e.data.headers;return n.ETag in t||n.LastModified in t||n.XAxiosCacheEtag in t||n.XAxiosCacheStaleIfError in t||n.XAxiosCacheLastModified in t}function v(e){return e.createdAt+e.ttl<=Date.now()}function y({set:e,find:t,remove:a}){return{[w]:1,set:e,remove:a,get:async r=>{const s=await t(r);if(!s)return{state:"empty"};if("cached"!==s.state||!v(s))return s;if(I(s)){const t={state:"stale",createdAt:s.createdAt,data:s.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function S(){const e=y({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}const C=(e=>{var t={};return r.d(t,e),t})({hashCode:()=>a.hashCode}),x=/^\/|\/$/g;function A(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(x,"")),a.url&&(a.url=a.url.replace(x,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,C.hashCode)(r).toString():r}}const E=A(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:s})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:s})));function R(e,t={}){const a=e;if(a.storage=t.storage||S(),!b(a.storage))throw new Error("Use buildStorage() function");return a.generateKey=t.generateKey||E,a.waiting=t.waiting||{},a.headerInterpreter=t.headerInterpreter||o,a.requestInterceptor=t.requestInterceptor||f(a),a.responseInterceptor=t.responseInterceptor||m(a),a.debug=t.debug,a.defaults.cache={ttl:t.ttl??3e5,interpretHeader:t.interpretHeader??!1,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:t.etag??!1,modifiedSince:t.modifiedSince??!1,staleIfError:t.staleIfError??!1,update:t.update||{}},a.requestInterceptor.apply(),a.responseInterceptor.apply(),a}function L(e,t=""){return y({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},remove:a=>{e.removeItem(t+a)},set:(a,r)=>{const s=()=>e.setItem(t+a,JSON.stringify(r));try{return s()}catch(r){const i=Object.entries(e).filter((([a])=>a.startsWith(t)&&e.getItem(a))).map((([e,t])=>[e,JSON.parse(t)]));for(const[t,a]of i)"cached"===a.state&&v(a)&&!I(a)&&e.removeItem(t);try{return s()}catch(t){const a=i.sort((([,e],[,t])=>(e.createdAt||0)-(t.createdAt||0)));for(const[t]of a){e.removeItem(t);try{return s()}catch(e){}}}e.removeItem(t+a)}}})}console.error("You are using a development build. Make sure to use the correct build in production"),console.error("https://axios-cache-interceptor.js.org/#/pages/installing");var T=s.h4,M=s.UN,j=s.uu,q=s.Kd,N=s.ZF,U=s.nv,k=s.p,K=s.E7,X=s.NQ,D=s.xK,O=s.G6,P=s.LN,F=s.Bw,H=s.Ad,J=s.$k,W=s.v8,$=s.Jk,G=s.tI,B=s.iS;export{T as Header,M as buildKeyGenerator,j as buildMemoryStorage,q as buildStorage,N as buildWebStorage,U as canStale,k as createCacheResponse,K as createValidateStatus,X as defaultHeaderInterpreter,D as defaultKeyGenerator,O as defaultRequestInterceptor,P as defaultResponseInterceptor,F as isExpired,H as isMethodIn,J as isStorage,W as setupCache,$ as testCachePredicate,G as updateCache,B as updateStaleRequest};
//# sourceMappingURL=dev.map

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

import*as e from"cache-parser";import*as t from"fast-defer";import*as a from"object-code";var r={d:(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},s={};r.d(s,{h4:()=>n,UN:()=>b,uu:()=>y,Kd:()=>S,ZF:()=>E,p:()=>l,E7:()=>c,NQ:()=>o,xK:()=>C,G6:()=>h,LN:()=>w,Ad:()=>u,$k:()=>v,v8:()=>A,Jk:()=>g,tI:()=>p,iS:()=>f});const i=(e=>{var t={};return r.d(t,e),t})({parse:()=>e.parse}),n=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),o=e=>{if(!e)return"not enough headers";const t=e[n.CacheControl];if(t){const{noCache:a,noStore:r,mustRevalidate:s,maxAge:o,immutable:d}=(0,i.parse)(String(t));if(a||r)return"dont cache";if(d)return 31536e6;if(s)return 0;if(o){const t=e[n.Age];return t?1e3*(o-Number(t)):1e3*o}}const a=e[n.Expires];if(a){const e=Date.parse(String(a))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};const d=(e=>{var t={};return r.d(t,e),t})({deferred:()=>t.deferred});function c(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function u(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function f(e,t){var a;t.headers||(t.headers={});const{etag:r,modifiedSince:s}=t.cache;if(r){const s=!0===r?null===(a=e.data)||void 0===a?void 0:a.headers[n.ETag]:r;s&&(t.headers[n.IfNoneMatch]=s)}s&&(t.headers[n.IfModifiedSince]=!0===s?e.data.headers[n.LastModified]||new Date(e.createdAt).toUTCString():s.toUTCString())}function l(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function h(e){const t=async t=>{var a;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!u(t.method,t.cache.methods))return t;const r=t.id=e.generateKey(t);let s,i=await e.storage.get(r);e:if("empty"===i.state||"stale"===i.state){if(e.waiting[r]){i=await e.storage.get(r);break e}return e.waiting[r]=(0,d.deferred)(),null===(a=e.waiting[r])||void 0===a||a.catch((()=>{})),await e.storage.set(r,{state:"loading",previous:i.state,data:i.data,createdAt:i.createdAt}),"stale"===i.state&&f(i,t),t.validateStatus=c(t.validateStatus),t}if("loading"===i.state){const a=e.waiting[r];if(!a)return await e.storage.remove(r),t;0;try{s=await a}catch(e){return t}}else s=i.data;return t.adapter=()=>Promise.resolve({config:t,data:s.data,headers:s.headers,status:s.status,statusText:s.statusText,cached:!0,id:r}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function g(e,t){var a;if("function"==typeof t)return t(e);const{statusCheck:r,responseMatch:s,containsHeaders:i}=t;if(r&&!await r(e.status)||s&&!await s(e))return!1;if(i)for(const t in i){const r=i[t];if(r&&!await r(null!==(a=e.headers[t.toLowerCase()])&&void 0!==a?a:e.headers[t]))return!1}return!0}async function p(e,t,a){for(const r in a){const s=a[r];if("delete"===s){await e.remove(r);continue}const i=await e.get(r);if("loading"===i.state)continue;const n=await s(i,t);"delete"!==n?"ignore"!==n&&await e.set(r,n):await e.remove(r)}}function w(e){const t=async t=>{var a;await e.storage.remove(t),null===(a=e.waiting[t])||void 0===a||a.reject(null),delete e.waiting[t]},a=async a=>{var r,s,i;if(a.id=null!==(r=(i=a.config).id)&&void 0!==r?r:i.id=e.generateKey(a.config),null!==(s=a.cached)&&void 0!==s||(a.cached=!1),a.cached)return a;if(!a.config.cache)return Object.assign(Object.assign({},a),{cached:!1});const o=a.config.cache,d=await e.storage.get(a.id);if("stale"===d.state||"empty"===d.state||"cached"===d.state)return a;if(!d.data&&!await g(a,o.cachePredicate))return await t(a.id),a;for(const e in n)e.startsWith("XAxiosCache")&&delete a.headers[e];o.etag&&!0!==o.etag&&(a.headers[n.XAxiosCacheEtag]=o.etag),o.modifiedSince&&(a.headers[n.XAxiosCacheLastModified]=!0===o.modifiedSince?"use-cache-timestamp":o.modifiedSince.toUTCString());let c=o.ttl||-1;if(null==o?void 0:o.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),a;c="not enough headers"===r?c:r}const u=l(a,d.data);"function"==typeof c&&(c=await c(a)),o.staleIfError&&(a.headers[n.XAxiosCacheStaleIfError]=String(c)),(null==o?void 0:o.update)&&await p(e.storage,a,o.update);const f={state:"cached",ttl:c,createdAt:Date.now(),data:u},h=e.waiting[a.id];return h&&(h.resolve(f.data),delete e.waiting[a.id]),await e.storage.set(a.id,f),a},r=async a=>{var r;const s=a.config;if(!s||!1===s.cache||!s.id)throw a;const i=await e.storage.get(s.id),n=s.cache;if("loading"!==i.state||"stale"!==i.previous)throw await t(s.id),a;if(null==n?void 0:n.staleIfError){const t="function"==typeof n.staleIfError?await n.staleIfError(a.response,i,a):n.staleIfError;if(!0===t||"number"==typeof t&&i.createdAt+t>Date.now())return null===(r=e.waiting[s.id])||void 0===r||r.resolve(i.data),delete e.waiting[s.id],await e.storage.set(s.id,{state:"stale",createdAt:Date.now(),data:i.data}),{cached:!0,config:s,id:s.id,data:i.data.data,headers:i.data.headers,status:i.data.status,statusText:i.data.statusText}}throw a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const m=Symbol(),v=e=>!!e&&!!e[m];function S({set:e,find:t,remove:a}){return{[m]:1,set:e,remove:a,get:async r=>{const s=await t(r);if(!s)return{state:"empty"};if("cached"!==s.state||s.createdAt+s.ttl>Date.now())return s;if(s.data.headers&&(n.ETag in s.data.headers||n.LastModified in s.data.headers||n.XAxiosCacheEtag in s.data.headers||n.XAxiosCacheStaleIfError in s.data.headers||n.XAxiosCacheLastModified in s.data.headers)){const t={state:"stale",createdAt:s.createdAt,data:s.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function y(){const e=S({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}const I=(e=>{var t={};return r.d(t,e),t})({code:()=>a.code}),x=/^\/|\/$/g;function b(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(x,"")),a.url&&(a.url=a.url.replace(x,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,I.code)(r).toString():r}}const C=b(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:s})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:s})));function A(e,t={}){var a,r,s,i,n;const d=e;if(d.storage=t.storage||y(),!v(d.storage))throw new Error("Use buildStorage() function");return d.generateKey=t.generateKey||C,d.waiting=t.waiting||{},d.headerInterpreter=t.headerInterpreter||o,d.requestInterceptor=t.requestInterceptor||h(d),d.responseInterceptor=t.responseInterceptor||w(d),d.debug=t.debug,d.defaults.cache={ttl:null!==(a=t.ttl)&&void 0!==a?a:3e5,interpretHeader:null!==(r=t.interpretHeader)&&void 0!==r&&r,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(s=t.etag)&&void 0!==s&&s,modifiedSince:null!==(i=t.modifiedSince)&&void 0!==i&&i,staleIfError:null!==(n=t.staleIfError)&&void 0!==n&&n,update:t.update||{}},d.requestInterceptor.apply(),d.responseInterceptor.apply(),d}function E(e,t=""){return S({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},set:(a,r)=>{e.setItem(t+a,JSON.stringify(r))},remove:a=>{e.removeItem(t+a)}})}var L=s.h4,T=s.UN,j=s.uu,M=s.Kd,O=s.ZF,N=s.p,K=s.E7,R=s.NQ,U=s.xK,X=s.G6,k=s.LN,D=s.Ad,P=s.$k,q=s.v8,H=s.Jk,F=s.tI,G=s.iS;export{L as Header,T as buildKeyGenerator,j as buildMemoryStorage,M as buildStorage,O as buildWebStorage,N as createCacheResponse,K as createValidateStatus,R as defaultHeaderInterpreter,U as defaultKeyGenerator,X as defaultRequestInterceptor,k as defaultResponseInterceptor,D as isMethodIn,P as isStorage,q as setupCache,H as testCachePredicate,F as updateCache,G as updateStaleRequest};
import*as e from"cache-parser";import*as t from"fast-defer";import*as a from"object-code";var r={d:(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},s={};r.d(s,{h4:()=>i,UN:()=>A,uu:()=>x,Kd:()=>S,ZF:()=>O,nv:()=>I,p:()=>h,E7:()=>c,NQ:()=>o,xK:()=>E,G6:()=>l,LN:()=>m,Bw:()=>y,Ad:()=>u,$k:()=>v,v8:()=>L,Jk:()=>g,tI:()=>p,iS:()=>f});const n=(e=>{var t={};return r.d(t,e),t})({parse:()=>e.parse}),i=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),o=e=>{if(!e)return"not enough headers";const t=e[i.CacheControl];if(t){const{noCache:a,noStore:r,mustRevalidate:s,maxAge:o,immutable:d}=(0,n.parse)(String(t));if(a||r)return"dont cache";if(d)return 31536e6;if(s)return 0;if(o){const t=e[i.Age];return t?1e3*(o-Number(t)):1e3*o}}const a=e[i.Expires];if(a){const e=Date.parse(String(a))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};const d=(e=>{var t={};return r.d(t,e),t})({deferred:()=>t.deferred});function c(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function u(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function f(e,t){var a;t.headers||(t.headers={});const{etag:r,modifiedSince:s}=t.cache;if(r){const s=!0===r?null===(a=e.data)||void 0===a?void 0:a.headers[i.ETag]:r;s&&(t.headers[i.IfNoneMatch]=s)}s&&(t.headers[i.IfModifiedSince]=!0===s?e.data.headers[i.LastModified]||new Date(e.createdAt).toUTCString():s.toUTCString())}function h(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function l(e){const t=async t=>{var a;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!u(t.method,t.cache.methods))return t;const r=t.id=e.generateKey(t);let s,n=await e.storage.get(r);e:if("empty"===n.state||"stale"===n.state){if(e.waiting[r]){n=await e.storage.get(r);break e}return e.waiting[r]=(0,d.deferred)(),null===(a=e.waiting[r])||void 0===a||a.catch((()=>{})),await e.storage.set(r,{state:"loading",previous:n.state,data:n.data,createdAt:n.createdAt}),"stale"===n.state&&f(n,t),t.validateStatus=c(t.validateStatus),t}if("loading"===n.state){const a=e.waiting[r];if(!a)return await e.storage.remove(r),t;0;try{s=await a}catch(e){return t}}else s=n.data;return t.adapter=()=>Promise.resolve({config:t,data:s.data,headers:s.headers,status:s.status,statusText:s.statusText,cached:!0,id:r}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function g(e,t){var a;if("function"==typeof t)return t(e);const{statusCheck:r,responseMatch:s,containsHeaders:n}=t;if(r&&!await r(e.status)||s&&!await s(e))return!1;if(n)for(const t in n){const r=n[t];if(r&&!await r(null!==(a=e.headers[t.toLowerCase()])&&void 0!==a?a:e.headers[t]))return!1}return!0}async function p(e,t,a){for(const r in a){const s=a[r];if("delete"===s){await e.remove(r);continue}const n=await e.get(r);if("loading"===n.state)continue;const i=await s(n,t);"delete"!==i?"ignore"!==i&&await e.set(r,i):await e.remove(r)}}function m(e){const t=async t=>{var a;await e.storage.remove(t),null===(a=e.waiting[t])||void 0===a||a.reject(null),delete e.waiting[t]},a=async a=>{var r,s,n;if(a.id=null!==(r=(n=a.config).id)&&void 0!==r?r:n.id=e.generateKey(a.config),null!==(s=a.cached)&&void 0!==s||(a.cached=!1),a.cached)return a;if(!a.config.cache)return Object.assign(Object.assign({},a),{cached:!1});const o=a.config.cache,d=await e.storage.get(a.id);if("stale"===d.state||"empty"===d.state||"cached"===d.state)return a;if(!d.data&&!await g(a,o.cachePredicate))return await t(a.id),a;for(const e in i)e.startsWith("XAxiosCache")&&delete a.headers[e];o.etag&&!0!==o.etag&&(a.headers[i.XAxiosCacheEtag]=o.etag),o.modifiedSince&&(a.headers[i.XAxiosCacheLastModified]=!0===o.modifiedSince?"use-cache-timestamp":o.modifiedSince.toUTCString());let c=o.ttl||-1;if(null==o?void 0:o.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),a;c="not enough headers"===r?c:r}const u=h(a,d.data);"function"==typeof c&&(c=await c(a)),o.staleIfError&&(a.headers[i.XAxiosCacheStaleIfError]=String(c)),(null==o?void 0:o.update)&&await p(e.storage,a,o.update);const f={state:"cached",ttl:c,createdAt:Date.now(),data:u},l=e.waiting[a.id];return l&&(l.resolve(f.data),delete e.waiting[a.id]),await e.storage.set(a.id,f),a},r=async a=>{var r;const s=a.config;if(!s||!1===s.cache||!s.id)throw a;const n=await e.storage.get(s.id),i=s.cache;if("loading"!==n.state||"stale"!==n.previous)throw await t(s.id),a;if(null==i?void 0:i.staleIfError){const t="function"==typeof i.staleIfError?await i.staleIfError(a.response,n,a):i.staleIfError;if(!0===t||"number"==typeof t&&n.createdAt+t>Date.now())return null===(r=e.waiting[s.id])||void 0===r||r.resolve(n.data),delete e.waiting[s.id],await e.storage.set(s.id,{state:"stale",createdAt:Date.now(),data:n.data}),{cached:!0,config:s,id:s.id,data:n.data.data,headers:n.data.headers,status:n.data.status,statusText:n.data.statusText}}throw a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const w=Symbol(),v=e=>!!e&&!!e[w];function I(e){const t=e.data.headers;return i.ETag in t||i.LastModified in t||i.XAxiosCacheEtag in t||i.XAxiosCacheStaleIfError in t||i.XAxiosCacheLastModified in t}function y(e){return e.createdAt+e.ttl<=Date.now()}function S({set:e,find:t,remove:a}){return{[w]:1,set:e,remove:a,get:async r=>{const s=await t(r);if(!s)return{state:"empty"};if("cached"!==s.state||!y(s))return s;if(I(s)){const t={state:"stale",createdAt:s.createdAt,data:s.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function x(){const e=S({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}const C=(e=>{var t={};return r.d(t,e),t})({hashCode:()=>a.hashCode}),b=/^\/|\/$/g;function A(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(b,"")),a.url&&(a.url=a.url.replace(b,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,C.hashCode)(r).toString():r}}const E=A(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:s})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:s})));function L(e,t={}){var a,r,s,n,i;const d=e;if(d.storage=t.storage||x(),!v(d.storage))throw new Error("Use buildStorage() function");return d.generateKey=t.generateKey||E,d.waiting=t.waiting||{},d.headerInterpreter=t.headerInterpreter||o,d.requestInterceptor=t.requestInterceptor||l(d),d.responseInterceptor=t.responseInterceptor||m(d),d.debug=t.debug,d.defaults.cache={ttl:null!==(a=t.ttl)&&void 0!==a?a:3e5,interpretHeader:null!==(r=t.interpretHeader)&&void 0!==r&&r,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(s=t.etag)&&void 0!==s&&s,modifiedSince:null!==(n=t.modifiedSince)&&void 0!==n&&n,staleIfError:null!==(i=t.staleIfError)&&void 0!==i&&i,update:t.update||{}},d.requestInterceptor.apply(),d.responseInterceptor.apply(),d}function O(e,t=""){return S({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},remove:a=>{e.removeItem(t+a)},set:(a,r)=>{const s=()=>e.setItem(t+a,JSON.stringify(r));try{return s()}catch(r){const n=Object.entries(e).filter((([a])=>a.startsWith(t)&&e.getItem(a))).map((([e,t])=>[e,JSON.parse(t)]));for(const[t,a]of n)"cached"===a.state&&y(a)&&!I(a)&&e.removeItem(t);try{return s()}catch(t){const a=n.sort((([,e],[,t])=>(e.createdAt||0)-(t.createdAt||0)));for(const[t]of a){e.removeItem(t);try{return s()}catch(e){}}}e.removeItem(t+a)}}})}var j=s.h4,T=s.UN,M=s.uu,N=s.Kd,K=s.ZF,R=s.nv,U=s.p,X=s.E7,k=s.NQ,D=s.xK,P=s.G6,q=s.LN,H=s.Bw,J=s.Ad,F=s.$k,G=s.v8,W=s.Jk,$=s.tI,B=s.iS;export{j as Header,T as buildKeyGenerator,M as buildMemoryStorage,N as buildStorage,K as buildWebStorage,R as canStale,U as createCacheResponse,X as createValidateStatus,k as defaultHeaderInterpreter,D as defaultKeyGenerator,P as defaultRequestInterceptor,q as defaultResponseInterceptor,H as isExpired,J as isMethodIn,F as isStorage,G as setupCache,W as testCachePredicate,$ as updateCache,B as updateStaleRequest};
{
"name": "axios-cache-interceptor",
"version": "0.8.10",
"version": "0.9.0",
"description": "Cache interceptor for axios",

@@ -52,3 +52,3 @@ "main": "./cjs/index.js",

"fast-defer": "^1.1.3",
"object-code": "^1.0.1"
"object-code": "^1.1.2"
},

@@ -55,0 +55,0 @@ "resolutions": {

import { Header } from '../header/headers';
import type { MaybePromise } from '../util/types';
import type { AxiosStorage, StaleStorageValue, StorageValue } from './types';
import type {
AxiosStorage,
CachedStorageValue,
StaleStorageValue,
StorageValue
} from './types';

@@ -11,6 +16,23 @@ const storage = Symbol();

/** Returns true if this storage is expired, but it has sufficient properties to stale. */
export function canStale(value: CachedStorageValue): boolean {
const headers = value.data.headers;
return (
Header.ETag in headers ||
Header.LastModified in headers ||
Header.XAxiosCacheEtag in headers ||
Header.XAxiosCacheStaleIfError in headers ||
Header.XAxiosCacheLastModified in headers
);
}
/** Checks if the provided cache is expired. You should also check if the cache {@link canStale} */
export function isExpired(value: CachedStorageValue): boolean {
return value.createdAt + value.ttl <= Date.now();
}
export type BuildStorage = Omit<AxiosStorage, 'get'> & {
/**
* Returns the value for the given key. This method does not have to make checks for
* cache invalidation or etc. It just return what was previous saved, if present.
* cache invalidation or anything. It just returns what was previous saved, if present.
*/

@@ -53,3 +75,3 @@ find: (key: string) => MaybePromise<StorageValue | undefined>;

value.state !== 'cached' ||
value.createdAt + value.ttl > Date.now()
!isExpired(value)
) {

@@ -59,11 +81,3 @@ return value;

if (
value.data.headers &&
// Any header below allows the response to stale
(Header.ETag in value.data.headers ||
Header.LastModified in value.data.headers ||
Header.XAxiosCacheEtag in value.data.headers ||
Header.XAxiosCacheStaleIfError in value.data.headers ||
Header.XAxiosCacheLastModified in value.data.headers)
) {
if (canStale(value)) {
const stale: StaleStorageValue = {

@@ -74,2 +88,3 @@ state: 'stale',

};
await set(key, stale);

@@ -76,0 +91,0 @@ return stale;

@@ -1,3 +0,3 @@

import type { StorageValue } from '..';
import { buildStorage } from './build';
import { buildStorage, canStale, isExpired } from './build';
import type { StorageValue } from './types';

@@ -20,2 +20,3 @@ /**

*
* @param storage The type of web storage to use. localStorage or sessionStorage.
* @param prefix The prefix to index the storage. Useful to prevent collision between

@@ -30,9 +31,53 @@ * multiple places using the same storage.

},
set: (key, value) => {
storage.setItem(prefix + key, JSON.stringify(value));
},
remove: (key) => {
storage.removeItem(prefix + key);
},
set: (key, value) => {
const save = () => storage.setItem(prefix + key, JSON.stringify(value));
try {
return save();
} catch (error) {
const allValues: [string, StorageValue][] = Object.entries(
storage as Record<string, string>
)
.filter(([key]) => key.startsWith(prefix) && storage.getItem(key))
.map(([key, val]) => [key, JSON.parse(val) as StorageValue]);
// Remove all expired values
for (const [prefixedKey, value] of allValues) {
if (value.state === 'cached' && isExpired(value) && !canStale(value)) {
storage.removeItem(prefixedKey);
}
}
// Try save again after removing expired values
try {
return save();
} catch (_) {
// Storage still full, try removing the oldest value until it can be saved
// Descending sort by createdAt
const sortedItems = allValues.sort(
([, valueA], [, valueB]) => (valueA.createdAt || 0) - (valueB.createdAt || 0)
);
for (const [prefixedKey] of sortedItems) {
storage.removeItem(prefixedKey);
try {
return save();
} catch (_) {
// This key didn't free all the required space
}
}
}
// Clear the cache for the specified key
storage.removeItem(prefix + key);
}
}
});
}
import type { Method } from 'axios';
import { code } from 'object-code';
import { hashCode } from 'object-code';
import type { CacheRequestConfig } from '../cache/axios';

@@ -56,3 +56,3 @@ import type { KeyGenerator } from './types';

const result = generator(request) as string;
return hash ? code(result).toString() : result;
return hash ? hashCode(result).toString() : result;
};

@@ -59,0 +59,0 @@ }

import type { MaybePromise } from '../util/types';
import type { AxiosStorage, StorageValue } from './types';
import type { AxiosStorage, CachedStorageValue, StorageValue } from './types';
/** Returns true if the provided object was created from {@link buildStorage} function. */
export declare const isStorage: (obj: unknown) => obj is AxiosStorage;
/** Returns true if this storage is expired, but it has sufficient properties to stale. */
export declare function canStale(value: CachedStorageValue): boolean;
/** Checks if the provided cache is expired. You should also check if the cache {@link canStale} */
export declare function isExpired(value: CachedStorageValue): boolean;
export declare type BuildStorage = Omit<AxiosStorage, 'get'> & {
/**
* Returns the value for the given key. This method does not have to make checks for
* cache invalidation or etc. It just return what was previous saved, if present.
* cache invalidation or anything. It just returns what was previous saved, if present.
*/

@@ -10,0 +14,0 @@ find: (key: string) => MaybePromise<StorageValue | undefined>;

@@ -17,2 +17,3 @@ /**

*
* @param storage The type of web storage to use. localStorage or sessionStorage.
* @param prefix The prefix to index the storage. Useful to prevent collision between

@@ -19,0 +20,0 @@ * multiple places using the same storage.

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}("undefined"!=typeof self?self:this,(function(){return(()=>{var e={549:(e,t)=>{var a,r;a=t,r=Symbol("fast-defer"),a.deferred=function(){var e,t,a=new Promise((function(a,r){e=a,t=r}));return a.resolve=e,a.reject=t,a[r]=1,a},a.isDeferred=function(e){return!!e&&!!e[r]}},246:(e,t)=>{var a;(a=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var r=Array.isArray(e)?[]:{};for(var n in e)r[n]=a.transform(e[n]);return"#"+String(e.constructor)+JSON.stringify(r,Object.keys(r).sort())}return t+String(e)+("symbol"===t?Math.random():"")},a.code=function(e){e=a.transform(e);for(var t=7,r=0;r<e.length;)t=31*t+e.charCodeAt(r++)&9007199254740991;return t}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,a),o.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";a.r(r),a.d(r,{Header:()=>o,buildKeyGenerator:()=>S,buildMemoryStorage:()=>y,buildStorage:()=>w,buildWebStorage:()=>A,createCacheResponse:()=>f,createValidateStatus:()=>d,defaultHeaderInterpreter:()=>s,defaultKeyGenerator:()=>C,defaultRequestInterceptor:()=>g,defaultResponseInterceptor:()=>p,isMethodIn:()=>c,isStorage:()=>b,setupCache:()=>I,testCachePredicate:()=>h,updateCache:()=>l,updateStaleRequest:()=>u});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}const o=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),s=a=>{if(!a)return"not enough headers";const r=a[o.CacheControl];if(r){const{noCache:s,noStore:i,mustRevalidate:d,maxAge:c,immutable:u}=function(a){var r=Object.defineProperty({},e,{enumerable:!1,value:1});if(!a||"string"!=typeof a)return r;var o=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),a={};for(var r in t){var n=t[r].split("=",2);a[n[0]]=1===n.length||n[1]}return a}(a);return n(o.immutable)&&(r.immutable=!0),t(o["max-age"])&&(r.maxAge=Number(o["max-age"])),t(o["max-stale"])&&(r.maxStale=Number(o["max-stale"])),t(o["min-fresh"])&&(r.minFresh=Number(o["min-fresh"])),n(o["must-revalidate"])&&(r.mustRevalidate=!0),n(o["must-understand"])&&(r.mustUnderstand=!0),n(o["no-cache"])&&(r.noCache=!0),n(o["no-store"])&&(r.noStore=!0),n(o["no-transform"])&&(r.noTransform=!0),n(o["only-if-cached"])&&(r.onlyIfCached=!0),n(o.private)&&(r.private=!0),n(o["proxy-revalidate"])&&(r.proxyRevalidate=!0),n(o.public)&&(r.public=!0),t(o["s-maxage"])&&(r.sMaxAge=Number(o["s-maxage"])),t(o["stale-if-error"])&&(r.staleIfError=Number(o["stale-if-error"])),t(o["stale-while-revalidate"])&&(r.staleWhileRevalidate=Number(o["stale-while-revalidate"])),r}(String(r));if(s||i)return"dont cache";if(u)return 31536e6;if(d)return 0;if(c){const e=a[o.Age];return e?1e3*(c-Number(e)):1e3*c}}const s=a[o.Expires];if(s){const e=Date.parse(String(s))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};var i=a(549);function d(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function c(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function u(e,t){t.headers||(t.headers={});const{etag:a,modifiedSince:r}=t.cache;if(a){const r=!0===a?e.data?.headers[o.ETag]:a;r&&(t.headers[o.IfNoneMatch]=r)}r&&(t.headers[o.IfModifiedSince]=!0===r?e.data.headers[o.LastModified]||new Date(e.createdAt).toUTCString():r.toUTCString())}function f(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers={...t.headers,...e.headers},t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function g(e){const t=async t=>{if(!1===t.cache)return e.debug?.({msg:"Ignoring cache because config.cache is false",data:t}),t;if(t.cache={...e.defaults.cache,...t.cache},!c(t.method,t.cache.methods))return e.debug?.({msg:`Ignored because method (${t.method}) is not in cache.methods (${t.cache.methods})`}),t;const a=t.id=e.generateKey(t);let r,n=await e.storage.get(a);e:if("empty"===n.state||"stale"===n.state){if(e.waiting[a]){n=await e.storage.get(a),e.debug?.({id:a,msg:"Waiting list had an deferred for this key, waiting for it to finish"});break e}return e.waiting[a]=(0,i.deferred)(),e.waiting[a]?.catch((()=>{})),await e.storage.set(a,{state:"loading",previous:n.state,data:n.data,createdAt:n.createdAt}),"stale"===n.state&&(u(n,t),e.debug?.({id:a,msg:"Updated stale request"})),t.validateStatus=d(t.validateStatus),e.debug?.({id:a,msg:"Sending request, waiting for response"}),t}if("loading"===n.state){const n=e.waiting[a];if(!n)return await e.storage.remove(a),t;e.debug?.({id:a,msg:"Detected concurrent request, waiting for it to finish"});try{r=await n}catch(r){return e.debug?.({id:a,msg:"Deferred rejected, requesting again",data:r}),t}}else r=n.data;return t.adapter=()=>Promise.resolve({config:t,data:r.data,headers:r.headers,status:r.status,statusText:r.statusText,cached:!0,id:a}),e.debug?.({id:a,msg:"Returning cached response"}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function h(e,t){if("function"==typeof t)return t(e);const{statusCheck:a,responseMatch:r,containsHeaders:n}=t;if(a&&!await a(e.status)||r&&!await r(e))return!1;if(n)for(const t in n){const a=n[t];if(a&&!await a(e.headers[t.toLowerCase()]??e.headers[t]))return!1}return!0}async function l(e,t,a){for(const r in a){const n=a[r];if("delete"===n){await e.remove(r);continue}const o=await e.get(r);if("loading"===o.state)continue;const s=await n(o,t);"delete"!==s?"ignore"!==s&&await e.set(r,s):await e.remove(r)}}function p(e){const t=async t=>{await e.storage.remove(t),e.waiting[t]?.reject(null),delete e.waiting[t]},a=async a=>{var r;if(a.id=(r=a.config).id??(r.id=e.generateKey(a.config)),a.cached??(a.cached=!1),a.cached)return e.debug?.({id:a.id,msg:"Returned cached response"}),a;if(!a.config.cache)return e.debug?.({id:a.id,msg:"Response with config.cache === false",data:a}),{...a,cached:!1};const n=a.config.cache,s=await e.storage.get(a.id);if("stale"===s.state||"empty"===s.state||"cached"===s.state)return e.debug?.({id:a.id,msg:"Response not cached but storage is not loading",data:{cache:s,response:a}}),a;if(!s.data&&!await h(a,n.cachePredicate))return await t(a.id),e.debug?.({id:a.id,msg:"Cache predicate rejected this response"}),a;for(const e in o)e.startsWith("XAxiosCache")&&delete a.headers[e];n.etag&&!0!==n.etag&&(a.headers[o.XAxiosCacheEtag]=n.etag),n.modifiedSince&&(a.headers[o.XAxiosCacheLastModified]=!0===n.modifiedSince?"use-cache-timestamp":n.modifiedSince.toUTCString());let i=n.ttl||-1;if(n?.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),e.debug?.({id:a.id,msg:"Cache header interpreted as 'dont cache'",data:{cache:s,response:a,expirationTime:r}}),a;i="not enough headers"===r?i:r}const d=f(a,s.data);"function"==typeof i&&(i=await i(a)),n.staleIfError&&(a.headers[o.XAxiosCacheStaleIfError]=String(i)),e.debug?.({id:a.id,msg:"Useful response configuration found",data:{cacheConfig:n,ttl:i,cacheResponse:d}}),n?.update&&await l(e.storage,a,n.update);const c={state:"cached",ttl:i,createdAt:Date.now(),data:d},u=e.waiting[a.id];return u&&(u.resolve(c.data),delete e.waiting[a.id],e.debug?.({id:a.id,msg:"Found waiting deferred(s) and resolved them"})),await e.storage.set(a.id,c),e.debug?.({id:a.id,msg:"Response cached",data:{cache:c,response:a}}),a},r=async a=>{const r=a.config;if(!r||!1===r.cache||!r.id)throw e.debug?.({msg:"Web request returned an error but cache handling is not enabled",data:{error:a,config:r}}),a;const n=await e.storage.get(r.id),o=r.cache;if("loading"!==n.state||"stale"!==n.previous)throw await t(r.id),e.debug?.({msg:"Caught an error in the request interceptor",data:{error:a,config:r}}),a;if(o?.staleIfError){const t="function"==typeof o.staleIfError?await o.staleIfError(a.response,n,a):o.staleIfError;if(e.debug?.({msg:"Found cache if stale config for rejected response",data:{error:a,config:r,staleIfError:t}}),!0===t||"number"==typeof t&&n.createdAt+t>Date.now())return e.waiting[r.id]?.resolve(n.data),delete e.waiting[r.id],await e.storage.set(r.id,{state:"stale",createdAt:Date.now(),data:n.data}),e.debug?.({msg:"staleIfError resolved this response with cached data",data:{error:a,config:r,cache:n}}),{cached:!0,config:r,id:r.id,data:n.data.data,headers:n.data.headers,status:n.data.status,statusText:n.data.statusText}}throw e.debug?.({msg:"Received an unknown error that could not be handled",data:{error:a,config:r}}),a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const m=Symbol(),b=e=>!!e&&!!e[m];function w({set:e,find:t,remove:a}){return{[m]:1,set:e,remove:a,get:async r=>{const n=await t(r);if(!n)return{state:"empty"};if("cached"!==n.state||n.createdAt+n.ttl>Date.now())return n;if(n.data.headers&&(o.ETag in n.data.headers||o.LastModified in n.data.headers||o.XAxiosCacheEtag in n.data.headers||o.XAxiosCacheStaleIfError in n.data.headers||o.XAxiosCacheLastModified in n.data.headers)){const t={state:"stale",createdAt:n.createdAt,data:n.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function y(){const e=w({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}var v=a(246);const x=/^\/|\/$/g;function S(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(x,"")),a.url&&(a.url=a.url.replace(x,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,v.code)(r).toString():r}}const C=S(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:n})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:n})));function I(e,t={}){const a=e;if(a.storage=t.storage||y(),!b(a.storage))throw new Error("Use buildStorage() function");return a.generateKey=t.generateKey||C,a.waiting=t.waiting||{},a.headerInterpreter=t.headerInterpreter||s,a.requestInterceptor=t.requestInterceptor||g(a),a.responseInterceptor=t.responseInterceptor||p(a),a.debug=t.debug,a.defaults.cache={ttl:t.ttl??3e5,interpretHeader:t.interpretHeader??!1,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:t.etag??!1,modifiedSince:t.modifiedSince??!1,staleIfError:t.staleIfError??!1,update:t.update||{}},a.requestInterceptor.apply(),a.responseInterceptor.apply(),a}function A(e,t=""){return w({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},set:(a,r)=>{e.setItem(t+a,JSON.stringify(r))},remove:a=>{e.removeItem(t+a)}})}console.error("You are using a development build. Make sure to use the correct build in production"),console.error("https://axios-cache-interceptor.js.org/#/pages/installing")})(),r})()}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}("undefined"!=typeof self?self:this,(function(){return(()=>{var e={549:(e,t)=>{var a,r;a=t,r=Symbol("fast-defer"),a.deferred=function(){var e,t,a=new Promise((function(a,r){e=a,t=r}));return a.resolve=e,a.reject=t,a[r]=1,a},a.isDeferred=function(e){return!!e&&!!e[r]}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,a),o.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";a.r(r),a.d(r,{Header:()=>o,buildKeyGenerator:()=>A,buildMemoryStorage:()=>x,buildStorage:()=>v,buildWebStorage:()=>j,canStale:()=>w,createCacheResponse:()=>f,createValidateStatus:()=>d,defaultHeaderInterpreter:()=>s,defaultKeyGenerator:()=>E,defaultRequestInterceptor:()=>g,defaultResponseInterceptor:()=>p,isExpired:()=>y,isMethodIn:()=>c,isStorage:()=>b,setupCache:()=>R,testCachePredicate:()=>h,updateCache:()=>l,updateStaleRequest:()=>u});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}const o=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),s=a=>{if(!a)return"not enough headers";const r=a[o.CacheControl];if(r){const{noCache:s,noStore:i,mustRevalidate:d,maxAge:c,immutable:u}=function(a){var r=Object.defineProperty({},e,{enumerable:!1,value:1});if(!a||"string"!=typeof a)return r;var o=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),a={};for(var r in t){var n=t[r].split("=",2);a[n[0]]=1===n.length||n[1]}return a}(a);return n(o.immutable)&&(r.immutable=!0),t(o["max-age"])&&(r.maxAge=Number(o["max-age"])),t(o["max-stale"])&&(r.maxStale=Number(o["max-stale"])),t(o["min-fresh"])&&(r.minFresh=Number(o["min-fresh"])),n(o["must-revalidate"])&&(r.mustRevalidate=!0),n(o["must-understand"])&&(r.mustUnderstand=!0),n(o["no-cache"])&&(r.noCache=!0),n(o["no-store"])&&(r.noStore=!0),n(o["no-transform"])&&(r.noTransform=!0),n(o["only-if-cached"])&&(r.onlyIfCached=!0),n(o.private)&&(r.private=!0),n(o["proxy-revalidate"])&&(r.proxyRevalidate=!0),n(o.public)&&(r.public=!0),t(o["s-maxage"])&&(r.sMaxAge=Number(o["s-maxage"])),t(o["stale-if-error"])&&(r.staleIfError=Number(o["stale-if-error"])),t(o["stale-while-revalidate"])&&(r.staleWhileRevalidate=Number(o["stale-while-revalidate"])),r}(String(r));if(s||i)return"dont cache";if(u)return 31536e6;if(d)return 0;if(c){const e=a[o.Age];return e?1e3*(c-Number(e)):1e3*c}}const s=a[o.Expires];if(s){const e=Date.parse(String(s))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};var i=a(549);function d(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function c(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function u(e,t){t.headers||(t.headers={});const{etag:a,modifiedSince:r}=t.cache;if(a){const r=!0===a?e.data?.headers[o.ETag]:a;r&&(t.headers[o.IfNoneMatch]=r)}r&&(t.headers[o.IfModifiedSince]=!0===r?e.data.headers[o.LastModified]||new Date(e.createdAt).toUTCString():r.toUTCString())}function f(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers={...t.headers,...e.headers},t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function g(e){const t=async t=>{if(!1===t.cache)return e.debug?.({msg:"Ignoring cache because config.cache is false",data:t}),t;if(t.cache={...e.defaults.cache,...t.cache},!c(t.method,t.cache.methods))return e.debug?.({msg:`Ignored because method (${t.method}) is not in cache.methods (${t.cache.methods})`}),t;const a=t.id=e.generateKey(t);let r,n=await e.storage.get(a);e:if("empty"===n.state||"stale"===n.state){if(e.waiting[a]){n=await e.storage.get(a),e.debug?.({id:a,msg:"Waiting list had an deferred for this key, waiting for it to finish"});break e}return e.waiting[a]=(0,i.deferred)(),e.waiting[a]?.catch((()=>{})),await e.storage.set(a,{state:"loading",previous:n.state,data:n.data,createdAt:n.createdAt}),"stale"===n.state&&(u(n,t),e.debug?.({id:a,msg:"Updated stale request"})),t.validateStatus=d(t.validateStatus),e.debug?.({id:a,msg:"Sending request, waiting for response"}),t}if("loading"===n.state){const n=e.waiting[a];if(!n)return await e.storage.remove(a),t;e.debug?.({id:a,msg:"Detected concurrent request, waiting for it to finish"});try{r=await n}catch(r){return e.debug?.({id:a,msg:"Deferred rejected, requesting again",data:r}),t}}else r=n.data;return t.adapter=()=>Promise.resolve({config:t,data:r.data,headers:r.headers,status:r.status,statusText:r.statusText,cached:!0,id:a}),e.debug?.({id:a,msg:"Returning cached response"}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function h(e,t){if("function"==typeof t)return t(e);const{statusCheck:a,responseMatch:r,containsHeaders:n}=t;if(a&&!await a(e.status)||r&&!await r(e))return!1;if(n)for(const t in n){const a=n[t];if(a&&!await a(e.headers[t.toLowerCase()]??e.headers[t]))return!1}return!0}async function l(e,t,a){for(const r in a){const n=a[r];if("delete"===n){await e.remove(r);continue}const o=await e.get(r);if("loading"===o.state)continue;const s=await n(o,t);"delete"!==s?"ignore"!==s&&await e.set(r,s):await e.remove(r)}}function p(e){const t=async t=>{await e.storage.remove(t),e.waiting[t]?.reject(null),delete e.waiting[t]},a=async a=>{var r;if(a.id=(r=a.config).id??(r.id=e.generateKey(a.config)),a.cached??(a.cached=!1),a.cached)return e.debug?.({id:a.id,msg:"Returned cached response"}),a;if(!a.config.cache)return e.debug?.({id:a.id,msg:"Response with config.cache === false",data:a}),{...a,cached:!1};const n=a.config.cache,s=await e.storage.get(a.id);if("stale"===s.state||"empty"===s.state||"cached"===s.state)return e.debug?.({id:a.id,msg:"Response not cached but storage is not loading",data:{cache:s,response:a}}),a;if(!s.data&&!await h(a,n.cachePredicate))return await t(a.id),e.debug?.({id:a.id,msg:"Cache predicate rejected this response"}),a;for(const e in o)e.startsWith("XAxiosCache")&&delete a.headers[e];n.etag&&!0!==n.etag&&(a.headers[o.XAxiosCacheEtag]=n.etag),n.modifiedSince&&(a.headers[o.XAxiosCacheLastModified]=!0===n.modifiedSince?"use-cache-timestamp":n.modifiedSince.toUTCString());let i=n.ttl||-1;if(n?.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),e.debug?.({id:a.id,msg:"Cache header interpreted as 'dont cache'",data:{cache:s,response:a,expirationTime:r}}),a;i="not enough headers"===r?i:r}const d=f(a,s.data);"function"==typeof i&&(i=await i(a)),n.staleIfError&&(a.headers[o.XAxiosCacheStaleIfError]=String(i)),e.debug?.({id:a.id,msg:"Useful response configuration found",data:{cacheConfig:n,ttl:i,cacheResponse:d}}),n?.update&&await l(e.storage,a,n.update);const c={state:"cached",ttl:i,createdAt:Date.now(),data:d},u=e.waiting[a.id];return u&&(u.resolve(c.data),delete e.waiting[a.id],e.debug?.({id:a.id,msg:"Found waiting deferred(s) and resolved them"})),await e.storage.set(a.id,c),e.debug?.({id:a.id,msg:"Response cached",data:{cache:c,response:a}}),a},r=async a=>{const r=a.config;if(!r||!1===r.cache||!r.id)throw e.debug?.({msg:"Web request returned an error but cache handling is not enabled",data:{error:a,config:r}}),a;const n=await e.storage.get(r.id),o=r.cache;if("loading"!==n.state||"stale"!==n.previous)throw await t(r.id),e.debug?.({msg:"Caught an error in the request interceptor",data:{error:a,config:r}}),a;if(o?.staleIfError){const t="function"==typeof o.staleIfError?await o.staleIfError(a.response,n,a):o.staleIfError;if(e.debug?.({msg:"Found cache if stale config for rejected response",data:{error:a,config:r,staleIfError:t}}),!0===t||"number"==typeof t&&n.createdAt+t>Date.now())return e.waiting[r.id]?.resolve(n.data),delete e.waiting[r.id],await e.storage.set(r.id,{state:"stale",createdAt:Date.now(),data:n.data}),e.debug?.({msg:"staleIfError resolved this response with cached data",data:{error:a,config:r,cache:n}}),{cached:!0,config:r,id:r.id,data:n.data.data,headers:n.data.headers,status:n.data.status,statusText:n.data.statusText}}throw e.debug?.({msg:"Received an unknown error that could not be handled",data:{error:a,config:r}}),a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const m=Symbol(),b=e=>!!e&&!!e[m];function w(e){const t=e.data.headers;return o.ETag in t||o.LastModified in t||o.XAxiosCacheEtag in t||o.XAxiosCacheStaleIfError in t||o.XAxiosCacheLastModified in t}function y(e){return e.createdAt+e.ttl<=Date.now()}function v({set:e,find:t,remove:a}){return{[m]:1,set:e,remove:a,get:async r=>{const n=await t(r);if(!n)return{state:"empty"};if("cached"!==n.state||!y(n))return n;if(w(n)){const t={state:"stale",createdAt:n.createdAt,data:n.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function x(){const e=v({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}function S(e){const t=typeof e;if(e&&"object"===t&&!(e instanceof Date||e instanceof RegExp)){const t=Array.isArray(e)?[]:{};for(const a in e)t[a]=S(e[a]);return`${e.constructor}${JSON.stringify(t,Object.keys(e).sort())}`}return`${t}${String(e)}`}function I(e){e=S(e);let t=5381;for(let a=0;a<e.length;a++)t=33*t^e.charCodeAt(a);return t>>>0}const C=/^\/|\/$/g;function A(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(C,"")),a.url&&(a.url=a.url.replace(C,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?I(r).toString():r}}const E=A(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:n})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:n})));function R(e,t={}){const a=e;if(a.storage=t.storage||x(),!b(a.storage))throw new Error("Use buildStorage() function");return a.generateKey=t.generateKey||E,a.waiting=t.waiting||{},a.headerInterpreter=t.headerInterpreter||s,a.requestInterceptor=t.requestInterceptor||g(a),a.responseInterceptor=t.responseInterceptor||p(a),a.debug=t.debug,a.defaults.cache={ttl:t.ttl??3e5,interpretHeader:t.interpretHeader??!1,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:t.etag??!1,modifiedSince:t.modifiedSince??!1,staleIfError:t.staleIfError??!1,update:t.update||{}},a.requestInterceptor.apply(),a.responseInterceptor.apply(),a}function j(e,t=""){return v({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},remove:a=>{e.removeItem(t+a)},set:(a,r)=>{const n=()=>e.setItem(t+a,JSON.stringify(r));try{return n()}catch(r){const o=Object.entries(e).filter((([a])=>a.startsWith(t)&&e.getItem(a))).map((([e,t])=>[e,JSON.parse(t)]));for(const[t,a]of o)"cached"===a.state&&y(a)&&!w(a)&&e.removeItem(t);try{return n()}catch(t){const a=o.sort((([,e],[,t])=>(e.createdAt||0)-(t.createdAt||0)));for(const[t]of a){e.removeItem(t);try{return n()}catch(e){}}}e.removeItem(t+a)}}})}console.error("You are using a development build. Make sure to use the correct build in production"),console.error("https://axios-cache-interceptor.js.org/#/pages/installing")})(),r})()}));
//# sourceMappingURL=dev.map

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}("undefined"!=typeof self?self:this,(function(){return function(){var e={549:function(e,t){var r,a;r=t,a=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise((function(r,a){e=r,t=a}));return r.resolve=e,r.reject=t,r[a]=1,r},r.isDeferred=function(e){return!!e&&!!e[a]}},246:function(e,t){var r;(r=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var a=Array.isArray(e)?[]:{};for(var n in e)a[n]=r.transform(e[n]);return"#"+String(e.constructor)+JSON.stringify(a,Object.keys(a).sort())}return t+String(e)+("symbol"===t?Math.random():"")},r.code=function(e){e=r.transform(e);for(var t=7,a=0;a<e.length;)t=31*t+e.charCodeAt(a++)&9007199254740991;return t}}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,r),o.exports}r.d=function(e,t){for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){"use strict";r.r(a),r.d(a,{Header:function(){return o},buildKeyGenerator:function(){return A},buildMemoryStorage:function(){return S},buildStorage:function(){return w},buildWebStorage:function(){return T},createCacheResponse:function(){return v},createValidateStatus:function(){return f},defaultHeaderInterpreter:function(){return i},defaultKeyGenerator:function(){return E},defaultRequestInterceptor:function(){return p},defaultResponseInterceptor:function(){return b},isMethodIn:function(){return l},isStorage:function(){return x},setupCache:function(){return j},testCachePredicate:function(){return g},updateCache:function(){return m},updateStaleRequest:function(){return h}});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}var o=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),i=function(r){if(!r)return"not enough headers";var a=r[o.CacheControl];if(a){var i=function(r){var a=Object.defineProperty({},e,{enumerable:!1,value:1});if(!r||"string"!=typeof r)return a;var o=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),r={};for(var a in t){var n=t[a].split("=",2);r[n[0]]=1===n.length||n[1]}return r}(r);return n(o.immutable)&&(a.immutable=!0),t(o["max-age"])&&(a.maxAge=Number(o["max-age"])),t(o["max-stale"])&&(a.maxStale=Number(o["max-stale"])),t(o["min-fresh"])&&(a.minFresh=Number(o["min-fresh"])),n(o["must-revalidate"])&&(a.mustRevalidate=!0),n(o["must-understand"])&&(a.mustUnderstand=!0),n(o["no-cache"])&&(a.noCache=!0),n(o["no-store"])&&(a.noStore=!0),n(o["no-transform"])&&(a.noTransform=!0),n(o["only-if-cached"])&&(a.onlyIfCached=!0),n(o.private)&&(a.private=!0),n(o["proxy-revalidate"])&&(a.proxyRevalidate=!0),n(o.public)&&(a.public=!0),t(o["s-maxage"])&&(a.sMaxAge=Number(o["s-maxage"])),t(o["stale-if-error"])&&(a.staleIfError=Number(o["stale-if-error"])),t(o["stale-while-revalidate"])&&(a.staleWhileRevalidate=Number(o["stale-while-revalidate"])),a}(String(a)),s=i.noCache,c=i.noStore,u=i.mustRevalidate,d=i.maxAge,f=i.immutable;if(s||c)return"dont cache";if(f)return 31536e6;if(u)return 0;if(d){var l=r[o.Age];return l?1e3*(d-Number(l)):1e3*d}}var h=r[o.Expires];if(h){var v=Date.parse(String(h))-Date.now();return v>=0?v:"dont cache"}return"not enough headers"};var s=function(){return s=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},s.apply(this,arguments)};function c(e,t,r,a){return new(r||(r=Promise))((function(n,o){function i(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((a=a.apply(e,t||[])).next())}))}function u(e,t){var r,a,n,o,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}Object.create;Object.create;var d=r(549);function f(e){return e?function(t){return e(t)||304===t}:function(e){return e>=200&&e<300||304===e}}function l(e,t){void 0===e&&(e="get"),void 0===t&&(t=[]),e=e.toLowerCase();for(var r=0,a=t;r<a.length;r++){if(a[r].toLowerCase()===e)return!0}return!1}function h(e,t){var r;t.headers||(t.headers={});var a=t.cache,n=a.etag,i=a.modifiedSince;if(n){var s=!0===n?null===(r=e.data)||void 0===r?void 0:r.headers[o.ETag]:n;s&&(t.headers[o.IfNoneMatch]=s)}i&&(t.headers[o.IfModifiedSince]=!0===i?e.data.headers[o.LastModified]||new Date(e.createdAt).toUTCString():i.toUTCString())}function v(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=s(s({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function p(e){var t=this,r=function(r){return c(t,void 0,void 0,(function(){var t,a,n,o,i;return u(this,(function(c){switch(c.label){case 0:return!1===r.cache?[2,r]:(r.cache=s(s({},e.defaults.cache),r.cache),l(r.method,r.cache.methods)?(t=r.id=e.generateKey(r),[4,e.storage.get(t)]):[2,r]);case 1:return"empty"!==(a=c.sent()).state&&"stale"!==a.state?[3,5]:e.waiting[t]?[4,e.storage.get(t)]:[3,3];case 2:return a=c.sent(),[3,5];case 3:return e.waiting[t]=(0,d.deferred)(),null===(i=e.waiting[t])||void 0===i||i.catch((function(){})),[4,e.storage.set(t,{state:"loading",previous:a.state,data:a.data,createdAt:a.createdAt})];case 4:return c.sent(),"stale"===a.state&&h(a,r),r.validateStatus=f(r.validateStatus),[2,r];case 5:return"loading"!==a.state?[3,12]:(o=e.waiting[t])?[3,7]:[4,e.storage.remove(t)];case 6:return c.sent(),[2,r];case 7:0,c.label=8;case 8:return c.trys.push([8,10,,11]),[4,o];case 9:return n=c.sent(),[3,11];case 10:return c.sent(),[2,r];case 11:return[3,13];case 12:n=a.data,c.label=13;case 13:return r.adapter=function(){return Promise.resolve({config:r,data:n.data,headers:n.headers,status:n.status,statusText:n.statusText,cached:!0,id:t})},[2,r]}}))}))};return{onFulfilled:r,apply:function(){return e.interceptors.request.use(r)}}}function g(e,t){var r;return c(this,void 0,void 0,(function(){var a,n,o,i,s,c,d,f,l,h,v,p;return u(this,(function(u){switch(u.label){case 0:return"function"==typeof t?[2,t(e)]:(a=t.statusCheck,n=t.responseMatch,o=t.containsHeaders,(s=a)?[4,a(e.status)]:[3,2]);case 1:s=!u.sent(),u.label=2;case 2:return(i=s)?[3,5]:(c=n)?[4,n(e)]:[3,4];case 3:c=!u.sent(),u.label=4;case 4:i=c,u.label=5;case 5:if(i)return[2,!1];if(!o)return[3,10];for(f in d=[],o)d.push(f);l=0,u.label=6;case 6:return l<d.length?(h=d[l],v=o[h],(p=v)?[4,v(null!==(r=e.headers[h.toLowerCase()])&&void 0!==r?r:e.headers[h])]:[3,8]):[3,10];case 7:p=!u.sent(),u.label=8;case 8:if(p)return[2,!1];u.label=9;case 9:return l++,[3,6];case 10:return[2,!0]}}))}))}function m(e,t,r){return c(this,void 0,void 0,(function(){var a,n,o,i,s,c,d;return u(this,(function(u){switch(u.label){case 0:for(n in a=[],r)a.push(n);o=0,u.label=1;case 1:return o<a.length?(i=a[o],"delete"!==(s=r[i])?[3,3]:[4,e.remove(i)]):[3,10];case 2:return u.sent(),[3,9];case 3:return[4,e.get(i)];case 4:return"loading"===(c=u.sent()).state?[3,9]:[4,s(c,t)];case 5:return"delete"!==(d=u.sent())?[3,7]:[4,e.remove(i)];case 6:return u.sent(),[3,9];case 7:return"ignore"===d?[3,9]:[4,e.set(i,d)];case 8:u.sent(),u.label=9;case 9:return o++,[3,1];case 10:return[2]}}))}))}function b(e){var t=this,r=function(r){return c(t,void 0,void 0,(function(){var t;return u(this,(function(a){switch(a.label){case 0:return[4,e.storage.remove(r)];case 1:return a.sent(),null===(t=e.waiting[r])||void 0===t||t.reject(null),delete e.waiting[r],[2]}}))}))},a=function(a){return c(t,void 0,void 0,(function(){var t,n,i,c,d,f,l,h,p,b,y,x;return u(this,(function(u){switch(u.label){case 0:return a.id=null!==(b=(x=a.config).id)&&void 0!==b?b:x.id=e.generateKey(a.config),null!==(y=a.cached)&&void 0!==y||(a.cached=!1),a.cached?[2,a]:a.config.cache?(t=a.config.cache,[4,e.storage.get(a.id)]):[2,s(s({},a),{cached:!1})];case 1:return"stale"===(n=u.sent()).state||"empty"===n.state||"cached"===n.state?[2,a]:(i=!n.data)?[4,g(a,t.cachePredicate)]:[3,3];case 2:i=!u.sent(),u.label=3;case 3:return i?[4,r(a.id)]:[3,5];case 4:return u.sent(),[2,a];case 5:for(c in o)c.startsWith("XAxiosCache")&&delete a.headers[c];return t.etag&&!0!==t.etag&&(a.headers[o.XAxiosCacheEtag]=t.etag),t.modifiedSince&&(a.headers[o.XAxiosCacheLastModified]=!0===t.modifiedSince?"use-cache-timestamp":t.modifiedSince.toUTCString()),d=t.ttl||-1,(null==t?void 0:t.interpretHeader)?"dont cache"!==(f=e.headerInterpreter(a.headers))?[3,7]:[4,r(a.id)]:[3,8];case 6:return u.sent(),[2,a];case 7:d="not enough headers"===f?d:f,u.label=8;case 8:return l=v(a,n.data),"function"!=typeof d?[3,10]:[4,d(a)];case 9:d=u.sent(),u.label=10;case 10:return t.staleIfError&&(a.headers[o.XAxiosCacheStaleIfError]=String(d)),(null==t?void 0:t.update)?[4,m(e.storage,a,t.update)]:[3,12];case 11:u.sent(),u.label=12;case 12:return h={state:"cached",ttl:d,createdAt:Date.now(),data:l},(p=e.waiting[a.id])&&(p.resolve(h.data),delete e.waiting[a.id]),[4,e.storage.set(a.id,h)];case 13:return u.sent(),[2,a]}}))}))},n=function(a){return c(t,void 0,void 0,(function(){var t,n,o,i,s,c;return u(this,(function(u){switch(u.label){case 0:if(!(t=a.config)||!1===t.cache||!t.id)throw a;return[4,e.storage.get(t.id)];case 1:return n=u.sent(),o=t.cache,"loading"===n.state&&"stale"===n.previous?[3,3]:[4,r(t.id)];case 2:throw u.sent(),a;case 3:return(null==o?void 0:o.staleIfError)?"function"!=typeof o.staleIfError?[3,5]:[4,o.staleIfError(a.response,n,a)]:[3,8];case 4:return s=u.sent(),[3,6];case 5:s=o.staleIfError,u.label=6;case 6:return!0===(i=s)||"number"==typeof i&&n.createdAt+i>Date.now()?(null===(c=e.waiting[t.id])||void 0===c||c.resolve(n.data),delete e.waiting[t.id],[4,e.storage.set(t.id,{state:"stale",createdAt:Date.now(),data:n.data})]):[3,8];case 7:return u.sent(),[2,{cached:!0,config:t,id:t.id,data:n.data.data,headers:n.data.headers,status:n.data.status,statusText:n.data.statusText}];case 8:throw a}}))}))};return{onFulfilled:a,onRejected:n,apply:function(){return e.interceptors.response.use(a,n)}}}var y=Symbol(),x=function(e){return!!e&&!!e[y]};function w(e){var t,r=this,a=e.set,n=e.find,i=e.remove;return(t={})[y]=1,t.set=a,t.remove=i,t.get=function(e){return c(r,void 0,void 0,(function(){var t,r;return u(this,(function(s){switch(s.label){case 0:return[4,n(e)];case 1:return(t=s.sent())?"cached"!==t.state||t.createdAt+t.ttl>Date.now()?[2,t]:t.data.headers&&(o.ETag in t.data.headers||o.LastModified in t.data.headers||o.XAxiosCacheEtag in t.data.headers||o.XAxiosCacheStaleIfError in t.data.headers||o.XAxiosCacheLastModified in t.data.headers)?(r={state:"stale",createdAt:t.createdAt,data:t.data},[4,a(e,r)]):[3,3]:[2,{state:"empty"}];case 2:return s.sent(),[2,r];case 3:return[4,i(e)];case 4:return s.sent(),[2,{state:"empty"}]}}))}))},t}function S(){var e=w({find:function(t){return e.data[t]},set:function(t,r){e.data[t]=r},remove:function(t){delete e.data[t]}});return e.data=Object.create(null),e}var C=r(246),I=/^\/|\/$/g;function A(e,t){return function(r){if(r.id)return r.id;r.baseURL&&(r.baseURL=r.baseURL.replace(I,"")),r.url&&(r.url=r.url.replace(I,"")),r.method&&(r.method=r.method.toLowerCase());var a=t(r);return e?(0,C.code)(a).toString():a}}var E=A(!0,(function(e){var t=e.baseURL,r=void 0===t?"":t,a=e.url,n=void 0===a?"":a,o=e.method;return{url:r+(r&&n?"/":"")+n,method:void 0===o?"get":o,params:e.params,data:e.data}}));function j(e,t){var r,a,n,o,s;void 0===t&&(t={});var c=e;if(c.storage=t.storage||S(),!x(c.storage))throw new Error("Use buildStorage() function");return c.generateKey=t.generateKey||E,c.waiting=t.waiting||{},c.headerInterpreter=t.headerInterpreter||i,c.requestInterceptor=t.requestInterceptor||p(c),c.responseInterceptor=t.responseInterceptor||b(c),c.debug=t.debug,c.defaults.cache={ttl:null!==(r=t.ttl)&&void 0!==r?r:3e5,interpretHeader:null!==(a=t.interpretHeader)&&void 0!==a&&a,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:function(e){return e>=200&&e<400}},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(o=t.modifiedSince)&&void 0!==o&&o,staleIfError:null!==(s=t.staleIfError)&&void 0!==s&&s,update:t.update||{}},c.requestInterceptor.apply(),c.responseInterceptor.apply(),c}function T(e,t){return void 0===t&&(t=""),w({find:function(r){var a=e.getItem(t+r);return a?JSON.parse(a):void 0},set:function(r,a){e.setItem(t+r,JSON.stringify(a))},remove:function(r){e.removeItem(t+r)}})}}(),a}()}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}("undefined"!=typeof self?self:this,(function(){return function(){var e={549:function(e,t){var r,n;r=t,n=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise((function(r,n){e=r,t=n}));return r.resolve=e,r.reject=t,r[n]=1,r},r.isDeferred=function(e){return!!e&&!!e[n]}}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return function(){"use strict";r.r(n),r.d(n,{Header:function(){return o},buildKeyGenerator:function(){return O},buildMemoryStorage:function(){return C},buildStorage:function(){return I},buildWebStorage:function(){return L},canStale:function(){return w},createCacheResponse:function(){return v},createValidateStatus:function(){return f},defaultHeaderInterpreter:function(){return i},defaultKeyGenerator:function(){return T},defaultRequestInterceptor:function(){return p},defaultResponseInterceptor:function(){return b},isExpired:function(){return S},isMethodIn:function(){return l},isStorage:function(){return x},setupCache:function(){return M},testCachePredicate:function(){return g},updateCache:function(){return m},updateStaleRequest:function(){return h}});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function a(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}var o=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),i=function(r){if(!r)return"not enough headers";var n=r[o.CacheControl];if(n){var i=function(r){var n=Object.defineProperty({},e,{enumerable:!1,value:1});if(!r||"string"!=typeof r)return n;var o=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),r={};for(var n in t){var a=t[n].split("=",2);r[a[0]]=1===a.length||a[1]}return r}(r);return a(o.immutable)&&(n.immutable=!0),t(o["max-age"])&&(n.maxAge=Number(o["max-age"])),t(o["max-stale"])&&(n.maxStale=Number(o["max-stale"])),t(o["min-fresh"])&&(n.minFresh=Number(o["min-fresh"])),a(o["must-revalidate"])&&(n.mustRevalidate=!0),a(o["must-understand"])&&(n.mustUnderstand=!0),a(o["no-cache"])&&(n.noCache=!0),a(o["no-store"])&&(n.noStore=!0),a(o["no-transform"])&&(n.noTransform=!0),a(o["only-if-cached"])&&(n.onlyIfCached=!0),a(o.private)&&(n.private=!0),a(o["proxy-revalidate"])&&(n.proxyRevalidate=!0),a(o.public)&&(n.public=!0),t(o["s-maxage"])&&(n.sMaxAge=Number(o["s-maxage"])),t(o["stale-if-error"])&&(n.staleIfError=Number(o["stale-if-error"])),t(o["stale-while-revalidate"])&&(n.staleWhileRevalidate=Number(o["stale-while-revalidate"])),n}(String(n)),s=i.noCache,c=i.noStore,u=i.mustRevalidate,d=i.maxAge,f=i.immutable;if(s||c)return"dont cache";if(f)return 31536e6;if(u)return 0;if(d){var l=r[o.Age];return l?1e3*(d-Number(l)):1e3*d}}var h=r[o.Expires];if(h){var v=Date.parse(String(h))-Date.now();return v>=0?v:"dont cache"}return"not enough headers"};var s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},s.apply(this,arguments)};function c(e,t,r,n){return new(r||(r=Promise))((function(a,o){function i(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((n=n.apply(e,t||[])).next())}))}function u(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}Object.create;Object.create;var d=r(549);function f(e){return e?function(t){return e(t)||304===t}:function(e){return e>=200&&e<300||304===e}}function l(e,t){void 0===e&&(e="get"),void 0===t&&(t=[]),e=e.toLowerCase();for(var r=0,n=t;r<n.length;r++){if(n[r].toLowerCase()===e)return!0}return!1}function h(e,t){var r;t.headers||(t.headers={});var n=t.cache,a=n.etag,i=n.modifiedSince;if(a){var s=!0===a?null===(r=e.data)||void 0===r?void 0:r.headers[o.ETag]:a;s&&(t.headers[o.IfNoneMatch]=s)}i&&(t.headers[o.IfModifiedSince]=!0===i?e.data.headers[o.LastModified]||new Date(e.createdAt).toUTCString():i.toUTCString())}function v(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=s(s({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function p(e){var t=this,r=function(r){return c(t,void 0,void 0,(function(){var t,n,a,o,i;return u(this,(function(c){switch(c.label){case 0:return!1===r.cache?[2,r]:(r.cache=s(s({},e.defaults.cache),r.cache),l(r.method,r.cache.methods)?(t=r.id=e.generateKey(r),[4,e.storage.get(t)]):[2,r]);case 1:return"empty"!==(n=c.sent()).state&&"stale"!==n.state?[3,5]:e.waiting[t]?[4,e.storage.get(t)]:[3,3];case 2:return n=c.sent(),[3,5];case 3:return e.waiting[t]=(0,d.deferred)(),null===(i=e.waiting[t])||void 0===i||i.catch((function(){})),[4,e.storage.set(t,{state:"loading",previous:n.state,data:n.data,createdAt:n.createdAt})];case 4:return c.sent(),"stale"===n.state&&h(n,r),r.validateStatus=f(r.validateStatus),[2,r];case 5:return"loading"!==n.state?[3,12]:(o=e.waiting[t])?[3,7]:[4,e.storage.remove(t)];case 6:return c.sent(),[2,r];case 7:0,c.label=8;case 8:return c.trys.push([8,10,,11]),[4,o];case 9:return a=c.sent(),[3,11];case 10:return c.sent(),[2,r];case 11:return[3,13];case 12:a=n.data,c.label=13;case 13:return r.adapter=function(){return Promise.resolve({config:r,data:a.data,headers:a.headers,status:a.status,statusText:a.statusText,cached:!0,id:t})},[2,r]}}))}))};return{onFulfilled:r,apply:function(){return e.interceptors.request.use(r)}}}function g(e,t){var r;return c(this,void 0,void 0,(function(){var n,a,o,i,s,c,d,f,l,h,v,p;return u(this,(function(u){switch(u.label){case 0:return"function"==typeof t?[2,t(e)]:(n=t.statusCheck,a=t.responseMatch,o=t.containsHeaders,(s=n)?[4,n(e.status)]:[3,2]);case 1:s=!u.sent(),u.label=2;case 2:return(i=s)?[3,5]:(c=a)?[4,a(e)]:[3,4];case 3:c=!u.sent(),u.label=4;case 4:i=c,u.label=5;case 5:if(i)return[2,!1];if(!o)return[3,10];for(f in d=[],o)d.push(f);l=0,u.label=6;case 6:return l<d.length?(h=d[l],v=o[h],(p=v)?[4,v(null!==(r=e.headers[h.toLowerCase()])&&void 0!==r?r:e.headers[h])]:[3,8]):[3,10];case 7:p=!u.sent(),u.label=8;case 8:if(p)return[2,!1];u.label=9;case 9:return l++,[3,6];case 10:return[2,!0]}}))}))}function m(e,t,r){return c(this,void 0,void 0,(function(){var n,a,o,i,s,c,d;return u(this,(function(u){switch(u.label){case 0:for(a in n=[],r)n.push(a);o=0,u.label=1;case 1:return o<n.length?(i=n[o],"delete"!==(s=r[i])?[3,3]:[4,e.remove(i)]):[3,10];case 2:return u.sent(),[3,9];case 3:return[4,e.get(i)];case 4:return"loading"===(c=u.sent()).state?[3,9]:[4,s(c,t)];case 5:return"delete"!==(d=u.sent())?[3,7]:[4,e.remove(i)];case 6:return u.sent(),[3,9];case 7:return"ignore"===d?[3,9]:[4,e.set(i,d)];case 8:u.sent(),u.label=9;case 9:return o++,[3,1];case 10:return[2]}}))}))}function b(e){var t=this,r=function(r){return c(t,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return[4,e.storage.remove(r)];case 1:return n.sent(),null===(t=e.waiting[r])||void 0===t||t.reject(null),delete e.waiting[r],[2]}}))}))},n=function(n){return c(t,void 0,void 0,(function(){var t,a,i,c,d,f,l,h,p,b,y,x;return u(this,(function(u){switch(u.label){case 0:return n.id=null!==(b=(x=n.config).id)&&void 0!==b?b:x.id=e.generateKey(n.config),null!==(y=n.cached)&&void 0!==y||(n.cached=!1),n.cached?[2,n]:n.config.cache?(t=n.config.cache,[4,e.storage.get(n.id)]):[2,s(s({},n),{cached:!1})];case 1:return"stale"===(a=u.sent()).state||"empty"===a.state||"cached"===a.state?[2,n]:(i=!a.data)?[4,g(n,t.cachePredicate)]:[3,3];case 2:i=!u.sent(),u.label=3;case 3:return i?[4,r(n.id)]:[3,5];case 4:return u.sent(),[2,n];case 5:for(c in o)c.startsWith("XAxiosCache")&&delete n.headers[c];return t.etag&&!0!==t.etag&&(n.headers[o.XAxiosCacheEtag]=t.etag),t.modifiedSince&&(n.headers[o.XAxiosCacheLastModified]=!0===t.modifiedSince?"use-cache-timestamp":t.modifiedSince.toUTCString()),d=t.ttl||-1,(null==t?void 0:t.interpretHeader)?"dont cache"!==(f=e.headerInterpreter(n.headers))?[3,7]:[4,r(n.id)]:[3,8];case 6:return u.sent(),[2,n];case 7:d="not enough headers"===f?d:f,u.label=8;case 8:return l=v(n,a.data),"function"!=typeof d?[3,10]:[4,d(n)];case 9:d=u.sent(),u.label=10;case 10:return t.staleIfError&&(n.headers[o.XAxiosCacheStaleIfError]=String(d)),(null==t?void 0:t.update)?[4,m(e.storage,n,t.update)]:[3,12];case 11:u.sent(),u.label=12;case 12:return h={state:"cached",ttl:d,createdAt:Date.now(),data:l},(p=e.waiting[n.id])&&(p.resolve(h.data),delete e.waiting[n.id]),[4,e.storage.set(n.id,h)];case 13:return u.sent(),[2,n]}}))}))},a=function(n){return c(t,void 0,void 0,(function(){var t,a,o,i,s,c;return u(this,(function(u){switch(u.label){case 0:if(!(t=n.config)||!1===t.cache||!t.id)throw n;return[4,e.storage.get(t.id)];case 1:return a=u.sent(),o=t.cache,"loading"===a.state&&"stale"===a.previous?[3,3]:[4,r(t.id)];case 2:throw u.sent(),n;case 3:return(null==o?void 0:o.staleIfError)?"function"!=typeof o.staleIfError?[3,5]:[4,o.staleIfError(n.response,a,n)]:[3,8];case 4:return s=u.sent(),[3,6];case 5:s=o.staleIfError,u.label=6;case 6:return!0===(i=s)||"number"==typeof i&&a.createdAt+i>Date.now()?(null===(c=e.waiting[t.id])||void 0===c||c.resolve(a.data),delete e.waiting[t.id],[4,e.storage.set(t.id,{state:"stale",createdAt:Date.now(),data:a.data})]):[3,8];case 7:return u.sent(),[2,{cached:!0,config:t,id:t.id,data:a.data.data,headers:a.data.headers,status:a.data.status,statusText:a.data.statusText}];case 8:throw n}}))}))};return{onFulfilled:n,onRejected:a,apply:function(){return e.interceptors.response.use(n,a)}}}var y=Symbol(),x=function(e){return!!e&&!!e[y]};function w(e){var t=e.data.headers;return o.ETag in t||o.LastModified in t||o.XAxiosCacheEtag in t||o.XAxiosCacheStaleIfError in t||o.XAxiosCacheLastModified in t}function S(e){return e.createdAt+e.ttl<=Date.now()}function I(e){var t,r=this,n=e.set,a=e.find,o=e.remove;return(t={})[y]=1,t.set=n,t.remove=o,t.get=function(e){return c(r,void 0,void 0,(function(){var t,r;return u(this,(function(i){switch(i.label){case 0:return[4,a(e)];case 1:return(t=i.sent())?"cached"===t.state&&S(t)?w(t)?(r={state:"stale",createdAt:t.createdAt,data:t.data},[4,n(e,r)]):[3,3]:[2,t]:[2,{state:"empty"}];case 2:return i.sent(),[2,r];case 3:return[4,o(e)];case 4:return i.sent(),[2,{state:"empty"}]}}))}))},t}function C(){var e=I({find:function(t){return e.data[t]},set:function(t,r){e.data[t]=r},remove:function(t){delete e.data[t]}});return e.data=Object.create(null),e}function A(e){const t=typeof e;if(e&&"object"===t&&!(e instanceof Date||e instanceof RegExp)){const t=Array.isArray(e)?[]:{};for(const r in e)t[r]=A(e[r]);return`${e.constructor}${JSON.stringify(t,Object.keys(e).sort())}`}return`${t}${String(e)}`}function E(e){e=A(e);let t=5381;for(let r=0;r<e.length;r++)t=33*t^e.charCodeAt(r);return t>>>0}var j=/^\/|\/$/g;function O(e,t){return function(r){if(r.id)return r.id;r.baseURL&&(r.baseURL=r.baseURL.replace(j,"")),r.url&&(r.url=r.url.replace(j,"")),r.method&&(r.method=r.method.toLowerCase());var n=t(r);return e?E(n).toString():n}}var T=O(!0,(function(e){var t=e.baseURL,r=void 0===t?"":t,n=e.url,a=void 0===n?"":n,o=e.method;return{url:r+(r&&a?"/":"")+a,method:void 0===o?"get":o,params:e.params,data:e.data}}));function M(e,t){var r,n,a,o,s;void 0===t&&(t={});var c=e;if(c.storage=t.storage||C(),!x(c.storage))throw new Error("Use buildStorage() function");return c.generateKey=t.generateKey||T,c.waiting=t.waiting||{},c.headerInterpreter=t.headerInterpreter||i,c.requestInterceptor=t.requestInterceptor||p(c),c.responseInterceptor=t.responseInterceptor||b(c),c.debug=t.debug,c.defaults.cache={ttl:null!==(r=t.ttl)&&void 0!==r?r:3e5,interpretHeader:null!==(n=t.interpretHeader)&&void 0!==n&&n,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:function(e){return e>=200&&e<400}},etag:null!==(a=t.etag)&&void 0!==a&&a,modifiedSince:null!==(o=t.modifiedSince)&&void 0!==o&&o,staleIfError:null!==(s=t.staleIfError)&&void 0!==s&&s,update:t.update||{}},c.requestInterceptor.apply(),c.responseInterceptor.apply(),c}function L(e,t){return void 0===t&&(t=""),I({find:function(r){var n=e.getItem(t+r);return n?JSON.parse(n):void 0},remove:function(r){e.removeItem(t+r)},set:function(r,n){var a=function(){return e.setItem(t+r,JSON.stringify(n))};try{return a()}catch(n){for(var o=Object.entries(e).filter((function(r){var n=r[0];return n.startsWith(t)&&e.getItem(n)})).map((function(e){var t=e[0],r=e[1];return[t,JSON.parse(r)]})),i=0,s=o;i<s.length;i++){var c=s[i],u=c[0],d=c[1];"cached"===d.state&&S(d)&&!w(d)&&e.removeItem(u)}try{return a()}catch(t){for(var f=o.sort((function(e,t){var r=e[1],n=t[1];return(r.createdAt||0)-(n.createdAt||0)})),l=0,h=f;l<h.length;l++){u=h[l][0];e.removeItem(u);try{return a()}catch(e){}}}e.removeItem(t+r)}}})}}(),n}()}));

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}("undefined"!=typeof self?self:this,(function(){return(()=>{var e={549:(e,t)=>{var a,r;a=t,r=Symbol("fast-defer"),a.deferred=function(){var e,t,a=new Promise((function(a,r){e=a,t=r}));return a.resolve=e,a.reject=t,a[r]=1,a},a.isDeferred=function(e){return!!e&&!!e[r]}},246:(e,t)=>{var a;(a=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var r=Array.isArray(e)?[]:{};for(var n in e)r[n]=a.transform(e[n]);return"#"+String(e.constructor)+JSON.stringify(r,Object.keys(r).sort())}return t+String(e)+("symbol"===t?Math.random():"")},a.code=function(e){e=a.transform(e);for(var t=7,r=0;r<e.length;)t=31*t+e.charCodeAt(r++)&9007199254740991;return t}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,a),i.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";a.r(r),a.d(r,{Header:()=>i,buildKeyGenerator:()=>S,buildMemoryStorage:()=>w,buildStorage:()=>y,buildWebStorage:()=>A,createCacheResponse:()=>f,createValidateStatus:()=>d,defaultHeaderInterpreter:()=>o,defaultKeyGenerator:()=>C,defaultRequestInterceptor:()=>l,defaultResponseInterceptor:()=>p,isMethodIn:()=>c,isStorage:()=>v,setupCache:()=>I,testCachePredicate:()=>h,updateCache:()=>g,updateStaleRequest:()=>u});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}const i=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),o=a=>{if(!a)return"not enough headers";const r=a[i.CacheControl];if(r){const{noCache:o,noStore:s,mustRevalidate:d,maxAge:c,immutable:u}=function(a){var r=Object.defineProperty({},e,{enumerable:!1,value:1});if(!a||"string"!=typeof a)return r;var i=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),a={};for(var r in t){var n=t[r].split("=",2);a[n[0]]=1===n.length||n[1]}return a}(a);return n(i.immutable)&&(r.immutable=!0),t(i["max-age"])&&(r.maxAge=Number(i["max-age"])),t(i["max-stale"])&&(r.maxStale=Number(i["max-stale"])),t(i["min-fresh"])&&(r.minFresh=Number(i["min-fresh"])),n(i["must-revalidate"])&&(r.mustRevalidate=!0),n(i["must-understand"])&&(r.mustUnderstand=!0),n(i["no-cache"])&&(r.noCache=!0),n(i["no-store"])&&(r.noStore=!0),n(i["no-transform"])&&(r.noTransform=!0),n(i["only-if-cached"])&&(r.onlyIfCached=!0),n(i.private)&&(r.private=!0),n(i["proxy-revalidate"])&&(r.proxyRevalidate=!0),n(i.public)&&(r.public=!0),t(i["s-maxage"])&&(r.sMaxAge=Number(i["s-maxage"])),t(i["stale-if-error"])&&(r.staleIfError=Number(i["stale-if-error"])),t(i["stale-while-revalidate"])&&(r.staleWhileRevalidate=Number(i["stale-while-revalidate"])),r}(String(r));if(o||s)return"dont cache";if(u)return 31536e6;if(d)return 0;if(c){const e=a[i.Age];return e?1e3*(c-Number(e)):1e3*c}}const o=a[i.Expires];if(o){const e=Date.parse(String(o))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};var s=a(549);function d(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function c(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function u(e,t){var a;t.headers||(t.headers={});const{etag:r,modifiedSince:n}=t.cache;if(r){const n=!0===r?null===(a=e.data)||void 0===a?void 0:a.headers[i.ETag]:r;n&&(t.headers[i.IfNoneMatch]=n)}n&&(t.headers[i.IfModifiedSince]=!0===n?e.data.headers[i.LastModified]||new Date(e.createdAt).toUTCString():n.toUTCString())}function f(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function l(e){const t=async t=>{var a;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!c(t.method,t.cache.methods))return t;const r=t.id=e.generateKey(t);let n,i=await e.storage.get(r);e:if("empty"===i.state||"stale"===i.state){if(e.waiting[r]){i=await e.storage.get(r);break e}return e.waiting[r]=(0,s.deferred)(),null===(a=e.waiting[r])||void 0===a||a.catch((()=>{})),await e.storage.set(r,{state:"loading",previous:i.state,data:i.data,createdAt:i.createdAt}),"stale"===i.state&&u(i,t),t.validateStatus=d(t.validateStatus),t}if("loading"===i.state){const a=e.waiting[r];if(!a)return await e.storage.remove(r),t;0;try{n=await a}catch(e){return t}}else n=i.data;return t.adapter=()=>Promise.resolve({config:t,data:n.data,headers:n.headers,status:n.status,statusText:n.statusText,cached:!0,id:r}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function h(e,t){var a;if("function"==typeof t)return t(e);const{statusCheck:r,responseMatch:n,containsHeaders:i}=t;if(r&&!await r(e.status)||n&&!await n(e))return!1;if(i)for(const t in i){const r=i[t];if(r&&!await r(null!==(a=e.headers[t.toLowerCase()])&&void 0!==a?a:e.headers[t]))return!1}return!0}async function g(e,t,a){for(const r in a){const n=a[r];if("delete"===n){await e.remove(r);continue}const i=await e.get(r);if("loading"===i.state)continue;const o=await n(i,t);"delete"!==o?"ignore"!==o&&await e.set(r,o):await e.remove(r)}}function p(e){const t=async t=>{var a;await e.storage.remove(t),null===(a=e.waiting[t])||void 0===a||a.reject(null),delete e.waiting[t]},a=async a=>{var r,n,o;if(a.id=null!==(r=(o=a.config).id)&&void 0!==r?r:o.id=e.generateKey(a.config),null!==(n=a.cached)&&void 0!==n||(a.cached=!1),a.cached)return a;if(!a.config.cache)return Object.assign(Object.assign({},a),{cached:!1});const s=a.config.cache,d=await e.storage.get(a.id);if("stale"===d.state||"empty"===d.state||"cached"===d.state)return a;if(!d.data&&!await h(a,s.cachePredicate))return await t(a.id),a;for(const e in i)e.startsWith("XAxiosCache")&&delete a.headers[e];s.etag&&!0!==s.etag&&(a.headers[i.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(a.headers[i.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString());let c=s.ttl||-1;if(null==s?void 0:s.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),a;c="not enough headers"===r?c:r}const u=f(a,d.data);"function"==typeof c&&(c=await c(a)),s.staleIfError&&(a.headers[i.XAxiosCacheStaleIfError]=String(c)),(null==s?void 0:s.update)&&await g(e.storage,a,s.update);const l={state:"cached",ttl:c,createdAt:Date.now(),data:u},p=e.waiting[a.id];return p&&(p.resolve(l.data),delete e.waiting[a.id]),await e.storage.set(a.id,l),a},r=async a=>{var r;const n=a.config;if(!n||!1===n.cache||!n.id)throw a;const i=await e.storage.get(n.id),o=n.cache;if("loading"!==i.state||"stale"!==i.previous)throw await t(n.id),a;if(null==o?void 0:o.staleIfError){const t="function"==typeof o.staleIfError?await o.staleIfError(a.response,i,a):o.staleIfError;if(!0===t||"number"==typeof t&&i.createdAt+t>Date.now())return null===(r=e.waiting[n.id])||void 0===r||r.resolve(i.data),delete e.waiting[n.id],await e.storage.set(n.id,{state:"stale",createdAt:Date.now(),data:i.data}),{cached:!0,config:n,id:n.id,data:i.data.data,headers:i.data.headers,status:i.data.status,statusText:i.data.statusText}}throw a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const m=Symbol(),v=e=>!!e&&!!e[m];function y({set:e,find:t,remove:a}){return{[m]:1,set:e,remove:a,get:async r=>{const n=await t(r);if(!n)return{state:"empty"};if("cached"!==n.state||n.createdAt+n.ttl>Date.now())return n;if(n.data.headers&&(i.ETag in n.data.headers||i.LastModified in n.data.headers||i.XAxiosCacheEtag in n.data.headers||i.XAxiosCacheStaleIfError in n.data.headers||i.XAxiosCacheLastModified in n.data.headers)){const t={state:"stale",createdAt:n.createdAt,data:n.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function w(){const e=y({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}var b=a(246);const x=/^\/|\/$/g;function S(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(x,"")),a.url&&(a.url=a.url.replace(x,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,b.code)(r).toString():r}}const C=S(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:n})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:n})));function I(e,t={}){var a,r,n,i,s;const d=e;if(d.storage=t.storage||w(),!v(d.storage))throw new Error("Use buildStorage() function");return d.generateKey=t.generateKey||C,d.waiting=t.waiting||{},d.headerInterpreter=t.headerInterpreter||o,d.requestInterceptor=t.requestInterceptor||l(d),d.responseInterceptor=t.responseInterceptor||p(d),d.debug=t.debug,d.defaults.cache={ttl:null!==(a=t.ttl)&&void 0!==a?a:3e5,interpretHeader:null!==(r=t.interpretHeader)&&void 0!==r&&r,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(i=t.modifiedSince)&&void 0!==i&&i,staleIfError:null!==(s=t.staleIfError)&&void 0!==s&&s,update:t.update||{}},d.requestInterceptor.apply(),d.responseInterceptor.apply(),d}function A(e,t=""){return y({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},set:(a,r)=>{e.setItem(t+a,JSON.stringify(r))},remove:a=>{e.removeItem(t+a)}})}})(),r})()}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}("undefined"!=typeof self?self:this,(function(){return(()=>{var e={549:(e,t)=>{var a,r;a=t,r=Symbol("fast-defer"),a.deferred=function(){var e,t,a=new Promise((function(a,r){e=a,t=r}));return a.resolve=e,a.reject=t,a[r]=1,a},a.isDeferred=function(e){return!!e&&!!e[r]}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,a),o.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";a.r(r),a.d(r,{Header:()=>o,buildKeyGenerator:()=>A,buildMemoryStorage:()=>x,buildStorage:()=>b,buildWebStorage:()=>O,canStale:()=>y,createCacheResponse:()=>f,createValidateStatus:()=>c,defaultHeaderInterpreter:()=>i,defaultKeyGenerator:()=>j,defaultRequestInterceptor:()=>l,defaultResponseInterceptor:()=>p,isExpired:()=>w,isMethodIn:()=>d,isStorage:()=>v,setupCache:()=>E,testCachePredicate:()=>h,updateCache:()=>g,updateStaleRequest:()=>u});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}const o=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),i=a=>{if(!a)return"not enough headers";const r=a[o.CacheControl];if(r){const{noCache:i,noStore:s,mustRevalidate:c,maxAge:d,immutable:u}=function(a){var r=Object.defineProperty({},e,{enumerable:!1,value:1});if(!a||"string"!=typeof a)return r;var o=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),a={};for(var r in t){var n=t[r].split("=",2);a[n[0]]=1===n.length||n[1]}return a}(a);return n(o.immutable)&&(r.immutable=!0),t(o["max-age"])&&(r.maxAge=Number(o["max-age"])),t(o["max-stale"])&&(r.maxStale=Number(o["max-stale"])),t(o["min-fresh"])&&(r.minFresh=Number(o["min-fresh"])),n(o["must-revalidate"])&&(r.mustRevalidate=!0),n(o["must-understand"])&&(r.mustUnderstand=!0),n(o["no-cache"])&&(r.noCache=!0),n(o["no-store"])&&(r.noStore=!0),n(o["no-transform"])&&(r.noTransform=!0),n(o["only-if-cached"])&&(r.onlyIfCached=!0),n(o.private)&&(r.private=!0),n(o["proxy-revalidate"])&&(r.proxyRevalidate=!0),n(o.public)&&(r.public=!0),t(o["s-maxage"])&&(r.sMaxAge=Number(o["s-maxage"])),t(o["stale-if-error"])&&(r.staleIfError=Number(o["stale-if-error"])),t(o["stale-while-revalidate"])&&(r.staleWhileRevalidate=Number(o["stale-while-revalidate"])),r}(String(r));if(i||s)return"dont cache";if(u)return 31536e6;if(c)return 0;if(d){const e=a[o.Age];return e?1e3*(d-Number(e)):1e3*d}}const i=a[o.Expires];if(i){const e=Date.parse(String(i))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};var s=a(549);function c(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function d(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function u(e,t){var a;t.headers||(t.headers={});const{etag:r,modifiedSince:n}=t.cache;if(r){const n=!0===r?null===(a=e.data)||void 0===a?void 0:a.headers[o.ETag]:r;n&&(t.headers[o.IfNoneMatch]=n)}n&&(t.headers[o.IfModifiedSince]=!0===n?e.data.headers[o.LastModified]||new Date(e.createdAt).toUTCString():n.toUTCString())}function f(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function l(e){const t=async t=>{var a;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!d(t.method,t.cache.methods))return t;const r=t.id=e.generateKey(t);let n,o=await e.storage.get(r);e:if("empty"===o.state||"stale"===o.state){if(e.waiting[r]){o=await e.storage.get(r);break e}return e.waiting[r]=(0,s.deferred)(),null===(a=e.waiting[r])||void 0===a||a.catch((()=>{})),await e.storage.set(r,{state:"loading",previous:o.state,data:o.data,createdAt:o.createdAt}),"stale"===o.state&&u(o,t),t.validateStatus=c(t.validateStatus),t}if("loading"===o.state){const a=e.waiting[r];if(!a)return await e.storage.remove(r),t;0;try{n=await a}catch(e){return t}}else n=o.data;return t.adapter=()=>Promise.resolve({config:t,data:n.data,headers:n.headers,status:n.status,statusText:n.statusText,cached:!0,id:r}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function h(e,t){var a;if("function"==typeof t)return t(e);const{statusCheck:r,responseMatch:n,containsHeaders:o}=t;if(r&&!await r(e.status)||n&&!await n(e))return!1;if(o)for(const t in o){const r=o[t];if(r&&!await r(null!==(a=e.headers[t.toLowerCase()])&&void 0!==a?a:e.headers[t]))return!1}return!0}async function g(e,t,a){for(const r in a){const n=a[r];if("delete"===n){await e.remove(r);continue}const o=await e.get(r);if("loading"===o.state)continue;const i=await n(o,t);"delete"!==i?"ignore"!==i&&await e.set(r,i):await e.remove(r)}}function p(e){const t=async t=>{var a;await e.storage.remove(t),null===(a=e.waiting[t])||void 0===a||a.reject(null),delete e.waiting[t]},a=async a=>{var r,n,i;if(a.id=null!==(r=(i=a.config).id)&&void 0!==r?r:i.id=e.generateKey(a.config),null!==(n=a.cached)&&void 0!==n||(a.cached=!1),a.cached)return a;if(!a.config.cache)return Object.assign(Object.assign({},a),{cached:!1});const s=a.config.cache,c=await e.storage.get(a.id);if("stale"===c.state||"empty"===c.state||"cached"===c.state)return a;if(!c.data&&!await h(a,s.cachePredicate))return await t(a.id),a;for(const e in o)e.startsWith("XAxiosCache")&&delete a.headers[e];s.etag&&!0!==s.etag&&(a.headers[o.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(a.headers[o.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString());let d=s.ttl||-1;if(null==s?void 0:s.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),a;d="not enough headers"===r?d:r}const u=f(a,c.data);"function"==typeof d&&(d=await d(a)),s.staleIfError&&(a.headers[o.XAxiosCacheStaleIfError]=String(d)),(null==s?void 0:s.update)&&await g(e.storage,a,s.update);const l={state:"cached",ttl:d,createdAt:Date.now(),data:u},p=e.waiting[a.id];return p&&(p.resolve(l.data),delete e.waiting[a.id]),await e.storage.set(a.id,l),a},r=async a=>{var r;const n=a.config;if(!n||!1===n.cache||!n.id)throw a;const o=await e.storage.get(n.id),i=n.cache;if("loading"!==o.state||"stale"!==o.previous)throw await t(n.id),a;if(null==i?void 0:i.staleIfError){const t="function"==typeof i.staleIfError?await i.staleIfError(a.response,o,a):i.staleIfError;if(!0===t||"number"==typeof t&&o.createdAt+t>Date.now())return null===(r=e.waiting[n.id])||void 0===r||r.resolve(o.data),delete e.waiting[n.id],await e.storage.set(n.id,{state:"stale",createdAt:Date.now(),data:o.data}),{cached:!0,config:n,id:n.id,data:o.data.data,headers:o.data.headers,status:o.data.status,statusText:o.data.statusText}}throw a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const m=Symbol(),v=e=>!!e&&!!e[m];function y(e){const t=e.data.headers;return o.ETag in t||o.LastModified in t||o.XAxiosCacheEtag in t||o.XAxiosCacheStaleIfError in t||o.XAxiosCacheLastModified in t}function w(e){return e.createdAt+e.ttl<=Date.now()}function b({set:e,find:t,remove:a}){return{[m]:1,set:e,remove:a,get:async r=>{const n=await t(r);if(!n)return{state:"empty"};if("cached"!==n.state||!w(n))return n;if(y(n)){const t={state:"stale",createdAt:n.createdAt,data:n.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function x(){const e=b({find:t=>e.data[t],set:(t,a)=>{e.data[t]=a},remove:t=>{delete e.data[t]}});return e.data=Object.create(null),e}function S(e){const t=typeof e;if(e&&"object"===t&&!(e instanceof Date||e instanceof RegExp)){const t=Array.isArray(e)?[]:{};for(const a in e)t[a]=S(e[a]);return`${e.constructor}${JSON.stringify(t,Object.keys(e).sort())}`}return`${t}${String(e)}`}function I(e){e=S(e);let t=5381;for(let a=0;a<e.length;a++)t=33*t^e.charCodeAt(a);return t>>>0}const C=/^\/|\/$/g;function A(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(C,"")),a.url&&(a.url=a.url.replace(C,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?I(r).toString():r}}const j=A(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:n})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:n})));function E(e,t={}){var a,r,n,o,s;const c=e;if(c.storage=t.storage||x(),!v(c.storage))throw new Error("Use buildStorage() function");return c.generateKey=t.generateKey||j,c.waiting=t.waiting||{},c.headerInterpreter=t.headerInterpreter||i,c.requestInterceptor=t.requestInterceptor||l(c),c.responseInterceptor=t.responseInterceptor||p(c),c.debug=t.debug,c.defaults.cache={ttl:null!==(a=t.ttl)&&void 0!==a?a:3e5,interpretHeader:null!==(r=t.interpretHeader)&&void 0!==r&&r,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(o=t.modifiedSince)&&void 0!==o&&o,staleIfError:null!==(s=t.staleIfError)&&void 0!==s&&s,update:t.update||{}},c.requestInterceptor.apply(),c.responseInterceptor.apply(),c}function O(e,t=""){return b({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},remove:a=>{e.removeItem(t+a)},set:(a,r)=>{const n=()=>e.setItem(t+a,JSON.stringify(r));try{return n()}catch(r){const o=Object.entries(e).filter((([a])=>a.startsWith(t)&&e.getItem(a))).map((([e,t])=>[e,JSON.parse(t)]));for(const[t,a]of o)"cached"===a.state&&w(a)&&!y(a)&&e.removeItem(t);try{return n()}catch(t){const a=o.sort((([,e],[,t])=>(e.createdAt||0)-(t.createdAt||0)));for(const[t]of a){e.removeItem(t);try{return n()}catch(e){}}}e.removeItem(t+a)}}})}})(),r})()}));

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