(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.RTKQ = {})); })(this, (function (exports) { 'use strict'; var e;exports.QueryStatus = void 0;var n,r=undefined&&undefined.__extends||(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t;}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r);}),i=undefined&&undefined.__generator||function(e,t){var n,r,i,a,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!((i=(i=u.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]1?t-1:0),r=1;r3?t.i-4:t.i:Array.isArray(e)?1:k(e)?2:x(e)?3:0}function A(e,t){return 2===q(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function R(e,t){return 2===q(e)?e.get(t):e[t]}function P(e,t,n){var r=q(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n;}function T(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function k(e){return te&&e instanceof Map}function x(e){return ne&&e instanceof Set}function I(e){return e.o||e.t}function C(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=se(e);delete t[ue];for(var n=ce(t),r=0;r1&&(e.set=e.add=e.clear=e.delete=N),Object.freeze(e),t&&j(e,(function(e,t){return E(t,!0)}),!0)),e}function N(){O(2);}function Q(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function M(e){var t=fe[e];return t||O(18,e),t}function D(e,t){fe[e]||(fe[e]=t);}function _(){return m}function K(e,t){t&&(M("Patches"),e.u=[],e.s=[],e.v=t);}function F(e){z(e),e.p.forEach(W),e.p=null;}function z(e){e===m&&(m=e.l);}function U(e){return m={p:[],l:m,h:e,m:!0,_:0}}function W(e){var t=e[ue];0===t.i||1===t.i?t.j():t.g=!0;}function B(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.O||M("ES5").S(t,e,r),r?(n[ue].P&&(F(t),O(4)),S(e)&&(e=L(t,e),t.l||H(t,e)),t.u&&M("Patches").M(n[ue].t,e,t.u,t.s)):e=L(t,n,[]),F(t),t.u&&t.v(t.u,t.s),e!==ie?e:void 0}function L(e,t,n){if(Q(t))return t;var r=t[ue];if(!r)return j(t,(function(i,a){return J(e,r,t,i,a,n)}),!0),t;if(r.A!==e)return t;if(!r.P)return H(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var i=4===r.i||5===r.i?r.o=C(r.k):r.o,a=i,u=!1;3===r.i&&(a=new Set(i),i.clear(),u=!0),j(a,(function(t,a){return J(e,r,i,t,a,n,u)})),H(e,i,!1),n&&e.u&&M("Patches").N(r,n,e.u,e.s);}return r.o}function J(e,t,n,r,i,a,u){if(w(i)){var o=L(e,i,a&&t&&3!==t.i&&!A(t.R,r)?a.concat(r):void 0);if(P(n,r,o),!w(o))return;e.m=!1;}else u&&n.add(i);if(S(i)&&!Q(i)){if(!e.h.D&&e._<1)return;L(e,i),t&&t.A.l||H(e,i);}}function H(e,t,n){void 0===n&&(n=!1),!e.l&&e.h.D&&e.m&&E(t,n);}function V(e,t){var n=e[ue];return (n?I(n):e)[t]}function G(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n);}}function $(e){e.P||(e.P=!0,e.l&&$(e.l));}function X(e){e.o||(e.o=C(e.t));}function Y(e,t,n){var r=k(t)?M("MapSet").F(t,n):x(t)?M("MapSet").T(t,n):e.O?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:_(),P:!1,I:!1,R:{},l:t,t:e,k:null,o:null,j:null,C:!1},i=r,a=le;n&&(i=[r],a=de);var u=Proxy.revocable(i,a),o=u.revoke,c=u.proxy;return r.k=c,r.j=o,c}(t,n):M("ES5").J(t,n);return (n?n.A:_()).p.push(r),r}function Z(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return C(e)}var ee="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),te="undefined"!=typeof Map,ne="undefined"!=typeof Set,re="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,ie=ee?Symbol.for("immer-nothing"):((g={})["immer-nothing"]=!0,g),ae=ee?Symbol.for("immer-draftable"):"__$immer_draftable",ue=ee?Symbol.for("immer-state"):"__$immer_state",oe=(""+Object.prototype.constructor),ce="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,se=Object.getOwnPropertyDescriptors||function(e){var t={};return ce(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n);})),t},fe={},le={get:function(e,t){if(t===ue)return e;var n,r,i,a=I(e);if(!A(a,t))return n=e,(i=G(a,t))?"value"in i?i.value:null===(r=i.get)||void 0===r?void 0:r.call(n.k):void 0;var u=a[t];return e.I||!S(u)?u:u===V(e.t,t)?(X(e),e.o[t]=Y(e.A.h,u,e)):u},has:function(e,t){return t in I(e)},ownKeys:function(e){return Reflect.ownKeys(I(e))},set:function(e,t,n){var r=G(I(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var i=V(I(e),t),a=null==i?void 0:i[ue];if(a&&a.t===n)return e.o[t]=n,e.R[t]=!1,!0;if(T(n,i)&&(void 0!==n||A(e.t,t)))return !0;X(e),$(e);}return e.o[t]===n&&(void 0!==n||t in e.o)||Number.isNaN(n)&&Number.isNaN(e.o[t])||(e.o[t]=n,e.R[t]=!0),!0},deleteProperty:function(e,t){return void 0!==V(e.t,t)||t in e.t?(e.R[t]=!1,X(e),$(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=I(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){O(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){O(12);}},de={};j(le,(function(e,t){de[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};})),de.deleteProperty=function(e,t){return de.set.call(this,e,t,void 0)},de.set=function(e,t,n){return le.set.call(this,e[0],t,n,e[0])};var pe=new(function(){function e(e){var t=this;this.O=re,this.D=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var i=n;n=e;var a=t;return function(e){var t=this;void 0===e&&(e=i);for(var r=arguments.length,u=Array(r>1?r-1:0),o=1;o1?r-1:0),a=1;a=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var i=M("Patches").$;return w(e)?i(e,t):this.produce(e,(function(e){return i(e,t)}))},e}()),ve=pe.produce,he=pe.produceWithPatches.bind(pe),ye=(pe.setAutoFreeze.bind(pe),pe.setUseProxies.bind(pe),pe.applyPatches.bind(pe)),ge=(pe.createDraft.bind(pe),pe.finishDraft.bind(pe),ve);function me(e){return "Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var be=function(){return Math.random().toString(36).substring(7).split("").join(".")},Oe={INIT:"@@redux/INIT"+be(),REPLACE:"@@redux/REPLACE"+be(),PROBE_UNKNOWN_ACTION:function(){return "@@redux/PROBE_UNKNOWN_ACTION"+be()}},we=function(e,t){return e===t};function Se(e,t){var n,r,i,a="object"==typeof t?t:{equalityCheck:t},u=a.equalityCheck,o=a.maxSize,c=void 0===o?1:o,s=a.resultEqualityCheck,f=(i=void 0===u?we:u,function(e,t){if(null===e||null===t||e.length!==t.length)return !1;for(var n=e.length,r=0;r-1){var i=n[r];return r>0&&(n.splice(r,1),n.unshift(i)),i.value}return "NOT_FOUND"}return {get:r,put:function(t,i){"NOT_FOUND"===r(t)&&(n.unshift({key:t,value:i}),n.length>e&&n.pop());},getEntries:function(){return n},clear:function(){n=[];}}}(c,f);function d(){var t=l.get(arguments);if("NOT_FOUND"===t){if(t=e.apply(null,arguments),s){var n=l.getEntries(),r=n.find((function(e){return s(e.value,t)}));r&&(t=r.value);}l.put(arguments,t);}return t}return d.clearCache=function(){return l.clear()},d}function je(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return "function"==typeof e}))){var n=t.map((function(e){return "function"==typeof e?"function "+(e.name||"unnamed")+"()":typeof e})).join(", ");throw new Error("createSelector expects all input-selectors to be functions, but received the following types: ["+n+"]")}return t}function qe(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r-1;return n&&r}function Ue(e){return "function"==typeof e[0]&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function We(){for(var e=[],t=0;t=0;t--){var i=e[t][ue];if(!i.P)switch(i.i){case 5:r(i)&&$(i);break;case 4:n(i)&&$(i);}}}function n(e){for(var t=e.t,n=e.k,r=ce(n),i=r.length-1;i>=0;i--){var a=r[i];if(a!==ue){var u=t[a];if(void 0===u&&!A(t,a))return !0;var o=n[a],c=o&&o[ue];if(c?c.t!==u:!T(o,u))return !0}}var s=!!t[ue];return r.length!==ce(t).length+(s?0:1)}function r(e){var t=e.k;if(t.length!==e.t.length)return !0;var n=Object.getOwnPropertyDescriptor(t,t.length-1);if(n&&!n.get)return !0;for(var r=0;r=200&&e.status<=299},Ye=function(e){return /ion\/(vnd\.api\+)?json/.test(e.get("content-type")||"")};function Ze(e){if(!Re(e))return e;for(var t=p({},e),n=0,r=Object.entries(t);n=f)}var d=Me(r+"/executeQuery",f,{getPendingMeta:function(){var e;return (e={startedTimeStamp:Date.now()}).RTK_autoBatch=!0,e},condition:function(e,t){var n,i,a,o=(0, t.getState)(),c=null==(i=null==(n=o[r])?void 0:n.queries)?void 0:i[e.queryCacheKey],s=null==c?void 0:c.fulfilledTimeStamp,f=e.originalArgs,d=null==c?void 0:c.originalArgs,p=u[e.endpointName];return !(!mt(e)&&("pending"===(null==c?void 0:c.status)||!l(e,o)&&(!pt(p)||!(null==(a=null==p?void 0:p.forceRefetch)?void 0:a.call(p,{currentArg:f,previousArg:d,endpointState:c,state:o})))&&s))},dispatchConditionRejection:!0}),p=Me(r+"/executeMutation",f,{getPendingMeta:function(){var e;return (e={startedTimeStamp:Date.now()}).RTK_autoBatch=!0,e}});function v(e){return function(t){var n,r;return (null==(r=null==(n=null==t?void 0:t.meta)?void 0:n.arg)?void 0:r.endpointName)===e}}return {queryThunk:d,mutationThunk:p,prefetch:function(e,t,n){return function(r,i){var a=function(e){return "force"in e}(n)&&n.force,u=function(e){return "ifOlderThan"in e}(n)&&n.ifOlderThan,o=function(n){return void 0===n&&(n=!0),c.endpoints[e].initiate(t,{forceRefetch:n})},s=c.endpoints[e].select(t)(i());if(a)r(o());else if(u){var f=null==s?void 0:s.fulfilledTimeStamp;if(!f)return void r(o());(Number(new Date)-Number(new Date(f)))/1e3>=u&&r(o());}else r(o(!1));}},updateQueryData:function(e,n,r,i){return void 0===i&&(i=!0),function(a,u){var o,s,f,l=c.endpoints[e].select(n)(u()),d={patches:[],inversePatches:[],undo:function(){return a(c.util.patchQueryData(e,n,d.inversePatches,i))}};if(l.status===exports.QueryStatus.uninitialized)return d;if("data"in l)if(S(l.data)){var p=he(l.data,r),v=p[0],h=p[2];(o=d.patches).push.apply(o,p[1]),(s=d.inversePatches).push.apply(s,h),f=v;}else f=r(l.data),d.patches.push({op:"replace",path:[],value:f}),d.inversePatches.push({op:"replace",path:[],value:l.data});return a(c.util.patchQueryData(e,n,d.patches,i)),d}},upsertQueryData:function(e,t,n){return function(r){var i;return r(c.endpoints[e].initiate(t,((i={subscribe:!1,forceRefetch:!0})[gt]=function(){return {data:n}},i)))}},patchQueryData:function(e,t,n,r){return function(i,a){var f=u[e],l=o({queryArgs:t,endpointDefinition:f,endpointName:e});if(i(c.internalActions.queryResultPatched({queryCacheKey:l,patches:n})),r){var d=c.endpoints[e].select(t)(a()),p=vt(f.providesTags,d.data,void 0,t,{},s);i(c.internalActions.updateProvidedBy({queryCacheKey:l,providedTags:p}));}}},buildMatchThunkActions:function(e,t){return {matchPending:Fe(We(e),v(t)),matchFulfilled:Fe(Je(e),v(t)),matchRejected:Fe(Be(e),v(t))}}}}({baseQuery:u,reducerPath:o,context:r,api:e,serializeQueryArgs:c,assertTagType:h}),m=g.queryThunk,P=g.mutationThunk,T=g.patchQueryData,I=g.updateQueryData,C=g.upsertQueryData,E=g.prefetch,N=g.buildMatchThunkActions,Q=function(e){var n=e.reducerPath,r=e.queryThunk,i=e.mutationThunk,a=e.context,u=a.endpointDefinitions,o=a.apiUid,c=a.extractRehydrationInfo,s=a.hasRehydrationInfo,f=e.assertTagType,l=e.config,d=Pe(n+"/resetApiState"),h=xe({name:n+"/queries",initialState:qt,reducers:{removeQueryResult:{reducer:function(e,t){delete e[t.payload.queryCacheKey];},prepare:function(e){var t;return {payload:e,meta:(t={},t.RTK_autoBatch=!0,t)}}},queryResultPatched:{reducer:function(e,t){var n=t.payload,r=n.patches;wt(e,n.queryCacheKey,(function(e){e.data=ye(e.data,r.concat());}));},prepare:function(e){var t;return {payload:e,meta:(t={},t.RTK_autoBatch=!0,t)}}}},extraReducers:function(e){e.addCase(r.pending,(function(e,n){var r,i=n.meta,a=n.meta.arg,u=mt(a);(a.subscribe||u)&&(null!=e[r=a.queryCacheKey]||(e[r]={status:exports.QueryStatus.uninitialized,endpointName:a.endpointName})),wt(e,a.queryCacheKey,(function(e){e.status=exports.QueryStatus.pending,e.requestId=u&&e.requestId?e.requestId:i.requestId,void 0!==a.originalArgs&&(e.originalArgs=a.originalArgs),e.startedTimeStamp=i.startedTimeStamp;}));})).addCase(r.fulfilled,(function(e,n){var r=n.meta,i=n.payload;wt(e,r.arg.queryCacheKey,(function(e){var n;if(e.requestId===r.requestId||mt(r.arg)){var a,o=u[r.arg.endpointName].merge;if(e.status=exports.QueryStatus.fulfilled,o)if(void 0!==e.data){var c=r.fulfilledTimeStamp,s=r.arg,f=r.baseQueryMeta,l=r.requestId,d=ge(e.data,(function(e){return o(e,i,{arg:s.originalArgs,baseQueryMeta:f,fulfilledTimeStamp:c,requestId:l})}));e.data=d;}else e.data=i;else e.data=null==(n=u[r.arg.endpointName].structuralSharing)||n?Ge(w(e.data)?(w(a=e.data)||O(23,a),a[ue].t):e.data,i):i;delete e.error,e.fulfilledTimeStamp=r.fulfilledTimeStamp;}}));})).addCase(r.rejected,(function(e,n){var r=n.meta,i=r.condition,a=r.requestId,u=n.error,o=n.payload;wt(e,r.arg.queryCacheKey,(function(e){if(i);else {if(e.requestId!==a)return;e.status=exports.QueryStatus.rejected,e.error=null!=o?o:u;}}));})).addMatcher(s,(function(e,n){for(var r=c(n).queries,i=0,a=Object.entries(r);i