UNPKG

next

Version:

The React Framework

1,465 lines (1,464 loc) • 98.2 kB
/** * @license React * react-server-dom-webpack-server.browser.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ "use strict"; var ReactDOM = require("react-dom"), React = require("react"), channel = new MessageChannel(), taskQueue = []; channel.port1.onmessage = function () { var task = taskQueue.shift(); task && task(); }; function scheduleWork(callback) { taskQueue.push(callback); channel.port2.postMessage(null); } function handleErrorInNextTick(error) { setTimeout(function () { throw error; }); } var LocalPromise = Promise, scheduleMicrotask = "function" === typeof queueMicrotask ? queueMicrotask : function (callback) { LocalPromise.resolve(null) .then(callback) .catch(handleErrorInNextTick); }, currentView = null, writtenBytes = 0; function writeChunkAndReturn(destination, chunk) { if (0 !== chunk.byteLength) if (2048 < chunk.byteLength) 0 < writtenBytes && (destination.enqueue( new Uint8Array(currentView.buffer, 0, writtenBytes) ), (currentView = new Uint8Array(2048)), (writtenBytes = 0)), destination.enqueue(chunk); else { var allowableBytes = currentView.length - writtenBytes; allowableBytes < chunk.byteLength && (0 === allowableBytes ? destination.enqueue(currentView) : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes), destination.enqueue(currentView), (chunk = chunk.subarray(allowableBytes))), (currentView = new Uint8Array(2048)), (writtenBytes = 0)); currentView.set(chunk, writtenBytes); writtenBytes += chunk.byteLength; } return !0; } var textEncoder = new TextEncoder(); function stringToChunk(content) { return textEncoder.encode(content); } function byteLengthOfChunk(chunk) { return chunk.byteLength; } function closeWithError(destination, error) { "function" === typeof destination.error ? destination.error(error) : destination.close(); } var CLIENT_REFERENCE_TAG$1 = Symbol.for("react.client.reference"), SERVER_REFERENCE_TAG = Symbol.for("react.server.reference"); function registerClientReferenceImpl(proxyImplementation, id, async) { return Object.defineProperties(proxyImplementation, { $$typeof: { value: CLIENT_REFERENCE_TAG$1 }, $$id: { value: id }, $$async: { value: async } }); } var FunctionBind = Function.prototype.bind, ArraySlice = Array.prototype.slice; function bind() { var newFn = FunctionBind.apply(this, arguments); if (this.$$typeof === SERVER_REFERENCE_TAG) { var args = ArraySlice.call(arguments, 1), $$typeof = { value: SERVER_REFERENCE_TAG }, $$id = { value: this.$$id }; args = { value: this.$$bound ? this.$$bound.concat(args) : args }; return Object.defineProperties(newFn, { $$typeof: $$typeof, $$id: $$id, $$bound: args, bind: { value: bind, configurable: !0 } }); } return newFn; } var PROMISE_PROTOTYPE = Promise.prototype, deepProxyHandlers = { get: function (target, name) { switch (name) { case "$$typeof": return target.$$typeof; case "$$id": return target.$$id; case "$$async": return target.$$async; case "name": return target.name; case "displayName": return; case "defaultProps": return; case "toJSON": return; case Symbol.toPrimitive: return Object.prototype[Symbol.toPrimitive]; case Symbol.toStringTag: return Object.prototype[Symbol.toStringTag]; case "Provider": throw Error( "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider." ); case "then": throw Error( "Cannot await or return from a thenable. You cannot await a client module from a server component." ); } throw Error( "Cannot access " + (String(target.name) + "." + String(name)) + " on the server. You cannot dot into a client module from a server component. You can only pass the imported name through." ); }, set: function () { throw Error("Cannot assign to a client module from a server module."); } }; function getReference(target, name) { switch (name) { case "$$typeof": return target.$$typeof; case "$$id": return target.$$id; case "$$async": return target.$$async; case "name": return target.name; case "defaultProps": return; case "toJSON": return; case Symbol.toPrimitive: return Object.prototype[Symbol.toPrimitive]; case Symbol.toStringTag: return Object.prototype[Symbol.toStringTag]; case "__esModule": var moduleId = target.$$id; target.default = registerClientReferenceImpl( function () { throw Error( "Attempted to call the default export of " + moduleId + " from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component." ); }, target.$$id + "#", target.$$async ); return !0; case "then": if (target.then) return target.then; if (target.$$async) return; var clientReference = registerClientReferenceImpl({}, target.$$id, !0), proxy = new Proxy(clientReference, proxyHandlers$1); target.status = "fulfilled"; target.value = proxy; return (target.then = registerClientReferenceImpl( function (resolve) { return Promise.resolve(resolve(proxy)); }, target.$$id + "#then", !1 )); } if ("symbol" === typeof name) throw Error( "Cannot read Symbol exports. Only named exports are supported on a client module imported on the server." ); clientReference = target[name]; clientReference || ((clientReference = registerClientReferenceImpl( function () { throw Error( "Attempted to call " + String(name) + "() from the server but " + String(name) + " is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component." ); }, target.$$id + "#" + name, target.$$async )), Object.defineProperty(clientReference, "name", { value: name }), (clientReference = target[name] = new Proxy(clientReference, deepProxyHandlers))); return clientReference; } var proxyHandlers$1 = { get: function (target, name) { return getReference(target, name); }, getOwnPropertyDescriptor: function (target, name) { var descriptor = Object.getOwnPropertyDescriptor(target, name); descriptor || ((descriptor = { value: getReference(target, name), writable: !1, configurable: !1, enumerable: !1 }), Object.defineProperty(target, name, descriptor)); return descriptor; }, getPrototypeOf: function () { return PROMISE_PROTOTYPE; }, set: function () { throw Error("Cannot assign to a client module from a server module."); } }, ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, previousDispatcher = ReactDOMSharedInternals.d; ReactDOMSharedInternals.d = { f: previousDispatcher.f, r: previousDispatcher.r, D: prefetchDNS, C: preconnect, L: preload, m: preloadModule$1, X: preinitScript, S: preinitStyle, M: preinitModuleScript }; function prefetchDNS(href) { if ("string" === typeof href && href) { var request = currentRequest ? currentRequest : null; if (request) { var hints = request.hints, key = "D|" + href; hints.has(key) || (hints.add(key), emitHint(request, "D", href)); } else previousDispatcher.D(href); } } function preconnect(href, crossOrigin) { if ("string" === typeof href) { var request = currentRequest ? currentRequest : null; if (request) { var hints = request.hints, key = "C|" + (null == crossOrigin ? "null" : crossOrigin) + "|" + href; hints.has(key) || (hints.add(key), "string" === typeof crossOrigin ? emitHint(request, "C", [href, crossOrigin]) : emitHint(request, "C", href)); } else previousDispatcher.C(href, crossOrigin); } } function preload(href, as, options) { if ("string" === typeof href) { var request = currentRequest ? currentRequest : null; if (request) { var hints = request.hints, key = "L"; if ("image" === as && options) { var imageSrcSet = options.imageSrcSet, imageSizes = options.imageSizes, uniquePart = ""; "string" === typeof imageSrcSet && "" !== imageSrcSet ? ((uniquePart += "[" + imageSrcSet + "]"), "string" === typeof imageSizes && (uniquePart += "[" + imageSizes + "]")) : (uniquePart += "[][]" + href); key += "[image]" + uniquePart; } else key += "[" + as + "]" + href; hints.has(key) || (hints.add(key), (options = trimOptions(options)) ? emitHint(request, "L", [href, as, options]) : emitHint(request, "L", [href, as])); } else previousDispatcher.L(href, as, options); } } function preloadModule$1(href, options) { if ("string" === typeof href) { var request = currentRequest ? currentRequest : null; if (request) { var hints = request.hints, key = "m|" + href; if (hints.has(key)) return; hints.add(key); return (options = trimOptions(options)) ? emitHint(request, "m", [href, options]) : emitHint(request, "m", href); } previousDispatcher.m(href, options); } } function preinitStyle(href, precedence, options) { if ("string" === typeof href) { var request = currentRequest ? currentRequest : null; if (request) { var hints = request.hints, key = "S|" + href; if (hints.has(key)) return; hints.add(key); return (options = trimOptions(options)) ? emitHint(request, "S", [ href, "string" === typeof precedence ? precedence : 0, options ]) : "string" === typeof precedence ? emitHint(request, "S", [href, precedence]) : emitHint(request, "S", href); } previousDispatcher.S(href, precedence, options); } } function preinitScript(src, options) { if ("string" === typeof src) { var request = currentRequest ? currentRequest : null; if (request) { var hints = request.hints, key = "X|" + src; if (hints.has(key)) return; hints.add(key); return (options = trimOptions(options)) ? emitHint(request, "X", [src, options]) : emitHint(request, "X", src); } previousDispatcher.X(src, options); } } function preinitModuleScript(src, options) { if ("string" === typeof src) { var request = currentRequest ? currentRequest : null; if (request) { var hints = request.hints, key = "M|" + src; if (hints.has(key)) return; hints.add(key); return (options = trimOptions(options)) ? emitHint(request, "M", [src, options]) : emitHint(request, "M", src); } previousDispatcher.M(src, options); } } function trimOptions(options) { if (null == options) return null; var hasProperties = !1, trimmed = {}, key; for (key in options) null != options[key] && ((hasProperties = !0), (trimmed[key] = options[key])); return hasProperties ? trimmed : null; } var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"), proxyHandlers = { get: function (target, name) { switch (name) { case "$$typeof": return target.$$typeof; case "name": return; case "displayName": return; case "defaultProps": return; case "toJSON": return; case Symbol.toPrimitive: return Object.prototype[Symbol.toPrimitive]; case Symbol.toStringTag: return Object.prototype[Symbol.toStringTag]; case "Provider": throw Error( "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider." ); } throw Error( "Cannot access " + String(name) + " on the server. You cannot dot into a temporary client reference from a server component. You can only pass the value through to the client." ); }, set: function () { throw Error( "Cannot assign to a temporary client reference from a server module." ); } }; function createTemporaryReference(temporaryReferences, id) { var reference = Object.defineProperties( function () { throw Error( "Attempted to call a temporary Client Reference from the server but it is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component." ); }, { $$typeof: { value: TEMPORARY_REFERENCE_TAG } } ); reference = new Proxy(reference, proxyHandlers); temporaryReferences.set(reference, id); return reference; } var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"), REACT_POSTPONE_TYPE = Symbol.for("react.postpone"), REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } var ASYNC_ITERATOR = Symbol.asyncIterator, SuspenseException = Error( "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`." ); function noop$1() {} function trackUsedThenable(thenableState, thenable, index) { index = thenableState[index]; void 0 === index ? thenableState.push(thenable) : index !== thenable && (thenable.then(noop$1, noop$1), (thenable = index)); switch (thenable.status) { case "fulfilled": return thenable.value; case "rejected": throw thenable.reason; default: "string" === typeof thenable.status ? thenable.then(noop$1, noop$1) : ((thenableState = thenable), (thenableState.status = "pending"), thenableState.then( function (fulfilledValue) { if ("pending" === thenable.status) { var fulfilledThenable = thenable; fulfilledThenable.status = "fulfilled"; fulfilledThenable.value = fulfilledValue; } }, function (error) { if ("pending" === thenable.status) { var rejectedThenable = thenable; rejectedThenable.status = "rejected"; rejectedThenable.reason = error; } } )); switch (thenable.status) { case "fulfilled": return thenable.value; case "rejected": throw thenable.reason; } suspendedThenable = thenable; throw SuspenseException; } } var suspendedThenable = null; function getSuspendedThenable() { if (null === suspendedThenable) throw Error( "Expected a suspended thenable. This is a bug in React. Please file an issue." ); var thenable = suspendedThenable; suspendedThenable = null; return thenable; } var currentRequest$1 = null, thenableIndexCounter = 0, thenableState = null; function getThenableStateAfterSuspending() { var state = thenableState || []; thenableState = null; return state; } var HooksDispatcher = { readContext: unsupportedContext, use: use, useCallback: function (callback) { return callback; }, useContext: unsupportedContext, useEffect: unsupportedHook, useImperativeHandle: unsupportedHook, useLayoutEffect: unsupportedHook, useInsertionEffect: unsupportedHook, useMemo: function (nextCreate) { return nextCreate(); }, useReducer: unsupportedHook, useRef: unsupportedHook, useState: unsupportedHook, useDebugValue: function () {}, useDeferredValue: unsupportedHook, useTransition: unsupportedHook, useSyncExternalStore: unsupportedHook, useId: useId, useHostTransitionStatus: unsupportedHook, useFormState: unsupportedHook, useActionState: unsupportedHook, useOptimistic: unsupportedHook, useMemoCache: function (size) { for (var data = Array(size), i = 0; i < size; i++) data[i] = REACT_MEMO_CACHE_SENTINEL; return data; }, useCacheRefresh: function () { return unsupportedRefresh; } }; HooksDispatcher.useEffectEvent = unsupportedHook; HooksDispatcher.useSwipeTransition = unsupportedHook; function unsupportedHook() { throw Error("This Hook is not supported in Server Components."); } function unsupportedRefresh() { throw Error("Refreshing the cache is not supported in Server Components."); } function unsupportedContext() { throw Error("Cannot read a Client Context from a Server Component."); } function useId() { if (null === currentRequest$1) throw Error("useId can only be used while React is rendering"); var id = currentRequest$1.identifierCount++; return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":"; } function use(usable) { if ( (null !== usable && "object" === typeof usable) || "function" === typeof usable ) { if ("function" === typeof usable.then) { var index = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); return trackUsedThenable(thenableState, usable, index); } usable.$$typeof === REACT_CONTEXT_TYPE && unsupportedContext(); } if (usable.$$typeof === CLIENT_REFERENCE_TAG$1) { if (null != usable.value && usable.value.$$typeof === REACT_CONTEXT_TYPE) throw Error("Cannot read a Client Context from a Server Component."); throw Error("Cannot use() an already resolved Client Reference."); } throw Error("An unsupported type was passed to use(): " + String(usable)); } var DefaultAsyncDispatcher = { getCacheForType: function (resourceType) { var JSCompiler_inline_result = (JSCompiler_inline_result = currentRequest ? currentRequest : null) ? JSCompiler_inline_result.cache : new Map(); var entry = JSCompiler_inline_result.get(resourceType); void 0 === entry && ((entry = resourceType()), JSCompiler_inline_result.set(resourceType, entry)); return entry; } }, ReactSharedInternalsServer = React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; if (!ReactSharedInternalsServer) throw Error( 'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.' ); var isArrayImpl = Array.isArray, getPrototypeOf = Object.getPrototypeOf; function objectName(object) { return Object.prototype.toString .call(object) .replace(/^\[object (.*)\]$/, function (m, p0) { return p0; }); } function describeValueForErrorMessage(value) { switch (typeof value) { case "string": return JSON.stringify( 10 >= value.length ? value : value.slice(0, 10) + "..." ); case "object": if (isArrayImpl(value)) return "[...]"; if (null !== value && value.$$typeof === CLIENT_REFERENCE_TAG) return "client"; value = objectName(value); return "Object" === value ? "{...}" : value; case "function": return value.$$typeof === CLIENT_REFERENCE_TAG ? "client" : (value = value.displayName || value.name) ? "function " + value : "function"; default: return String(value); } } function describeElementType(type) { if ("string" === typeof type) return type; switch (type) { case REACT_SUSPENSE_TYPE: return "Suspense"; case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; case REACT_VIEW_TRANSITION_TYPE: return "ViewTransition"; } if ("object" === typeof type) switch (type.$$typeof) { case REACT_FORWARD_REF_TYPE: return describeElementType(type.render); case REACT_MEMO_TYPE: return describeElementType(type.type); case REACT_LAZY_TYPE: var payload = type._payload; type = type._init; try { return describeElementType(type(payload)); } catch (x) {} } return ""; } var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"); function describeObjectForErrorMessage(objectOrArray, expandedName) { var objKind = objectName(objectOrArray); if ("Object" !== objKind && "Array" !== objKind) return objKind; objKind = -1; var length = 0; if (isArrayImpl(objectOrArray)) { var str = "["; for (var i = 0; i < objectOrArray.length; i++) { 0 < i && (str += ", "); var value = objectOrArray[i]; value = "object" === typeof value && null !== value ? describeObjectForErrorMessage(value) : describeValueForErrorMessage(value); "" + i === expandedName ? ((objKind = str.length), (length = value.length), (str += value)) : (str = 10 > value.length && 40 > str.length + value.length ? str + value : str + "..."); } str += "]"; } else if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) str = "<" + describeElementType(objectOrArray.type) + "/>"; else { if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) return "client"; str = "{"; i = Object.keys(objectOrArray); for (value = 0; value < i.length; value++) { 0 < value && (str += ", "); var name = i[value], encodedKey = JSON.stringify(name); str += ('"' + name + '"' === encodedKey ? name : encodedKey) + ": "; encodedKey = objectOrArray[name]; encodedKey = "object" === typeof encodedKey && null !== encodedKey ? describeObjectForErrorMessage(encodedKey) : describeValueForErrorMessage(encodedKey); name === expandedName ? ((objKind = str.length), (length = encodedKey.length), (str += encodedKey)) : (str = 10 > encodedKey.length && 40 > str.length + encodedKey.length ? str + encodedKey : str + "..."); } str += "}"; } return void 0 === expandedName ? str : -1 < objKind && 0 < length ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)), "\n " + str + "\n " + objectOrArray) : "\n " + str; } var ObjectPrototype = Object.prototype, stringify = JSON.stringify, TaintRegistryObjects = ReactSharedInternalsServer.TaintRegistryObjects, TaintRegistryValues = ReactSharedInternalsServer.TaintRegistryValues, TaintRegistryByteLengths = ReactSharedInternalsServer.TaintRegistryByteLengths, TaintRegistryPendingRequests = ReactSharedInternalsServer.TaintRegistryPendingRequests; function throwTaintViolation(message) { throw Error(message); } function cleanupTaintQueue(request) { request = request.taintCleanupQueue; TaintRegistryPendingRequests.delete(request); for (var i = 0; i < request.length; i++) { var entryValue = request[i], entry = TaintRegistryValues.get(entryValue); void 0 !== entry && (1 === entry.count ? TaintRegistryValues.delete(entryValue) : entry.count--); } request.length = 0; } function defaultErrorHandler(error) { console.error(error); } function defaultPostponeHandler() {} function RequestInstance( type, model, bundlerConfig, onError, identifierPrefix, onPostpone, temporaryReferences, environmentName, filterStackFrame, onAllReady, onFatalError ) { if ( null !== ReactSharedInternalsServer.A && ReactSharedInternalsServer.A !== DefaultAsyncDispatcher ) throw Error("Currently React only supports one RSC renderer at a time."); ReactSharedInternalsServer.A = DefaultAsyncDispatcher; filterStackFrame = new Set(); environmentName = []; var cleanupQueue = []; TaintRegistryPendingRequests.add(cleanupQueue); var hints = new Set(); this.type = type; this.status = 10; this.flushScheduled = !1; this.destination = this.fatalError = null; this.bundlerConfig = bundlerConfig; this.cache = new Map(); this.pendingChunks = this.nextChunkId = 0; this.hints = hints; this.abortListeners = new Set(); this.abortableTasks = filterStackFrame; this.pingedTasks = environmentName; this.completedImportChunks = []; this.completedHintChunks = []; this.completedRegularChunks = []; this.completedErrorChunks = []; this.writtenSymbols = new Map(); this.writtenClientReferences = new Map(); this.writtenServerReferences = new Map(); this.writtenObjects = new WeakMap(); this.temporaryReferences = temporaryReferences; this.identifierPrefix = identifierPrefix || ""; this.identifierCount = 1; this.taintCleanupQueue = cleanupQueue; this.onError = void 0 === onError ? defaultErrorHandler : onError; this.onPostpone = void 0 === onPostpone ? defaultPostponeHandler : onPostpone; this.onAllReady = onAllReady; this.onFatalError = onFatalError; type = createTask(this, model, null, !1, filterStackFrame); environmentName.push(type); } function noop() {} var currentRequest = null; function serializeThenable(request, task, thenable) { var newTask = createTask( request, null, task.keyPath, task.implicitSlot, request.abortableTasks ); switch (thenable.status) { case "fulfilled": return ( (newTask.model = thenable.value), pingTask(request, newTask), newTask.id ); case "rejected": return erroredTask(request, newTask, thenable.reason), newTask.id; default: if (12 === request.status) return ( request.abortableTasks.delete(newTask), (newTask.status = 3), 21 === request.type ? request.pendingChunks-- : ((task = stringify(serializeByValueID(request.fatalError))), emitModelChunk(request, newTask.id, task)), newTask.id ); "string" !== typeof thenable.status && ((thenable.status = "pending"), thenable.then( function (fulfilledValue) { "pending" === thenable.status && ((thenable.status = "fulfilled"), (thenable.value = fulfilledValue)); }, function (error) { "pending" === thenable.status && ((thenable.status = "rejected"), (thenable.reason = error)); } )); } thenable.then( function (value) { newTask.model = value; pingTask(request, newTask); }, function (reason) { 0 === newTask.status && (erroredTask(request, newTask, reason), enqueueFlush(request)); } ); return newTask.id; } function serializeReadableStream(request, task, stream) { function progress(entry) { if (!aborted) if (entry.done) request.abortListeners.delete(abortStream), (entry = streamTask.id.toString(16) + ":C\n"), request.completedRegularChunks.push(stringToChunk(entry)), enqueueFlush(request), (aborted = !0); else try { (streamTask.model = entry.value), request.pendingChunks++, emitChunk(request, streamTask, streamTask.model), enqueueFlush(request), reader.read().then(progress, error); } catch (x$7) { error(x$7); } } function error(reason) { aborted || ((aborted = !0), request.abortListeners.delete(abortStream), erroredTask(request, streamTask, reason), enqueueFlush(request), reader.cancel(reason).then(error, error)); } function abortStream(reason) { aborted || ((aborted = !0), request.abortListeners.delete(abortStream), 21 === request.type ? request.pendingChunks-- : (erroredTask(request, streamTask, reason), enqueueFlush(request)), reader.cancel(reason).then(error, error)); } var supportsBYOB = stream.supportsBYOB; if (void 0 === supportsBYOB) try { stream.getReader({ mode: "byob" }).releaseLock(), (supportsBYOB = !0); } catch (x) { supportsBYOB = !1; } var reader = stream.getReader(), streamTask = createTask( request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks ); request.abortableTasks.delete(streamTask); request.pendingChunks++; task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n"; request.completedRegularChunks.push(stringToChunk(task)); var aborted = !1; request.abortListeners.add(abortStream); reader.read().then(progress, error); return serializeByValueID(streamTask.id); } function serializeAsyncIterable(request, task, iterable, iterator) { function progress(entry) { if (!aborted) if (entry.done) { request.abortListeners.delete(abortIterable); if (void 0 === entry.value) var endStreamRow = streamTask.id.toString(16) + ":C\n"; else try { var chunkId = outlineModel(request, entry.value); endStreamRow = streamTask.id.toString(16) + ":C" + stringify(serializeByValueID(chunkId)) + "\n"; } catch (x) { error(x); return; } request.completedRegularChunks.push(stringToChunk(endStreamRow)); enqueueFlush(request); aborted = !0; } else try { (streamTask.model = entry.value), request.pendingChunks++, emitChunk(request, streamTask, streamTask.model), enqueueFlush(request), iterator.next().then(progress, error); } catch (x$8) { error(x$8); } } function error(reason) { aborted || ((aborted = !0), request.abortListeners.delete(abortIterable), erroredTask(request, streamTask, reason), enqueueFlush(request), "function" === typeof iterator.throw && iterator.throw(reason).then(error, error)); } function abortIterable(reason) { aborted || ((aborted = !0), request.abortListeners.delete(abortIterable), 21 === request.type ? request.pendingChunks-- : (erroredTask(request, streamTask, reason), enqueueFlush(request)), "function" === typeof iterator.throw && iterator.throw(reason).then(error, error)); } iterable = iterable === iterator; var streamTask = createTask( request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks ); request.abortableTasks.delete(streamTask); request.pendingChunks++; task = streamTask.id.toString(16) + ":" + (iterable ? "x" : "X") + "\n"; request.completedRegularChunks.push(stringToChunk(task)); var aborted = !1; request.abortListeners.add(abortIterable); iterator.next().then(progress, error); return serializeByValueID(streamTask.id); } function emitHint(request, code, model) { model = stringify(model); code = stringToChunk(":H" + code + model + "\n"); request.completedHintChunks.push(code); enqueueFlush(request); } function readThenable(thenable) { if ("fulfilled" === thenable.status) return thenable.value; if ("rejected" === thenable.status) throw thenable.reason; throw thenable; } function createLazyWrapperAroundWakeable(wakeable) { switch (wakeable.status) { case "fulfilled": case "rejected": break; default: "string" !== typeof wakeable.status && ((wakeable.status = "pending"), wakeable.then( function (fulfilledValue) { "pending" === wakeable.status && ((wakeable.status = "fulfilled"), (wakeable.value = fulfilledValue)); }, function (error) { "pending" === wakeable.status && ((wakeable.status = "rejected"), (wakeable.reason = error)); } )); } return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable }; } function voidHandler() {} function processServerComponentReturnValue(request, task, Component, result) { if ( "object" !== typeof result || null === result || result.$$typeof === CLIENT_REFERENCE_TAG$1 ) return result; if ("function" === typeof result.then) return "fulfilled" === result.status ? result.value : createLazyWrapperAroundWakeable(result); var iteratorFn = getIteratorFn(result); return iteratorFn ? ((request = {}), (request[Symbol.iterator] = function () { return iteratorFn.call(result); }), request) : "function" !== typeof result[ASYNC_ITERATOR] || ("function" === typeof ReadableStream && result instanceof ReadableStream) ? result : ((request = {}), (request[ASYNC_ITERATOR] = function () { return result[ASYNC_ITERATOR](); }), request); } function renderFunctionComponent(request, task, key, Component, props) { var prevThenableState = task.thenableState; task.thenableState = null; thenableIndexCounter = 0; thenableState = prevThenableState; props = Component(props, void 0); if (12 === request.status) throw ( ("object" === typeof props && null !== props && "function" === typeof props.then && props.$$typeof !== CLIENT_REFERENCE_TAG$1 && props.then(voidHandler, voidHandler), null) ); props = processServerComponentReturnValue(request, task, Component, props); Component = task.keyPath; prevThenableState = task.implicitSlot; null !== key ? (task.keyPath = null === Component ? key : Component + "," + key) : null === Component && (task.implicitSlot = !0); request = renderModelDestructive(request, task, emptyRoot, "", props); task.keyPath = Component; task.implicitSlot = prevThenableState; return request; } function renderFragment(request, task, children) { return null !== task.keyPath ? ((request = [ REACT_ELEMENT_TYPE, REACT_FRAGMENT_TYPE, task.keyPath, { children: children } ]), task.implicitSlot ? [request] : request) : children; } function renderElement(request, task, type, key, ref, props) { if (null !== ref && void 0 !== ref) throw Error( "Refs cannot be used in Server Components, nor passed to Client Components." ); if ( "function" === typeof type && type.$$typeof !== CLIENT_REFERENCE_TAG$1 && type.$$typeof !== TEMPORARY_REFERENCE_TAG ) return renderFunctionComponent(request, task, key, type, props); if (type === REACT_FRAGMENT_TYPE && null === key) return ( (type = task.implicitSlot), null === task.keyPath && (task.implicitSlot = !0), (props = renderModelDestructive( request, task, emptyRoot, "", props.children )), (task.implicitSlot = type), props ); if ( null != type && "object" === typeof type && type.$$typeof !== CLIENT_REFERENCE_TAG$1 ) switch (type.$$typeof) { case REACT_LAZY_TYPE: var init = type._init; type = init(type._payload); if (12 === request.status) throw null; return renderElement(request, task, type, key, ref, props); case REACT_FORWARD_REF_TYPE: return renderFunctionComponent(request, task, key, type.render, props); case REACT_MEMO_TYPE: return renderElement(request, task, type.type, key, ref, props); } request = key; key = task.keyPath; null === request ? (request = key) : null !== key && (request = key + "," + request); props = [REACT_ELEMENT_TYPE, type, request, props]; task = task.implicitSlot && null !== request ? [props] : props; return task; } function pingTask(request, task) { var pingedTasks = request.pingedTasks; pingedTasks.push(task); 1 === pingedTasks.length && ((request.flushScheduled = null !== request.destination), 21 === request.type || 10 === request.status ? scheduleMicrotask(function () { return performWork(request); }) : scheduleWork(function () { return performWork(request); })); } function createTask(request, model, keyPath, implicitSlot, abortSet) { request.pendingChunks++; var id = request.nextChunkId++; "object" !== typeof model || null === model || null !== keyPath || implicitSlot || request.writtenObjects.set(model, serializeByValueID(id)); var task = { id: id, status: 0, model: model, keyPath: keyPath, implicitSlot: implicitSlot, ping: function () { return pingTask(request, task); }, toJSON: function (parentPropertyName, value) { var prevKeyPath = task.keyPath, prevImplicitSlot = task.implicitSlot; try { var JSCompiler_inline_result = renderModelDestructive( request, task, this, parentPropertyName, value ); } catch (thrownValue) { if ( ((parentPropertyName = task.model), (parentPropertyName = "object" === typeof parentPropertyName && null !== parentPropertyName && (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE || parentPropertyName.$$typeof === REACT_LAZY_TYPE)), 12 === request.status) ) (task.status = 3), 21 === request.type ? ((prevKeyPath = request.nextChunkId++), (prevKeyPath = parentPropertyName ? "$L" + prevKeyPath.toString(16) : serializeByValueID(prevKeyPath)), (JSCompiler_inline_result = prevKeyPath)) : ((prevKeyPath = request.fatalError), (JSCompiler_inline_result = parentPropertyName ? "$L" + prevKeyPath.toString(16) : serializeByValueID(prevKeyPath))); else if ( ((value = thrownValue === SuspenseException ? getSuspendedThenable() : thrownValue), "object" === typeof value && null !== value && "function" === typeof value.then) ) { JSCompiler_inline_result = createTask( request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks ); var ping = JSCompiler_inline_result.ping; value.then(ping, ping); JSCompiler_inline_result.thenableState = getThenableStateAfterSuspending(); task.keyPath = prevKeyPath; task.implicitSlot = prevImplicitSlot; JSCompiler_inline_result = parentPropertyName ? "$L" + JSCompiler_inline_result.id.toString(16) : serializeByValueID(JSCompiler_inline_result.id); } else (task.keyPath = prevKeyPath), (task.implicitSlot = prevImplicitSlot), request.pendingChunks++, (prevKeyPath = request.nextChunkId++), "object" === typeof value && null !== value && value.$$typeof === REACT_POSTPONE_TYPE ? (logPostpone(request, value.message, task), emitPostponeChunk(request, prevKeyPath)) : ((prevImplicitSlot = logRecoverableError(request, value, task)), emitErrorChunk(request, prevKeyPath, prevImplicitSlot)), (JSCompiler_inline_result = parentPropertyName ? "$L" + prevKeyPath.toString(16) : serializeByValueID(prevKeyPath)); } return JSCompiler_inline_result; }, thenableState: null }; abortSet.add(task); return task; } function serializeByValueID(id) { return "$" + id.toString(16); } function encodeReferenceChunk(request, id, reference) { request = stringify(reference); id = id.toString(16) + ":" + request + "\n"; return stringToChunk(id); } function serializeClientReference( request, parent, parentPropertyName, clientReference ) { var clientReferenceKey = clientReference.$$async ? clientReference.$$id + "#async" : clientReference.$$id, writtenClientReferences = request.writtenClientReferences, existingId = writtenClientReferences.get(clientReferenceKey); if (void 0 !== existingId) return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName ? "$L" + existingId.toString(16) : serializeByValueID(existingId); try { var config = request.bundlerConfig, modulePath = clientReference.$$id; existingId = ""; var resolvedModuleData = config[modulePath]; if (resolvedModuleData) existingId = resolvedModuleData.name; else { var idx = modulePath.lastIndexOf("#"); -1 !== idx && ((existingId = modulePath.slice(idx + 1)), (resolvedModuleData = config[modulePath.slice(0, idx)])); if (!resolvedModuleData) throw Error( 'Could not find the module "' + modulePath + '" in the React Client Manifest. This is probably a bug in the React Server Components bundler.' ); } if (!0 === resolvedModuleData.async && !0 === clientReference.$$async) throw Error( 'The module "' + modulePath + '" is marked as an async ESM module but was loaded as a CJS proxy. This is probably a bug in the React Server Components bundler.' ); var JSCompiler_inline_result = !0 === resolvedModuleData.async || !0 === clientReference.$$async ? [resolvedModuleData.id, resolvedModuleData.chunks, existingId, 1] : [resolvedModuleData.id, resolvedModuleData.chunks, existingId]; request.pendingChunks++; var importId = request.nextChunkId++, json = stringify(JSCompiler_inline_result), row = importId.toString(16) + ":I" + json + "\n", processedChunk = stringToChunk(row); request.completedImportChunks.push(processedChunk); writtenClientReferences.set(clientReferenceKey, importId); return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName ? "$L" + importId.toString(16) : serializeByValueID(importId); } catch (x) { return ( request.pendingChunks++, (parent = request.nextChunkId++), (parentPropertyName = logRecoverableError(request, x, null)), emitErrorChunk(request, parent, parentPropertyName), serializeByValueID(parent) ); } } function outlineModel(request, value) { value = createTask(request, value, null, !1, request.abortableTasks); retryTask(request, value); return value.id; } function serializeTypedArray(request, tag, typedArray) { request.pendingChunks++; var bufferId = request.nextChunkId++; emitTypedArrayChunk(request, bufferId, tag, typedArray); return serializeByValueID(bufferId); } function serializeBlob(request, blob) { function progress(entry) { if (!aborted) if (entry.done) request.abortListeners.delete(abortBlob), (aborted = !0), pingTask(request, newTask); else return ( model.push(entry.value), reader.read().then(progress).catch(error) ); } function error(reason) { aborted || ((aborted = !0), request.abortListeners.delete(abortBlob), erroredTask(request, newTask, reason), enqueueFlush(request), reader.cancel(reason).then(error, error)); } function abortBlob(reason) { aborted || ((aborted = !0), request.abortListeners.delete(abortBlob), 21 === request.type ? request.pendingChunks-- : (erroredTask(request, newTask, reason), enqueueFlush(request)), reader.cancel(reason).then(error, error)); } var model = [blob.type], newTask = createTask(request, model, null, !1, request.abortableTasks), reader = blob.stream().getReader(), aborted = !1; request.abortListeners.add(abortBlob); reader.read().then(progress).catch(error); return "$B" + newTask.id.toString(16); } var modelRoot = !1; function renderModelDestructive( request, task, parent, parentPropertyName, value ) { task.model = value; if (value === REACT_ELEMENT_TYPE) return "$"; if (null === value) return null; if ("object" === typeof value) { switch (value.$$typeof) { case REACT_ELEMENT_TYPE: var elementReference = null, writtenObjects = request.writtenObjects; if (null === task.keyPath && !task.implicitSlot) { var existingReference = writtenObjects.get(value); if (void 0 !== existingReference) if (modelRoot === value) modelRoot = null; else return existingReference; else -1 === parentPropertyName.indexOf(":") && ((parent = writtenObjects.get(parent)), void 0 !== parent && ((elementReference = parent + ":" + parentPropertyName), writtenObjects.set(value, elementReference))); } parentPropertyName = value.props; parent = parentPropertyName.ref; value = renderElement( request, task, value.type, value.key, void 0 !== parent ? parent : null, parentPropertyName ); "object" === typeof value && null !== value && null !== elementReference && (writtenObjects.has(value) || writtenObjects.set(value, elementReference)); return value; case REACT_LAZY_TYPE: task.thenableState = null; parentPropertyName = value._init; value = parentPropertyName(value._payload); if (12 === request.status) throw null; return renderModelDestructive(request, task, emptyRoot, "", value); case REACT_LEGACY_ELEMENT_TYPE: throw Error( 'A React Element from an older version of React was rendered. This is not supported. It can happen if:\n- Multiple copies of the "react" package is used.\n- A library pre-bundled an old copy of "react" or "react/jsx-runtime".\n- A compiler tries to "inline" JSX instead of using the runtime.' ); } if (value.$$typeof === CLIENT_REFERENCE_TAG$1) return serializeClientReference( request, parent, parentPropertyName, value ); if ( void 0 !== request.temporaryReferences && ((elementReference = request.temporaryReferences.get(value)), void 0 !== elementReference) ) return "$T" + elementReference; elementReference = TaintRegistryObjects.get(value); void 0 !== elementReference && throwTaintViolation(elementReference); elementReference = request.writtenObjects; writtenObjects = elementReference.get(value); if ("function" === typeof value.then) { if (void 0 !== writtenObjects) { if (null !== task.keyPath || task.implicitSlot) return "$@" + serializeThenable(request, task, value).toString(16); if (modelRoot === value) modelRoot = null; else return writtenObjects; } request = "$@" + serializeThenable(request, task, value).toString(16); elementReference.set(value, request); return request; } if (void 0 !== writtenObjects) if (modelRoot === value) modelRoot = null; else return writtenObjects; else if ( -1 === parentPropertyName.indexOf(":") && ((writtenObjects = elementReference.get(parent)), void 0 !== writtenObjects) ) { existingReference = parentPropertyName; if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE) switch (parentPropertyName) { case "1": existingReference = "type"; break; case "2": existingReference = "key"; break; case "3": existingReference = "props"; break; case "4": existingReference = "_owner"; } elementReference.set(value, writtenObjects +