"use strict"; (self["webpackChunk_core_volunteer_app"] = self["webpackChunk_core_volunteer_app"] || []).push([["vendors-node_modules_reduxjs_toolkit_dist_redux-toolkit_modern_mjs"],{ /***/ "../../../node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs": /*!****************************************************************************!*\ !*** ../../../node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs ***! \****************************************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ReducerType: () => (/* binding */ ReducerType), /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH), /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError), /* harmony export */ Tuple: () => (/* binding */ Tuple), /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.__DO_NOT_USE__ActionTypes), /* harmony export */ addListener: () => (/* binding */ addListener), /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.applyMiddleware), /* harmony export */ asyncThunkCreator: () => (/* binding */ asyncThunkCreator), /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer), /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.bindActionCreators), /* harmony export */ buildCreateSlice: () => (/* binding */ buildCreateSlice), /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners), /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers), /* harmony export */ combineSlices: () => (/* binding */ combineSlices), /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.compose), /* harmony export */ configureStore: () => (/* binding */ configureStore), /* harmony export */ createAction: () => (/* binding */ createAction), /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware), /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk), /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector), /* harmony export */ createDraftSafeSelectorCreator: () => (/* binding */ createDraftSafeSelectorCreator), /* harmony export */ createDynamicMiddleware: () => (/* binding */ createDynamicMiddleware), /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter), /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware), /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware), /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_1__.produce), /* harmony export */ createReducer: () => (/* binding */ createReducer), /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector), /* harmony export */ createSelectorCreator: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelectorCreator), /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware), /* harmony export */ createSlice: () => (/* binding */ createSlice), /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.createStore), /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_1__.current), /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue), /* harmony export */ formatProdErrorMessage: () => (/* binding */ formatProdErrorMessage), /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_1__.freeze), /* harmony export */ isAction: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.isAction), /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator), /* harmony export */ isAllOf: () => (/* binding */ isAllOf), /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf), /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction), /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_1__.isDraft), /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA), /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled), /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault), /* harmony export */ isPending: () => (/* binding */ isPending), /* harmony export */ isPlain: () => (/* binding */ isPlain), /* harmony export */ isPlainObject: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.isPlainObject), /* harmony export */ isRejected: () => (/* binding */ isRejected), /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue), /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_0__.legacy_createStore), /* harmony export */ lruMemoize: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.lruMemoize), /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError), /* harmony export */ nanoid: () => (/* binding */ nanoid), /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_1__.original), /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched), /* harmony export */ removeListener: () => (/* binding */ removeListener), /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult), /* harmony export */ weakMapMemoize: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.weakMapMemoize) /* harmony export */ }); /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! redux */ "../../../node_modules/redux/dist/redux.mjs"); /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! immer */ "../../../node_modules/immer/dist/immer.mjs"); /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/dist/reselect.mjs"); /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../../../node_modules/redux-thunk/dist/redux-thunk.mjs"); // src/index.ts // src/immerImports.ts // src/index.ts // src/reselectImports.ts // src/createDraftSafeSelector.ts var createDraftSafeSelectorCreator = (...args) => { const createSelector2 = (0,reselect__WEBPACK_IMPORTED_MODULE_2__.createSelectorCreator)(...args); const createDraftSafeSelector2 = Object.assign((...args2) => { const selector = createSelector2(...args2); const wrappedSelector = (value, ...rest) => selector((0,immer__WEBPACK_IMPORTED_MODULE_1__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_1__.current)(value) : value, ...rest); Object.assign(wrappedSelector, selector); return wrappedSelector; }, { withTypes: () => createDraftSafeSelector2 }); return createDraftSafeSelector2; }; var createDraftSafeSelector = /* @__PURE__ */ createDraftSafeSelectorCreator(reselect__WEBPACK_IMPORTED_MODULE_2__.weakMapMemoize); // src/reduxImports.ts // src/devtoolsExtension.ts var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() { if (arguments.length === 0) return void 0; if (typeof arguments[0] === "object") return redux__WEBPACK_IMPORTED_MODULE_0__.compose; return redux__WEBPACK_IMPORTED_MODULE_0__.compose.apply(null, arguments); }; var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() { return function(noop3) { return noop3; }; }; // src/getDefaultMiddleware.ts // src/tsHelpers.ts var hasMatchFunction = (v) => { return v && typeof v.match === "function"; }; // src/createAction.ts function createAction(type, prepareAction) { function actionCreator(...args) { if (prepareAction) { let prepared = prepareAction(...args); if (!prepared) { throw new Error( false ? 0 : "prepareAction did not return an object"); } return { type, payload: prepared.payload, ..."meta" in prepared && { meta: prepared.meta }, ..."error" in prepared && { error: prepared.error } }; } return { type, payload: args[0] }; } actionCreator.toString = () => `${type}`; actionCreator.type = type; actionCreator.match = (action) => (0,redux__WEBPACK_IMPORTED_MODULE_0__.isAction)(action) && action.type === type; return actionCreator; } function isActionCreator(action) { return typeof action === "function" && "type" in action && // hasMatchFunction only wants Matchers but I don't see the point in rewriting it hasMatchFunction(action); } function isFSA(action) { return (0,redux__WEBPACK_IMPORTED_MODULE_0__.isAction)(action) && Object.keys(action).every(isValidKey); } function isValidKey(key) { return ["type", "payload", "error", "meta"].indexOf(key) > -1; } // src/actionCreatorInvariantMiddleware.ts function getMessage(type) { const splitType = type ? `${type}`.split("/") : []; const actionName = splitType[splitType.length - 1] || "actionCreator"; return `Detected an action creator with type "${type || "unknown"}" being dispatched. Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${actionName}())\` instead of \`dispatch(${actionName})\`. This is necessary even if the action has no payload.`; } function createActionCreatorInvariantMiddleware(options = {}) { if (false) // removed by dead control flow {} const { isActionCreator: isActionCreator2 = isActionCreator } = options; return () => (next) => (action) => { if (isActionCreator2(action)) { console.warn(getMessage(action.type)); } return next(action); }; } // src/utils.ts function getTimeMeasureUtils(maxDelay, fnName) { let elapsed = 0; return { measureTime(fn) { const started = Date.now(); try { return fn(); } finally { const finished = Date.now(); elapsed += finished - started; } }, warnIfExceeded() { if (elapsed > maxDelay) { console.warn(`${fnName} took ${elapsed}ms, which is more than the warning threshold of ${maxDelay}ms. If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions. It is disabled in production builds, so you don't need to worry about that.`); } } }; } var Tuple = class _Tuple extends Array { constructor(...items) { super(...items); Object.setPrototypeOf(this, _Tuple.prototype); } static get [Symbol.species]() { return _Tuple; } concat(...arr) { return super.concat.apply(this, arr); } prepend(...arr) { if (arr.length === 1 && Array.isArray(arr[0])) { return new _Tuple(...arr[0].concat(this)); } return new _Tuple(...arr.concat(this)); } }; function freezeDraftable(val) { return (0,immer__WEBPACK_IMPORTED_MODULE_1__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_1__.produce)(val, () => { }) : val; } function getOrInsertComputed(map, key, compute) { if (map.has(key)) return map.get(key); return map.set(key, compute(key)).get(key); } // src/immutableStateInvariantMiddleware.ts function isImmutableDefault(value) { return typeof value !== "object" || value == null || Object.isFrozen(value); } function trackForMutations(isImmutable, ignoredPaths, obj) { const trackedProperties = trackProperties(isImmutable, ignoredPaths, obj); return { detectMutations() { return detectMutations(isImmutable, ignoredPaths, trackedProperties, obj); } }; } function trackProperties(isImmutable, ignoredPaths = [], obj, path = "", checkedObjects = /* @__PURE__ */ new Set()) { const tracked = { value: obj }; if (!isImmutable(obj) && !checkedObjects.has(obj)) { checkedObjects.add(obj); tracked.children = {}; const hasIgnoredPaths = ignoredPaths.length > 0; for (const key in obj) { const nestedPath = path ? path + "." + key : key; if (hasIgnoredPaths) { const hasMatches = ignoredPaths.some((ignored) => { if (ignored instanceof RegExp) { return ignored.test(nestedPath); } return nestedPath === ignored; }); if (hasMatches) { continue; } } tracked.children[key] = trackProperties(isImmutable, ignoredPaths, obj[key], nestedPath); } } return tracked; } function detectMutations(isImmutable, ignoredPaths = [], trackedProperty, obj, sameParentRef = false, path = "") { const prevObj = trackedProperty ? trackedProperty.value : void 0; const sameRef = prevObj === obj; if (sameParentRef && !sameRef && !Number.isNaN(obj)) { return { wasMutated: true, path }; } if (isImmutable(prevObj) || isImmutable(obj)) { return { wasMutated: false }; } const keysToDetect = {}; for (let key in trackedProperty.children) { keysToDetect[key] = true; } for (let key in obj) { keysToDetect[key] = true; } const hasIgnoredPaths = ignoredPaths.length > 0; for (let key in keysToDetect) { const nestedPath = path ? path + "." + key : key; if (hasIgnoredPaths) { const hasMatches = ignoredPaths.some((ignored) => { if (ignored instanceof RegExp) { return ignored.test(nestedPath); } return nestedPath === ignored; }); if (hasMatches) { continue; } } const result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath); if (result.wasMutated) { return result; } } return { wasMutated: false }; } function createImmutableStateInvariantMiddleware(options = {}) { if (false) // removed by dead control flow {} else { let stringify2 = function(obj, serializer, indent, decycler) { return JSON.stringify(obj, getSerialize2(serializer, decycler), indent); }, getSerialize2 = function(serializer, decycler) { let stack = [], keys = []; if (!decycler) decycler = function(_, value) { if (stack[0] === value) return "[Circular ~]"; return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]"; }; return function(key, value) { if (stack.length > 0) { var thisPos = stack.indexOf(this); ~thisPos ? stack.splice(thisPos + 1) : stack.push(this); ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key); if (~stack.indexOf(value)) value = decycler.call(this, key, value); } else stack.push(value); return serializer == null ? value : serializer.call(this, key, value); }; }; var stringify = stringify2, getSerialize = getSerialize2; let { isImmutable = isImmutableDefault, ignoredPaths, warnAfter = 32 } = options; const track = trackForMutations.bind(null, isImmutable, ignoredPaths); return ({ getState }) => { let state = getState(); let tracker = track(state); let result; return (next) => (action) => { const measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware"); measureUtils.measureTime(() => { state = getState(); result = tracker.detectMutations(); tracker = track(state); if (result.wasMutated) { throw new Error( false ? 0 : `A state mutation was detected between dispatches, in the path '${result.path || ""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`); } }); const dispatchedAction = next(action); measureUtils.measureTime(() => { state = getState(); result = tracker.detectMutations(); tracker = track(state); if (result.wasMutated) { throw new Error( false ? 0 : `A state mutation was detected inside a dispatch, in the path: ${result.path || ""}. Take a look at the reducer(s) handling the action ${stringify2(action)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`); } }); measureUtils.warnIfExceeded(); return dispatchedAction; }; }; } } // src/serializableStateInvariantMiddleware.ts function isPlain(val) { const type = typeof val; return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || (0,redux__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(val); } function findNonSerializableValue(value, path = "", isSerializable = isPlain, getEntries, ignoredPaths = [], cache) { let foundNestedSerializable; if (!isSerializable(value)) { return { keyPath: path || "", value }; } if (typeof value !== "object" || value === null) { return false; } if (cache?.has(value)) return false; const entries = getEntries != null ? getEntries(value) : Object.entries(value); const hasIgnoredPaths = ignoredPaths.length > 0; for (const [key, nestedValue] of entries) { const nestedPath = path ? path + "." + key : key; if (hasIgnoredPaths) { const hasMatches = ignoredPaths.some((ignored) => { if (ignored instanceof RegExp) { return ignored.test(nestedPath); } return nestedPath === ignored; }); if (hasMatches) { continue; } } if (!isSerializable(nestedValue)) { return { keyPath: nestedPath, value: nestedValue }; } if (typeof nestedValue === "object") { foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache); if (foundNestedSerializable) { return foundNestedSerializable; } } } if (cache && isNestedFrozen(value)) cache.add(value); return false; } function isNestedFrozen(value) { if (!Object.isFrozen(value)) return false; for (const nestedValue of Object.values(value)) { if (typeof nestedValue !== "object" || nestedValue === null) continue; if (!isNestedFrozen(nestedValue)) return false; } return true; } function createSerializableStateInvariantMiddleware(options = {}) { if (false) // removed by dead control flow {} else { const { isSerializable = isPlain, getEntries, ignoredActions = [], ignoredActionPaths = ["meta.arg", "meta.baseQueryMeta"], ignoredPaths = [], warnAfter = 32, ignoreState = false, ignoreActions = false, disableCache = false } = options; const cache = !disableCache && WeakSet ? /* @__PURE__ */ new WeakSet() : void 0; return (storeAPI) => (next) => (action) => { if (!(0,redux__WEBPACK_IMPORTED_MODULE_0__.isAction)(action)) { return next(action); } const result = next(action); const measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware"); if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) { measureUtils.measureTime(() => { const foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache); if (foundActionNonSerializableValue) { const { keyPath, value } = foundActionNonSerializableValue; console.error(`A non-serializable value was detected in an action, in the path: \`${keyPath}\`. Value:`, value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)"); } }); } if (!ignoreState) { measureUtils.measureTime(() => { const state = storeAPI.getState(); const foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache); if (foundStateNonSerializableValue) { const { keyPath, value } = foundStateNonSerializableValue; console.error(`A non-serializable value was detected in the state, in the path: \`${keyPath}\`. Value:`, value, ` Take a look at the reducer(s) handling this action type: ${action.type}. (See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`); } }); measureUtils.warnIfExceeded(); } return result; }; } } // src/getDefaultMiddleware.ts function isBoolean(x) { return typeof x === "boolean"; } var buildGetDefaultMiddleware = () => function getDefaultMiddleware(options) { const { thunk = true, immutableCheck = true, serializableCheck = true, actionCreatorCheck = true } = options ?? {}; let middlewareArray = new Tuple(); if (thunk) { if (isBoolean(thunk)) { middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__.thunk); } else { middlewareArray.push((0,redux_thunk__WEBPACK_IMPORTED_MODULE_3__.withExtraArgument)(thunk.extraArgument)); } } if (true) { if (immutableCheck) { let immutableOptions = {}; if (!isBoolean(immutableCheck)) { immutableOptions = immutableCheck; } middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions)); } if (serializableCheck) { let serializableOptions = {}; if (!isBoolean(serializableCheck)) { serializableOptions = serializableCheck; } middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions)); } if (actionCreatorCheck) { let actionCreatorOptions = {}; if (!isBoolean(actionCreatorCheck)) { actionCreatorOptions = actionCreatorCheck; } middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions)); } } return middlewareArray; }; // src/autoBatchEnhancer.ts var SHOULD_AUTOBATCH = "RTK_autoBatch"; var prepareAutoBatched = () => (payload) => ({ payload, meta: { [SHOULD_AUTOBATCH]: true } }); var createQueueWithTimer = (timeout) => { return (notify) => { setTimeout(notify, timeout); }; }; var autoBatchEnhancer = (options = { type: "raf" }) => (next) => (...args) => { const store = next(...args); let notifying = true; let shouldNotifyAtEndOfTick = false; let notificationQueued = false; const listeners = /* @__PURE__ */ new Set(); const queueCallback = options.type === "tick" ? queueMicrotask : options.type === "raf" ? ( // requestAnimationFrame won't exist in SSR environments. Fall back to a vague approximation just to keep from erroring. typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10) ) : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout); const notifyListeners = () => { notificationQueued = false; if (shouldNotifyAtEndOfTick) { shouldNotifyAtEndOfTick = false; listeners.forEach((l) => l()); } }; return Object.assign({}, store, { // Override the base `store.subscribe` method to keep original listeners // from running if we're delaying notifications subscribe(listener2) { const wrappedListener = () => notifying && listener2(); const unsubscribe = store.subscribe(wrappedListener); listeners.add(listener2); return () => { unsubscribe(); listeners.delete(listener2); }; }, // Override the base `store.dispatch` method so that we can check actions // for the `shouldAutoBatch` flag and determine if batching is active dispatch(action) { try { notifying = !action?.meta?.[SHOULD_AUTOBATCH]; shouldNotifyAtEndOfTick = !notifying; if (shouldNotifyAtEndOfTick) { if (!notificationQueued) { notificationQueued = true; queueCallback(notifyListeners); } } return store.dispatch(action); } finally { notifying = true; } } }); }; // src/getDefaultEnhancers.ts var buildGetDefaultEnhancers = (middlewareEnhancer) => function getDefaultEnhancers(options) { const { autoBatch = true } = options ?? {}; let enhancerArray = new Tuple(middlewareEnhancer); if (autoBatch) { enhancerArray.push(autoBatchEnhancer(typeof autoBatch === "object" ? autoBatch : void 0)); } return enhancerArray; }; // src/configureStore.ts function configureStore(options) { const getDefaultMiddleware = buildGetDefaultMiddleware(); const { reducer = void 0, middleware, devTools = true, duplicateMiddlewareCheck = true, preloadedState = void 0, enhancers = void 0 } = options || {}; let rootReducer; if (typeof reducer === "function") { rootReducer = reducer; } else if ((0,redux__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(reducer)) { rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers)(reducer); } else { throw new Error( false ? 0 : "`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers"); } if ( true && middleware && typeof middleware !== "function") { throw new Error( false ? 0 : "`middleware` field must be a callback"); } let finalMiddleware; if (typeof middleware === "function") { finalMiddleware = middleware(getDefaultMiddleware); if ( true && !Array.isArray(finalMiddleware)) { throw new Error( false ? 0 : "when using a middleware builder function, an array of middleware must be returned"); } } else { finalMiddleware = getDefaultMiddleware(); } if ( true && finalMiddleware.some((item) => typeof item !== "function")) { throw new Error( false ? 0 : "each middleware provided to configureStore must be a function"); } if ( true && duplicateMiddlewareCheck) { let middlewareReferences = /* @__PURE__ */ new Set(); finalMiddleware.forEach((middleware2) => { if (middlewareReferences.has(middleware2)) { throw new Error( false ? 0 : "Duplicate middleware references found when creating the store. Ensure that each middleware is only included once."); } middlewareReferences.add(middleware2); }); } let finalCompose = redux__WEBPACK_IMPORTED_MODULE_0__.compose; if (devTools) { finalCompose = composeWithDevTools({ // Enable capture of stack traces for dispatched Redux actions trace: "development" !== "production", ...typeof devTools === "object" && devTools }); } const middlewareEnhancer = (0,redux__WEBPACK_IMPORTED_MODULE_0__.applyMiddleware)(...finalMiddleware); const getDefaultEnhancers = buildGetDefaultEnhancers(middlewareEnhancer); if ( true && enhancers && typeof enhancers !== "function") { throw new Error( false ? 0 : "`enhancers` field must be a callback"); } let storeEnhancers = typeof enhancers === "function" ? enhancers(getDefaultEnhancers) : getDefaultEnhancers(); if ( true && !Array.isArray(storeEnhancers)) { throw new Error( false ? 0 : "`enhancers` callback must return an array"); } if ( true && storeEnhancers.some((item) => typeof item !== "function")) { throw new Error( false ? 0 : "each enhancer provided to configureStore must be a function"); } if ( true && finalMiddleware.length && !storeEnhancers.includes(middlewareEnhancer)) { console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`"); } const composedEnhancer = finalCompose(...storeEnhancers); return (0,redux__WEBPACK_IMPORTED_MODULE_0__.createStore)(rootReducer, preloadedState, composedEnhancer); } // src/mapBuilders.ts function executeReducerBuilderCallback(builderCallback) { const actionsMap = {}; const actionMatchers = []; let defaultCaseReducer; const builder = { addCase(typeOrActionCreator, reducer) { if (true) { if (actionMatchers.length > 0) { throw new Error( false ? 0 : "`builder.addCase` should only be called before calling `builder.addMatcher`"); } if (defaultCaseReducer) { throw new Error( false ? 0 : "`builder.addCase` should only be called before calling `builder.addDefaultCase`"); } } const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type; if (!type) { throw new Error( false ? 0 : "`builder.addCase` cannot be called with an empty action type"); } if (type in actionsMap) { throw new Error( false ? 0 : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`); } actionsMap[type] = reducer; return builder; }, addAsyncThunk(asyncThunk, reducers) { if (true) { if (defaultCaseReducer) { throw new Error( false ? 0 : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`"); } } if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending; if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected; if (reducers.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers.fulfilled; if (reducers.settled) actionMatchers.push({ matcher: asyncThunk.settled, reducer: reducers.settled }); return builder; }, addMatcher(matcher, reducer) { if (true) { if (defaultCaseReducer) { throw new Error( false ? 0 : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`"); } } actionMatchers.push({ matcher, reducer }); return builder; }, addDefaultCase(reducer) { if (true) { if (defaultCaseReducer) { throw new Error( false ? 0 : "`builder.addDefaultCase` can only be called once"); } } defaultCaseReducer = reducer; return builder; } }; builderCallback(builder); return [actionsMap, actionMatchers, defaultCaseReducer]; } // src/createReducer.ts function isStateFunction(x) { return typeof x === "function"; } function createReducer(initialState, mapOrBuilderCallback) { if (true) { if (typeof mapOrBuilderCallback === "object") { throw new Error( false ? 0 : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer"); } } let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback); let getInitialState; if (isStateFunction(initialState)) { getInitialState = () => freezeDraftable(initialState()); } else { const frozenInitialState = freezeDraftable(initialState); getInitialState = () => frozenInitialState; } function reducer(state = getInitialState(), action) { let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({ matcher }) => matcher(action)).map(({ reducer: reducer2 }) => reducer2)]; if (caseReducers.filter((cr) => !!cr).length === 0) { caseReducers = [finalDefaultCaseReducer]; } return caseReducers.reduce((previousState, caseReducer) => { if (caseReducer) { if ((0,immer__WEBPACK_IMPORTED_MODULE_1__.isDraft)(previousState)) { const draft = previousState; const result = caseReducer(draft, action); if (result === void 0) { return previousState; } return result; } else if (!(0,immer__WEBPACK_IMPORTED_MODULE_1__.isDraftable)(previousState)) { const result = caseReducer(previousState, action); if (result === void 0) { if (previousState === null) { return previousState; } throw Error("A case reducer on a non-draftable value must not return undefined"); } return result; } else { return (0,immer__WEBPACK_IMPORTED_MODULE_1__.produce)(previousState, (draft) => { return caseReducer(draft, action); }); } } return previousState; }, state); } reducer.getInitialState = getInitialState; return reducer; } // src/matchers.ts var matches = (matcher, action) => { if (hasMatchFunction(matcher)) { return matcher.match(action); } else { return matcher(action); } }; function isAnyOf(...matchers) { return (action) => { return matchers.some((matcher) => matches(matcher, action)); }; } function isAllOf(...matchers) { return (action) => { return matchers.every((matcher) => matches(matcher, action)); }; } function hasExpectedRequestMetadata(action, validStatus) { if (!action || !action.meta) return false; const hasValidRequestId = typeof action.meta.requestId === "string"; const hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1; return hasValidRequestId && hasValidRequestStatus; } function isAsyncThunkArray(a) { return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0]; } function isPending(...asyncThunks) { if (asyncThunks.length === 0) { return (action) => hasExpectedRequestMetadata(action, ["pending"]); } if (!isAsyncThunkArray(asyncThunks)) { return isPending()(asyncThunks[0]); } return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.pending)); } function isRejected(...asyncThunks) { if (asyncThunks.length === 0) { return (action) => hasExpectedRequestMetadata(action, ["rejected"]); } if (!isAsyncThunkArray(asyncThunks)) { return isRejected()(asyncThunks[0]); } return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.rejected)); } function isRejectedWithValue(...asyncThunks) { const hasFlag = (action) => { return action && action.meta && action.meta.rejectedWithValue; }; if (asyncThunks.length === 0) { return isAllOf(isRejected(...asyncThunks), hasFlag); } if (!isAsyncThunkArray(asyncThunks)) { return isRejectedWithValue()(asyncThunks[0]); } return isAllOf(isRejected(...asyncThunks), hasFlag); } function isFulfilled(...asyncThunks) { if (asyncThunks.length === 0) { return (action) => hasExpectedRequestMetadata(action, ["fulfilled"]); } if (!isAsyncThunkArray(asyncThunks)) { return isFulfilled()(asyncThunks[0]); } return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.fulfilled)); } function isAsyncThunkAction(...asyncThunks) { if (asyncThunks.length === 0) { return (action) => hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); } if (!isAsyncThunkArray(asyncThunks)) { return isAsyncThunkAction()(asyncThunks[0]); } return isAnyOf(...asyncThunks.flatMap((asyncThunk) => [asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled])); } // src/nanoid.ts var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"; var nanoid = (size = 21) => { let id = ""; let i = size; while (i--) { id += urlAlphabet[Math.random() * 64 | 0]; } return id; }; // src/createAsyncThunk.ts var commonProperties = ["name", "message", "stack", "code"]; var RejectWithValue = class { constructor(payload, meta) { this.payload = payload; this.meta = meta; } /* type-only property to distinguish between RejectWithValue and FulfillWithMeta does not exist at runtime */ _type; }; var FulfillWithMeta = class { constructor(payload, meta) { this.payload = payload; this.meta = meta; } /* type-only property to distinguish between RejectWithValue and FulfillWithMeta does not exist at runtime */ _type; }; var miniSerializeError = (value) => { if (typeof value === "object" && value !== null) { const simpleError = {}; for (const property of commonProperties) { if (typeof value[property] === "string") { simpleError[property] = value[property]; } } return simpleError; } return { message: String(value) }; }; var externalAbortMessage = "External signal was aborted"; var createAsyncThunk = /* @__PURE__ */ (() => { function createAsyncThunk2(typePrefix, payloadCreator, options) { const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({ payload, meta: { ...meta || {}, arg, requestId, requestStatus: "fulfilled" } })); const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({ payload: void 0, meta: { ...meta || {}, arg, requestId, requestStatus: "pending" } })); const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({ payload, error: (options && options.serializeError || miniSerializeError)(error || "Rejected"), meta: { ...meta || {}, arg, requestId, rejectedWithValue: !!payload, requestStatus: "rejected", aborted: error?.name === "AbortError", condition: error?.name === "ConditionError" } })); function actionCreator(arg, { signal } = {}) { return (dispatch, getState, extra) => { const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid(); const abortController = new AbortController(); let abortHandler; let abortReason; function abort(reason) { abortReason = reason; abortController.abort(); } if (signal) { if (signal.aborted) { abort(externalAbortMessage); } else { signal.addEventListener("abort", () => abort(externalAbortMessage), { once: true }); } } const promise = async function() { let finalAction; try { let conditionResult = options?.condition?.(arg, { getState, extra }); if (isThenable(conditionResult)) { conditionResult = await conditionResult; } if (conditionResult === false || abortController.signal.aborted) { throw { name: "ConditionError", message: "Aborted due to condition callback returning false." }; } const abortedPromise = new Promise((_, reject) => { abortHandler = () => { reject({ name: "AbortError", message: abortReason || "Aborted" }); }; abortController.signal.addEventListener("abort", abortHandler); }); dispatch(pending(requestId, arg, options?.getPendingMeta?.({ requestId, arg }, { getState, extra }))); finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, { dispatch, getState, extra, requestId, signal: abortController.signal, abort, rejectWithValue: (value, meta) => { return new RejectWithValue(value, meta); }, fulfillWithValue: (value, meta) => { return new FulfillWithMeta(value, meta); } })).then((result) => { if (result instanceof RejectWithValue) { throw result; } if (result instanceof FulfillWithMeta) { return fulfilled(result.payload, requestId, arg, result.meta); } return fulfilled(result, requestId, arg); })]); } catch (err) { finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg); } finally { if (abortHandler) { abortController.signal.removeEventListener("abort", abortHandler); } } const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition; if (!skipDispatch) { dispatch(finalAction); } return finalAction; }(); return Object.assign(promise, { abort, requestId, arg, unwrap() { return promise.then(unwrapResult); } }); }; } return Object.assign(actionCreator, { pending, rejected, fulfilled, settled: isAnyOf(rejected, fulfilled), typePrefix }); } createAsyncThunk2.withTypes = () => createAsyncThunk2; return createAsyncThunk2; })(); function unwrapResult(action) { if (action.meta && action.meta.rejectedWithValue) { throw action.payload; } if (action.error) { throw action.error; } return action.payload; } function isThenable(value) { return value !== null && typeof value === "object" && typeof value.then === "function"; } // src/createSlice.ts var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk"); var asyncThunkCreator = { [asyncThunkSymbol]: createAsyncThunk }; var ReducerType = /* @__PURE__ */ ((ReducerType2) => { ReducerType2["reducer"] = "reducer"; ReducerType2["reducerWithPrepare"] = "reducerWithPrepare"; ReducerType2["asyncThunk"] = "asyncThunk"; return ReducerType2; })(ReducerType || {}); function getType(slice, actionKey) { return `${slice}/${actionKey}`; } function buildCreateSlice({ creators } = {}) { const cAT = creators?.asyncThunk?.[asyncThunkSymbol]; return function createSlice2(options) { const { name, reducerPath = name } = options; if (!name) { throw new Error( false ? 0 : "`name` is a required option for createSlice"); } if (typeof process !== "undefined" && "development" === "development") { if (options.initialState === void 0) { console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`"); } } const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {}; const reducerNames = Object.keys(reducers); const context = { sliceCaseReducersByName: {}, sliceCaseReducersByType: {}, actionCreators: {}, sliceMatchers: [] }; const contextMethods = { addCase(typeOrActionCreator, reducer2) { const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type; if (!type) { throw new Error( false ? 0 : "`context.addCase` cannot be called with an empty action type"); } if (type in context.sliceCaseReducersByType) { throw new Error( false ? 0 : "`context.addCase` cannot be called with two reducers for the same action type: " + type); } context.sliceCaseReducersByType[type] = reducer2; return contextMethods; }, addMatcher(matcher, reducer2) { context.sliceMatchers.push({ matcher, reducer: reducer2 }); return contextMethods; }, exposeAction(name2, actionCreator) { context.actionCreators[name2] = actionCreator; return contextMethods; }, exposeCaseReducer(name2, reducer2) { context.sliceCaseReducersByName[name2] = reducer2; return contextMethods; } }; reducerNames.forEach((reducerName) => { const reducerDefinition = reducers[reducerName]; const reducerDetails = { reducerName, type: getType(name, reducerName), createNotation: typeof options.reducers === "function" }; if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) { handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT); } else { handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods); } }); function buildReducer() { if (true) { if (typeof options.extraReducers === "object") { throw new Error( false ? 0 : "The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice"); } } const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers]; const finalCaseReducers = { ...extraReducers, ...context.sliceCaseReducersByType }; return createReducer(options.initialState, (builder) => { for (let key in finalCaseReducers) { builder.addCase(key, finalCaseReducers[key]); } for (let sM of context.sliceMatchers) { builder.addMatcher(sM.matcher, sM.reducer); } for (let m of actionMatchers) { builder.addMatcher(m.matcher, m.reducer); } if (defaultCaseReducer) { builder.addDefaultCase(defaultCaseReducer); } }); } const selectSelf = (state) => state; const injectedSelectorCache = /* @__PURE__ */ new Map(); const injectedStateCache = /* @__PURE__ */ new WeakMap(); let _reducer; function reducer(state, action) { if (!_reducer) _reducer = buildReducer(); return _reducer(state, action); } function getInitialState() { if (!_reducer) _reducer = buildReducer(); return _reducer.getInitialState(); } function makeSelectorProps(reducerPath2, injected = false) { function selectSlice(state) { let sliceState = state[reducerPath2]; if (typeof sliceState === "undefined") { if (injected) { sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState); } else if (true) { throw new Error( false ? 0 : "selectSlice returned undefined for an uninjected slice reducer"); } } return sliceState; } function getSelectors(selectState = selectSelf) { const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap()); return getOrInsertComputed(selectorCache, selectState, () => { const map = {}; for (const [name2, selector] of Object.entries(options.selectors ?? {})) { map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected); } return map; }); } return { reducerPath: reducerPath2, getSelectors, get selectors() { return getSelectors(selectSlice); }, selectSlice }; } const slice = { name, reducer, actions: context.actionCreators, caseReducers: context.sliceCaseReducersByName, getInitialState, ...makeSelectorProps(reducerPath), injectInto(injectable, { reducerPath: pathOpt, ...config } = {}) { const newReducerPath = pathOpt ?? reducerPath; injectable.inject({ reducerPath: newReducerPath, reducer }, config); return { ...slice, ...makeSelectorProps(newReducerPath, true) }; } }; return slice; }; } function wrapSelector(selector, selectState, getInitialState, injected) { function wrapper(rootState, ...args) { let sliceState = selectState(rootState); if (typeof sliceState === "undefined") { if (injected) { sliceState = getInitialState(); } else if (true) { throw new Error( false ? 0 : "selectState returned undefined for an uninjected slice reducer"); } } return selector(sliceState, ...args); } wrapper.unwrapped = selector; return wrapper; } var createSlice = /* @__PURE__ */ buildCreateSlice(); function buildReducerCreators() { function asyncThunk(payloadCreator, config) { return { _reducerDefinitionType: "asyncThunk" /* asyncThunk */, payloadCreator, ...config }; } asyncThunk.withTypes = () => asyncThunk; return { reducer(caseReducer) { return Object.assign({ // hack so the wrapping function has the same name as the original // we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original [caseReducer.name](...args) { return caseReducer(...args); } }[caseReducer.name], { _reducerDefinitionType: "reducer" /* reducer */ }); }, preparedReducer(prepare, reducer) { return { _reducerDefinitionType: "reducerWithPrepare" /* reducerWithPrepare */, prepare, reducer }; }, asyncThunk }; } function handleNormalReducerDefinition({ type, reducerName, createNotation }, maybeReducerWithPrepare, context) { let caseReducer; let prepareCallback; if ("reducer" in maybeReducerWithPrepare) { if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) { throw new Error( false ? 0 : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation."); } caseReducer = maybeReducerWithPrepare.reducer; prepareCallback = maybeReducerWithPrepare.prepare; } else { caseReducer = maybeReducerWithPrepare; } context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type)); } function isAsyncThunkSliceReducerDefinition(reducerDefinition) { return reducerDefinition._reducerDefinitionType === "asyncThunk" /* asyncThunk */; } function isCaseReducerWithPrepareDefinition(reducerDefinition) { return reducerDefinition._reducerDefinitionType === "reducerWithPrepare" /* reducerWithPrepare */; } function handleThunkCaseReducerDefinition({ type, reducerName }, reducerDefinition, context, cAT) { if (!cAT) { throw new Error( false ? 0 : "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`."); } const { payloadCreator, fulfilled, pending, rejected, settled, options } = reducerDefinition; const thunk = cAT(type, payloadCreator, options); context.exposeAction(reducerName, thunk); if (fulfilled) { context.addCase(thunk.fulfilled, fulfilled); } if (pending) { context.addCase(thunk.pending, pending); } if (rejected) { context.addCase(thunk.rejected, rejected); } if (settled) { context.addMatcher(thunk.settled, settled); } context.exposeCaseReducer(reducerName, { fulfilled: fulfilled || noop, pending: pending || noop, rejected: rejected || noop, settled: settled || noop }); } function noop() { } // src/entities/entity_state.ts function getInitialEntityState() { return { ids: [], entities: {} }; } function createInitialStateFactory(stateAdapter) { function getInitialState(additionalState = {}, entities) { const state = Object.assign(getInitialEntityState(), additionalState); return entities ? stateAdapter.setAll(state, entities) : state; } return { getInitialState }; } // src/entities/state_selectors.ts function createSelectorsFactory() { function getSelectors(selectState, options = {}) { const { createSelector: createSelector2 = createDraftSafeSelector } = options; const selectIds = (state) => state.ids; const selectEntities = (state) => state.entities; const selectAll = createSelector2(selectIds, selectEntities, (ids, entities) => ids.map((id) => entities[id])); const selectId = (_, id) => id; const selectById = (entities, id) => entities[id]; const selectTotal = createSelector2(selectIds, (ids) => ids.length); if (!selectState) { return { selectIds, selectEntities, selectAll, selectTotal, selectById: createSelector2(selectEntities, selectId, selectById) }; } const selectGlobalizedEntities = createSelector2(selectState, selectEntities); return { selectIds: createSelector2(selectState, selectIds), selectEntities: selectGlobalizedEntities, selectAll: createSelector2(selectState, selectAll), selectTotal: createSelector2(selectState, selectTotal), selectById: createSelector2(selectGlobalizedEntities, selectId, selectById) }; } return { getSelectors }; } // src/entities/state_adapter.ts var isDraftTyped = immer__WEBPACK_IMPORTED_MODULE_1__.isDraft; function createSingleArgumentStateOperator(mutator) { const operator = createStateOperator((_, state) => mutator(state)); return function operation(state) { return operator(state, void 0); }; } function createStateOperator(mutator) { return function operation(state, arg) { function isPayloadActionArgument(arg2) { return isFSA(arg2); } const runMutator = (draft) => { if (isPayloadActionArgument(arg)) { mutator(arg.payload, draft); } else { mutator(arg, draft); } }; if (isDraftTyped(state)) { runMutator(state); return state; } return (0,immer__WEBPACK_IMPORTED_MODULE_1__.produce)(state, runMutator); }; } // src/entities/utils.ts function selectIdValue(entity, selectId) { const key = selectId(entity); if ( true && key === void 0) { console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString()); } return key; } function ensureEntitiesArray(entities) { if (!Array.isArray(entities)) { entities = Object.values(entities); } return entities; } function getCurrent(value) { return (0,immer__WEBPACK_IMPORTED_MODULE_1__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_1__.current)(value) : value; } function splitAddedUpdatedEntities(newEntities, selectId, state) { newEntities = ensureEntitiesArray(newEntities); const existingIdsArray = getCurrent(state.ids); const existingIds = new Set(existingIdsArray); const added = []; const addedIds = /* @__PURE__ */ new Set([]); const updated = []; for (const entity of newEntities) { const id = selectIdValue(entity, selectId); if (existingIds.has(id) || addedIds.has(id)) { updated.push({ id, changes: entity }); } else { addedIds.add(id); added.push(entity); } } return [added, updated, existingIdsArray]; } // src/entities/unsorted_state_adapter.ts function createUnsortedStateAdapter(selectId) { function addOneMutably(entity, state) { const key = selectIdValue(entity, selectId); if (key in state.entities) { return; } state.ids.push(key); state.entities[key] = entity; } function addManyMutably(newEntities, state) { newEntities = ensureEntitiesArray(newEntities); for (const entity of newEntities) { addOneMutably(entity, state); } } function setOneMutably(entity, state) { const key = selectIdValue(entity, selectId); if (!(key in state.entities)) { state.ids.push(key); } ; state.entities[key] = entity; } function setManyMutably(newEntities, state) { newEntities = ensureEntitiesArray(newEntities); for (const entity of newEntities) { setOneMutably(entity, state); } } function setAllMutably(newEntities, state) { newEntities = ensureEntitiesArray(newEntities); state.ids = []; state.entities = {}; addManyMutably(newEntities, state); } function removeOneMutably(key, state) { return removeManyMutably([key], state); } function removeManyMutably(keys, state) { let didMutate = false; keys.forEach((key) => { if (key in state.entities) { delete state.entities[key]; didMutate = true; } }); if (didMutate) { state.ids = state.ids.filter((id) => id in state.entities); } } function removeAllMutably(state) { Object.assign(state, { ids: [], entities: {} }); } function takeNewKey(keys, update, state) { const original3 = state.entities[update.id]; if (original3 === void 0) { return false; } const updated = Object.assign({}, original3, update.changes); const newKey = selectIdValue(updated, selectId); const hasNewKey = newKey !== update.id; if (hasNewKey) { keys[update.id] = newKey; delete state.entities[update.id]; } ; state.entities[newKey] = updated; return hasNewKey; } function updateOneMutably(update, state) { return updateManyMutably([update], state); } function updateManyMutably(updates, state) { const newKeys = {}; const updatesPerEntity = {}; updates.forEach((update) => { if (update.id in state.entities) { updatesPerEntity[update.id] = { id: update.id, // Spreads ignore falsy values, so this works even if there isn't // an existing update already at this key changes: { ...updatesPerEntity[update.id]?.changes, ...update.changes } }; } }); updates = Object.values(updatesPerEntity); const didMutateEntities = updates.length > 0; if (didMutateEntities) { const didMutateIds = updates.filter((update) => takeNewKey(newKeys, update, state)).length > 0; if (didMutateIds) { state.ids = Object.values(state.entities).map((e) => selectIdValue(e, selectId)); } } } function upsertOneMutably(entity, state) { return upsertManyMutably([entity], state); } function upsertManyMutably(newEntities, state) { const [added, updated] = splitAddedUpdatedEntities(newEntities, selectId, state); addManyMutably(added, state); updateManyMutably(updated, state); } return { removeAll: createSingleArgumentStateOperator(removeAllMutably), addOne: createStateOperator(addOneMutably), addMany: createStateOperator(addManyMutably), setOne: createStateOperator(setOneMutably), setMany: createStateOperator(setManyMutably), setAll: createStateOperator(setAllMutably), updateOne: createStateOperator(updateOneMutably), updateMany: createStateOperator(updateManyMutably), upsertOne: createStateOperator(upsertOneMutably), upsertMany: createStateOperator(upsertManyMutably), removeOne: createStateOperator(removeOneMutably), removeMany: createStateOperator(removeManyMutably) }; } // src/entities/sorted_state_adapter.ts function findInsertIndex(sortedItems, item, comparisonFunction) { let lowIndex = 0; let highIndex = sortedItems.length; while (lowIndex < highIndex) { let middleIndex = lowIndex + highIndex >>> 1; const currentItem = sortedItems[middleIndex]; const res = comparisonFunction(item, currentItem); if (res >= 0) { lowIndex = middleIndex + 1; } else { highIndex = middleIndex; } } return lowIndex; } function insert(sortedItems, item, comparisonFunction) { const insertAtIndex = findInsertIndex(sortedItems, item, comparisonFunction); sortedItems.splice(insertAtIndex, 0, item); return sortedItems; } function createSortedStateAdapter(selectId, comparer) { const { removeOne, removeMany, removeAll } = createUnsortedStateAdapter(selectId); function addOneMutably(entity, state) { return addManyMutably([entity], state); } function addManyMutably(newEntities, state, existingIds) { newEntities = ensureEntitiesArray(newEntities); const existingKeys = new Set(existingIds ?? getCurrent(state.ids)); const addedKeys = /* @__PURE__ */ new Set(); const models = newEntities.filter((model) => { const modelId = selectIdValue(model, selectId); const notAdded = !addedKeys.has(modelId); if (notAdded) addedKeys.add(modelId); return !existingKeys.has(modelId) && notAdded; }); if (models.length !== 0) { mergeFunction(state, models); } } function setOneMutably(entity, state) { return setManyMutably([entity], state); } function setManyMutably(newEntities, state) { let deduplicatedEntities = {}; newEntities = ensureEntitiesArray(newEntities); if (newEntities.length !== 0) { for (const item of newEntities) { const entityId = selectId(item); deduplicatedEntities[entityId] = item; delete state.entities[entityId]; } newEntities = ensureEntitiesArray(deduplicatedEntities); mergeFunction(state, newEntities); } } function setAllMutably(newEntities, state) { newEntities = ensureEntitiesArray(newEntities); state.entities = {}; state.ids = []; addManyMutably(newEntities, state, []); } function updateOneMutably(update, state) { return updateManyMutably([update], state); } function updateManyMutably(updates, state) { let appliedUpdates = false; let replacedIds = false; for (let update of updates) { const entity = state.entities[update.id]; if (!entity) { continue; } appliedUpdates = true; Object.assign(entity, update.changes); const newId = selectId(entity); if (update.id !== newId) { replacedIds = true; delete state.entities[update.id]; const oldIndex = state.ids.indexOf(update.id); state.ids[oldIndex] = newId; state.entities[newId] = entity; } } if (appliedUpdates) { mergeFunction(state, [], appliedUpdates, replacedIds); } } function upsertOneMutably(entity, state) { return upsertManyMutably([entity], state); } function upsertManyMutably(newEntities, state) { const [added, updated, existingIdsArray] = splitAddedUpdatedEntities(newEntities, selectId, state); if (added.length) { addManyMutably(added, state, existingIdsArray); } if (updated.length) { updateManyMutably(updated, state); } } function areArraysEqual(a, b) { if (a.length !== b.length) { return false; } for (let i = 0; i < a.length; i++) { if (a[i] === b[i]) { continue; } return false; } return true; } const mergeFunction = (state, addedItems, appliedUpdates, replacedIds) => { const currentEntities = getCurrent(state.entities); const currentIds = getCurrent(state.ids); const stateEntities = state.entities; let ids = currentIds; if (replacedIds) { ids = new Set(currentIds); } let sortedEntities = []; for (const id of ids) { const entity = currentEntities[id]; if (entity) { sortedEntities.push(entity); } } const wasPreviouslyEmpty = sortedEntities.length === 0; for (const item of addedItems) { stateEntities[selectId(item)] = item; if (!wasPreviouslyEmpty) { insert(sortedEntities, item, comparer); } } if (wasPreviouslyEmpty) { sortedEntities = addedItems.slice().sort(comparer); } else if (appliedUpdates) { sortedEntities.sort(comparer); } const newSortedIds = sortedEntities.map(selectId); if (!areArraysEqual(currentIds, newSortedIds)) { state.ids = newSortedIds; } }; return { removeOne, removeMany, removeAll, addOne: createStateOperator(addOneMutably), updateOne: createStateOperator(updateOneMutably), upsertOne: createStateOperator(upsertOneMutably), setOne: createStateOperator(setOneMutably), setMany: createStateOperator(setManyMutably), setAll: createStateOperator(setAllMutably), addMany: createStateOperator(addManyMutably), updateMany: createStateOperator(updateManyMutably), upsertMany: createStateOperator(upsertManyMutably) }; } // src/entities/create_adapter.ts function createEntityAdapter(options = {}) { const { selectId, sortComparer } = { sortComparer: false, selectId: (instance) => instance.id, ...options }; const stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId); const stateFactory = createInitialStateFactory(stateAdapter); const selectorsFactory = createSelectorsFactory(); return { selectId, sortComparer, ...stateFactory, ...selectorsFactory, ...stateAdapter }; } // src/listenerMiddleware/exceptions.ts var task = "task"; var listener = "listener"; var completed = "completed"; var cancelled = "cancelled"; var taskCancelled = `task-${cancelled}`; var taskCompleted = `task-${completed}`; var listenerCancelled = `${listener}-${cancelled}`; var listenerCompleted = `${listener}-${completed}`; var TaskAbortError = class { constructor(code) { this.code = code; this.message = `${task} ${cancelled} (reason: ${code})`; } name = "TaskAbortError"; message; }; // src/listenerMiddleware/utils.ts var assertFunction = (func, expected) => { if (typeof func !== "function") { throw new TypeError( false ? 0 : `${expected} is not a function`); } }; var noop2 = () => { }; var catchRejection = (promise, onError = noop2) => { promise.catch(onError); return promise; }; var addAbortSignalListener = (abortSignal, callback) => { abortSignal.addEventListener("abort", callback, { once: true }); return () => abortSignal.removeEventListener("abort", callback); }; var abortControllerWithReason = (abortController, reason) => { const signal = abortController.signal; if (signal.aborted) { return; } if (!("reason" in signal)) { Object.defineProperty(signal, "reason", { enumerable: true, value: reason, configurable: true, writable: true }); } ; abortController.abort(reason); }; // src/listenerMiddleware/task.ts var validateActive = (signal) => { if (signal.aborted) { const { reason } = signal; throw new TaskAbortError(reason); } }; function raceWithSignal(signal, promise) { let cleanup = noop2; return new Promise((resolve, reject) => { const notifyRejection = () => reject(new TaskAbortError(signal.reason)); if (signal.aborted) { notifyRejection(); return; } cleanup = addAbortSignalListener(signal, notifyRejection); promise.finally(() => cleanup()).then(resolve, reject); }).finally(() => { cleanup = noop2; }); } var runTask = async (task2, cleanUp) => { try { await Promise.resolve(); const value = await task2(); return { status: "ok", value }; } catch (error) { return { status: error instanceof TaskAbortError ? "cancelled" : "rejected", error }; } finally { cleanUp?.(); } }; var createPause = (signal) => { return (promise) => { return catchRejection(raceWithSignal(signal, promise).then((output) => { validateActive(signal); return output; })); }; }; var createDelay = (signal) => { const pause = createPause(signal); return (timeoutMs) => { return pause(new Promise((resolve) => setTimeout(resolve, timeoutMs))); }; }; // src/listenerMiddleware/index.ts var { assign } = Object; var INTERNAL_NIL_TOKEN = {}; var alm = "listenerMiddleware"; var createFork = (parentAbortSignal, parentBlockingPromises) => { const linkControllers = (controller) => addAbortSignalListener(parentAbortSignal, () => abortControllerWithReason(controller, parentAbortSignal.reason)); return (taskExecutor, opts) => { assertFunction(taskExecutor, "taskExecutor"); const childAbortController = new AbortController(); linkControllers(childAbortController); const result = runTask(async () => { validateActive(parentAbortSignal); validateActive(childAbortController.signal); const result2 = await taskExecutor({ pause: createPause(childAbortController.signal), delay: createDelay(childAbortController.signal), signal: childAbortController.signal }); validateActive(childAbortController.signal); return result2; }, () => abortControllerWithReason(childAbortController, taskCompleted)); if (opts?.autoJoin) { parentBlockingPromises.push(result.catch(noop2)); } return { result: createPause(parentAbortSignal)(result), cancel() { abortControllerWithReason(childAbortController, taskCancelled); } }; }; }; var createTakePattern = (startListening, signal) => { const take = async (predicate, timeout) => { validateActive(signal); let unsubscribe = () => { }; const tuplePromise = new Promise((resolve, reject) => { let stopListening = startListening({ predicate, effect: (action, listenerApi) => { listenerApi.unsubscribe(); resolve([action, listenerApi.getState(), listenerApi.getOriginalState()]); } }); unsubscribe = () => { stopListening(); reject(); }; }); const promises = [tuplePromise]; if (timeout != null) { promises.push(new Promise((resolve) => setTimeout(resolve, timeout, null))); } try { const output = await raceWithSignal(signal, Promise.race(promises)); validateActive(signal); return output; } finally { unsubscribe(); } }; return (predicate, timeout) => catchRejection(take(predicate, timeout)); }; var getListenerEntryPropsFrom = (options) => { let { type, actionCreator, matcher, predicate, effect } = options; if (type) { predicate = createAction(type).match; } else if (actionCreator) { type = actionCreator.type; predicate = actionCreator.match; } else if (matcher) { predicate = matcher; } else if (predicate) { } else { throw new Error( false ? 0 : "Creating or removing a listener requires one of the known fields for matching an action"); } assertFunction(effect, "options.listener"); return { predicate, type, effect }; }; var createListenerEntry = /* @__PURE__ */ assign((options) => { const { type, predicate, effect } = getListenerEntryPropsFrom(options); const entry = { id: nanoid(), effect, type, predicate, pending: /* @__PURE__ */ new Set(), unsubscribe: () => { throw new Error( false ? 0 : "Unsubscribe not initialized"); } }; return entry; }, { withTypes: () => createListenerEntry }); var findListenerEntry = (listenerMap, options) => { const { type, effect, predicate } = getListenerEntryPropsFrom(options); return Array.from(listenerMap.values()).find((entry) => { const matchPredicateOrType = typeof type === "string" ? entry.type === type : entry.predicate === predicate; return matchPredicateOrType && entry.effect === effect; }); }; var cancelActiveListeners = (entry) => { entry.pending.forEach((controller) => { abortControllerWithReason(controller, listenerCancelled); }); }; var createClearListenerMiddleware = (listenerMap, executingListeners) => { return () => { for (const listener2 of executingListeners.keys()) { cancelActiveListeners(listener2); } listenerMap.clear(); }; }; var safelyNotifyError = (errorHandler, errorToNotify, errorInfo) => { try { errorHandler(errorToNotify, errorInfo); } catch (errorHandlerError) { setTimeout(() => { throw errorHandlerError; }, 0); } }; var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), { withTypes: () => addListener }); var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`); var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), { withTypes: () => removeListener }); var defaultErrorHandler = (...args) => { console.error(`${alm}/error`, ...args); }; var createListenerMiddleware = (middlewareOptions = {}) => { const listenerMap = /* @__PURE__ */ new Map(); const executingListeners = /* @__PURE__ */ new Map(); const trackExecutingListener = (entry) => { const count = executingListeners.get(entry) ?? 0; executingListeners.set(entry, count + 1); }; const untrackExecutingListener = (entry) => { const count = executingListeners.get(entry) ?? 1; if (count === 1) { executingListeners.delete(entry); } else { executingListeners.set(entry, count - 1); } }; const { extra, onError = defaultErrorHandler } = middlewareOptions; assertFunction(onError, "onError"); const insertEntry = (entry) => { entry.unsubscribe = () => listenerMap.delete(entry.id); listenerMap.set(entry.id, entry); return (cancelOptions) => { entry.unsubscribe(); if (cancelOptions?.cancelActive) { cancelActiveListeners(entry); } }; }; const startListening = (options) => { const entry = findListenerEntry(listenerMap, options) ?? createListenerEntry(options); return insertEntry(entry); }; assign(startListening, { withTypes: () => startListening }); const stopListening = (options) => { const entry = findListenerEntry(listenerMap, options); if (entry) { entry.unsubscribe(); if (options.cancelActive) { cancelActiveListeners(entry); } } return !!entry; }; assign(stopListening, { withTypes: () => stopListening }); const notifyListener = async (entry, action, api, getOriginalState) => { const internalTaskController = new AbortController(); const take = createTakePattern(startListening, internalTaskController.signal); const autoJoinPromises = []; try { entry.pending.add(internalTaskController); trackExecutingListener(entry); await Promise.resolve(entry.effect( action, // Use assign() rather than ... to avoid extra helper functions added to bundle assign({}, api, { getOriginalState, condition: (predicate, timeout) => take(predicate, timeout).then(Boolean), take, delay: createDelay(internalTaskController.signal), pause: createPause(internalTaskController.signal), extra, signal: internalTaskController.signal, fork: createFork(internalTaskController.signal, autoJoinPromises), unsubscribe: entry.unsubscribe, subscribe: () => { listenerMap.set(entry.id, entry); }, cancelActiveListeners: () => { entry.pending.forEach((controller, _, set) => { if (controller !== internalTaskController) { abortControllerWithReason(controller, listenerCancelled); set.delete(controller); } }); }, cancel: () => { abortControllerWithReason(internalTaskController, listenerCancelled); entry.pending.delete(internalTaskController); }, throwIfCancelled: () => { validateActive(internalTaskController.signal); } }) )); } catch (listenerError) { if (!(listenerError instanceof TaskAbortError)) { safelyNotifyError(onError, listenerError, { raisedBy: "effect" }); } } finally { await Promise.all(autoJoinPromises); abortControllerWithReason(internalTaskController, listenerCompleted); untrackExecutingListener(entry); entry.pending.delete(internalTaskController); } }; const clearListenerMiddleware = createClearListenerMiddleware(listenerMap, executingListeners); const middleware = (api) => (next) => (action) => { if (!(0,redux__WEBPACK_IMPORTED_MODULE_0__.isAction)(action)) { return next(action); } if (addListener.match(action)) { return startListening(action.payload); } if (clearAllListeners.match(action)) { clearListenerMiddleware(); return; } if (removeListener.match(action)) { return stopListening(action.payload); } let originalState = api.getState(); const getOriginalState = () => { if (originalState === INTERNAL_NIL_TOKEN) { throw new Error( false ? 0 : `${alm}: getOriginalState can only be called synchronously`); } return originalState; }; let result; try { result = next(action); if (listenerMap.size > 0) { const currentState = api.getState(); const listenerEntries = Array.from(listenerMap.values()); for (const entry of listenerEntries) { let runListener = false; try { runListener = entry.predicate(action, currentState, originalState); } catch (predicateError) { runListener = false; safelyNotifyError(onError, predicateError, { raisedBy: "predicate" }); } if (!runListener) { continue; } notifyListener(entry, action, api, getOriginalState); } } } finally { originalState = INTERNAL_NIL_TOKEN; } return result; }; return { middleware, startListening, stopListening, clearListeners: clearListenerMiddleware }; }; // src/dynamicMiddleware/index.ts var createMiddlewareEntry = (middleware) => ({ middleware, applied: /* @__PURE__ */ new Map() }); var matchInstance = (instanceId) => (action) => action?.meta?.instanceId === instanceId; var createDynamicMiddleware = () => { const instanceId = nanoid(); const middlewareMap = /* @__PURE__ */ new Map(); const withMiddleware = Object.assign(createAction("dynamicMiddleware/add", (...middlewares) => ({ payload: middlewares, meta: { instanceId } })), { withTypes: () => withMiddleware }); const addMiddleware = Object.assign(function addMiddleware2(...middlewares) { middlewares.forEach((middleware2) => { getOrInsertComputed(middlewareMap, middleware2, createMiddlewareEntry); }); }, { withTypes: () => addMiddleware }); const getFinalMiddleware = (api) => { const appliedMiddleware = Array.from(middlewareMap.values()).map((entry) => getOrInsertComputed(entry.applied, api, entry.middleware)); return (0,redux__WEBPACK_IMPORTED_MODULE_0__.compose)(...appliedMiddleware); }; const isWithMiddleware = isAllOf(withMiddleware, matchInstance(instanceId)); const middleware = (api) => (next) => (action) => { if (isWithMiddleware(action)) { addMiddleware(...action.payload); return api.dispatch; } return getFinalMiddleware(api)(next)(action); }; return { middleware, addMiddleware, withMiddleware, instanceId }; }; // src/combineSlices.ts var isSliceLike = (maybeSliceLike) => "reducerPath" in maybeSliceLike && typeof maybeSliceLike.reducerPath === "string"; var getReducers = (slices) => slices.flatMap((sliceOrMap) => isSliceLike(sliceOrMap) ? [[sliceOrMap.reducerPath, sliceOrMap.reducer]] : Object.entries(sliceOrMap)); var ORIGINAL_STATE = Symbol.for("rtk-state-proxy-original"); var isStateProxy = (value) => !!value && !!value[ORIGINAL_STATE]; var stateProxyMap = /* @__PURE__ */ new WeakMap(); var createStateProxy = (state, reducerMap, initialStateCache) => getOrInsertComputed(stateProxyMap, state, () => new Proxy(state, { get: (target, prop, receiver) => { if (prop === ORIGINAL_STATE) return target; const result = Reflect.get(target, prop, receiver); if (typeof result === "undefined") { const cached = initialStateCache[prop]; if (typeof cached !== "undefined") return cached; const reducer = reducerMap[prop]; if (reducer) { const reducerResult = reducer(void 0, { type: nanoid() }); if (typeof reducerResult === "undefined") { throw new Error( false ? 0 : `The slice reducer for key "${prop.toString()}" returned undefined when called for selector(). If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`); } initialStateCache[prop] = reducerResult; return reducerResult; } } return result; } })); var original = (state) => { if (!isStateProxy(state)) { throw new Error( false ? 0 : "original must be used on state Proxy"); } return state[ORIGINAL_STATE]; }; var emptyObject = {}; var noopReducer = (state = emptyObject) => state; function combineSlices(...slices) { const reducerMap = Object.fromEntries(getReducers(slices)); const getReducer = () => Object.keys(reducerMap).length ? (0,redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers)(reducerMap) : noopReducer; let reducer = getReducer(); function combinedReducer(state, action) { return reducer(state, action); } combinedReducer.withLazyLoadedSlices = () => combinedReducer; const initialStateCache = {}; const inject = (slice, config = {}) => { const { reducerPath, reducer: reducerToInject } = slice; const currentReducer = reducerMap[reducerPath]; if (!config.overrideExisting && currentReducer && currentReducer !== reducerToInject) { if (typeof process !== "undefined" && "development" === "development") { console.error(`called \`inject\` to override already-existing reducer ${reducerPath} without specifying \`overrideExisting: true\``); } return combinedReducer; } if (config.overrideExisting && currentReducer !== reducerToInject) { delete initialStateCache[reducerPath]; } reducerMap[reducerPath] = reducerToInject; reducer = getReducer(); return combinedReducer; }; const selector = Object.assign(function makeSelector(selectorFn, selectState) { return function selector2(state, ...args) { return selectorFn(createStateProxy(selectState ? selectState(state, ...args) : state, reducerMap, initialStateCache), ...args); }; }, { original }); return Object.assign(combinedReducer, { inject, selector }); } // src/formatProdErrorMessage.ts function formatProdErrorMessage(code) { return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `; } //# sourceMappingURL=redux-toolkit.modern.mjs.map /***/ }) }]); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoianMvdmVuZG9ycy1ub2RlX21vZHVsZXNfcmVkdXhqc190b29sa2l0X2Rpc3RfcmVkdXgtdG9vbGtpdF9tb2Rlcm5fbWpzLnZvbHVudGVlcmFwaS4wY2I1YTYwOTg4ZmY4ZmQxMDQwOS5idW5kbGUuan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AgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgcHJvbWlzZSA9IGFzeW5jIGZ1bmN0aW9uKCkge1xuICAgICAgICAgIGxldCBmaW5hbEFjdGlvbjtcbiAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgbGV0IGNvbmRpdGlvblJlc3VsdCA9IG9wdGlvbnM/LmNvbmRpdGlvbj8uKGFyZywge1xuICAgICAgICAgICAgICBnZXRTdGF0ZSxcbiAgICAgICAgICAgICAgZXh0cmFcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaWYgKGlzVGhlbmFibGUoY29uZGl0aW9uUmVzdWx0KSkge1xuICAgICAgICAgICAgICBjb25kaXRpb25SZXN1bHQgPSBhd2FpdCBjb25kaXRpb25SZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoY29uZGl0aW9uUmVzdWx0ID09PSBmYWxzZSB8fCBhYm9ydENvbnRyb2xsZXIuc2lnbmFsLmFib3J0ZWQpIHtcbiAgICAgICAgICAgICAgdGhyb3cge1xuICAgICAgICAgICAgICAgIG5hbWU6IFwiQ29uZGl0aW9uRXJyb3JcIixcbiAgICAgICAgICAgICAgICBtZXNzYWdlOiBcIkFib3J0ZWQgZHVlIHRvIGNvbmRpdGlvbiBjYWxsYmFjayByZXR1cm5pbmcgZmFsc2UuXCJcbiAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbnN0IGFib3J0ZWRQcm9taXNlID0gbmV3IFByb21pc2UoKF8sIHJlamVjdCkgPT4ge1xuICAgICAgICAgICAgICBhYm9ydEhhbmRsZXIgPSAoKSA9PiB7XG4gICAgICAgICAgICAgICAgcmVqZWN0KHtcbiAgICAgICAgICAgICAgICAgIG5hbWU6IFwiQWJvcnRFcnJvclwiLFxuICAgICAgICAgICAgICAgICAgbWVzc2FnZTogYWJvcnRSZWFzb24gfHwgXCJBYm9ydGVkXCJcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgYWJvcnRDb250cm9sbGVyLnNpZ25hbC5hZGRFdmVudExpc3RlbmVyKFwiYWJvcnRcIiwgYWJvcnRIYW5kbGVyKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgZGlzcGF0Y2gocGVuZGluZyhyZXF1ZXN0SWQsIGFyZywgb3B0aW9ucz8uZ2V0UGVuZGluZ01ldGE/Lih7XG4gICAgICAgICAgICAgIHJlcXVlc3RJZCxcbiAgICAgICAgICAgICAgYXJnXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgIGdldFN0YXRlLFxuICAgICAgICAgICAgICBleHRyYVxuICAgICAgICAgICAgfSkpKTtcbiAgICAgICAgICAgIGZpbmFsQWN0aW9uID0gYXdhaXQgUHJvbWlzZS5yYWNlKFthYm9ydGVkUHJvbWlzZSwgUHJvbWlzZS5yZXNvbHZlKHBheWxvYWRDcmVhdG9yKGFyZywge1xuICAgICAgICAgICAgICBkaXNwYXRjaCxcbiAgICAgICAgICAgICAgZ2V0U3RhdGUsXG4gICAgICAgICAgICAgIGV4dHJhLFxuICAgICAgICAgICAgICByZXF1ZXN0SWQsXG4gICAgICAgICAgICAgIHNpZ25hbDogYWJvcnRDb250cm9sbGVyLnNpZ25hbCxcbiAgICAgICAgICAgICAgYWJvcnQsXG4gICAgICAgICAgICAgIHJlamVjdFdpdGhWYWx1ZTogKHZhbHVlLCBtZXRhKSA9PiB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZWplY3RXaXRoVmFsdWUodmFsdWUsIG1ldGEpO1xuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICBmdWxmaWxsV2l0aFZhbHVlOiAodmFsdWUsIG1ldGEpID0+IHtcbiAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEZ1bGZpbGxXaXRoTWV0YSh2YWx1ZSwgbWV0YSk7XG4gICAgICAgICAgICAgIH1cbiAg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KSA9PiB0YWtlKHByZWRpY2F0ZSwgdGltZW91dCkudGhlbihCb29sZWFuKSxcbiAgICAgICAgICB0YWtlLFxuICAgICAgICAgIGRlbGF5OiBjcmVhdGVEZWxheShpbnRlcm5hbFRhc2tDb250cm9sbGVyLnNpZ25hbCksXG4gICAgICAgICAgcGF1c2U6IGNyZWF0ZVBhdXNlKGludGVybmFsVGFza0NvbnRyb2xsZXIuc2lnbmFsKSxcbiAgICAgICAgICBleHRyYSxcbiAgICAgICAgICBzaWduYWw6IGludGVybmFsVGFza0NvbnRyb2xsZXIuc2lnbmFsLFxuICAgICAgICAgIGZvcms6IGNyZWF0ZUZvcmsoaW50ZXJuYWxUYXNrQ29udHJvbGxlci5zaWduYWwsIGF1dG9Kb2luUHJvbWlzZXMpLFxuICAgICAgICAgIHVuc3Vic2NyaWJlOiBlbnRyeS51bnN1YnNjcmliZSxcbiAgICAgICAgICBzdWJzY3JpYmU6ICgpID0+IHtcbiAgICAgICAgICAgIGxpc3RlbmVyTWFwLnNldChlbnRyeS5pZCwgZW50cnkpO1xuICAgICAgICAgIH0sXG4gICAgICAgICAgY2FuY2VsQWN0aXZlTGlzdGVuZXJzOiAoKSA9PiB7XG4gICAgICAgICAgICBlbnRyeS5wZW5kaW5nLmZvckVhY2goKGNvbnRyb2xsZXIsIF8sIHNldCkgPT4ge1xuICAgICAgICAgICAgICBpZiAoY29udHJvbGxlciAhPT0gaW50ZXJuYWxUYXNrQ29udHJvbGxlcikge1xuICAgICAgICAgICAgICAgIGFib3J0Q29udHJvbGxlcldpdGhSZWFzb24oY29udHJvbGxlciwgbGlzdGVuZXJDYW5jZWxsZWQpO1xuICAgICAgICAgICAgICAgIHNldC5kZWxldGUoY29udHJvbGxlcik7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH0sXG4gICAgICAgICAgY2FuY2VsOiAoKSA9PiB7XG4gICAgICAgICAgICBhYm9ydENvbnRyb2xsZXJXaXRoUmVhc29u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BpLmdldFN0YXRlKCk7XG4gICAgICAgIGNvbnN0IGxpc3RlbmVyRW50cmllcyA9IEFycmF5LmZyb20obGlzdGVuZXJNYXAudmFsdWVzKCkpO1xuICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGxpc3RlbmVyRW50cmllcykge1xuICAgICAgICAgIGxldCBydW5MaXN0ZW5lciA9IGZhbHNlO1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBydW5MaXN0ZW5lciA9IGVudHJ5LnByZWRpY2F0ZShhY3Rpb24sIGN1cnJlbnRTdGF0ZSwgb3JpZ2luYWxTdGF0ZSk7XG4gICAgICAgICAgfSBjYXRjaCAocHJlZGljYXRlRXJyb3IpIHtcbiAgICAgICAgICAgIHJ1bkxpc3RlbmVyID0gZmFsc2U7XG4gICAgICAgICAgICBzYWZlbHlOb3RpZnlFcnJvcihvbkVycm9yLCBwcmVkaWNhdGVFcnJvciwge1xuICAgICAgICAgICAgICByYWlzZWRCeTogXCJwcmVkaWNhdGVcIlxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICghcnVuTGlzdGVuZXIpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgIH1cbiAgICAgICAgICBub3RpZnlMaXN0ZW5lcihlbnRyeSwgYWN0aW9uLCBhcGksIGdldE9yaWdpbmFsU3RhdGUpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfSBmaW5hbGx5IHtcbiAgICAgIG9yaWdpbmFsU3RhdGUgPSBJTlRFUk5BTF9OSUxfVE9LRU47XG4gICAgfVxuICAgIHJldHVybiByZXN1bHQ7XG4gIH07XG4gIHJldHVybiB7XG4gICAgbWlkZGxld2FyZSxcbiAgICBzdGFydExpc3RlbmluZyxcbiAgICBzdG9wTGlzdGVuaW5nLFxuICAgIGNsZWFyTGlzdGVuZXJzOiBjbGVhckxpc3RlbmVyTWlkZGxld2FyZVxuICB9O1xufTtcblxuLy8gc3JjL2R5b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