react-server-dom-parcel 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2569 @@
1
+ /**
2
+ * @license React
3
+ * react-server-dom-parcel-server.edge.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ "use strict";
12
+ var ReactDOM = require("react-dom"),
13
+ React = require("react");
14
+ function resolveServerReference(bundlerConfig, ref) {
15
+ var idx = ref.lastIndexOf("#"),
16
+ id = ref.slice(0, idx);
17
+ idx = ref.slice(idx + 1);
18
+ bundlerConfig = bundlerConfig[id];
19
+ if (!bundlerConfig) throw Error("Invalid server action: " + ref);
20
+ return { id: id, name: idx, bundles: bundlerConfig };
21
+ }
22
+ function preloadModule$1(metadata) {
23
+ return Promise.all(
24
+ metadata.bundles.map(function (bundlePath) {
25
+ return import(parcelRequire.meta.distDir + "/" + bundlePath);
26
+ })
27
+ );
28
+ }
29
+ function requireModule(metadata) {
30
+ return parcelRequire(metadata.id)[metadata.name];
31
+ }
32
+ function handleErrorInNextTick(error) {
33
+ setTimeout(function () {
34
+ throw error;
35
+ });
36
+ }
37
+ var LocalPromise = Promise,
38
+ scheduleMicrotask =
39
+ "function" === typeof queueMicrotask
40
+ ? queueMicrotask
41
+ : function (callback) {
42
+ LocalPromise.resolve(null)
43
+ .then(callback)
44
+ .catch(handleErrorInNextTick);
45
+ },
46
+ currentView = null,
47
+ writtenBytes = 0;
48
+ function writeChunkAndReturn(destination, chunk) {
49
+ if (0 !== chunk.byteLength)
50
+ if (2048 < chunk.byteLength)
51
+ 0 < writtenBytes &&
52
+ (destination.enqueue(
53
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
54
+ ),
55
+ (currentView = new Uint8Array(2048)),
56
+ (writtenBytes = 0)),
57
+ destination.enqueue(chunk);
58
+ else {
59
+ var allowableBytes = currentView.length - writtenBytes;
60
+ allowableBytes < chunk.byteLength &&
61
+ (0 === allowableBytes
62
+ ? destination.enqueue(currentView)
63
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
64
+ destination.enqueue(currentView),
65
+ (chunk = chunk.subarray(allowableBytes))),
66
+ (currentView = new Uint8Array(2048)),
67
+ (writtenBytes = 0));
68
+ currentView.set(chunk, writtenBytes);
69
+ writtenBytes += chunk.byteLength;
70
+ }
71
+ return !0;
72
+ }
73
+ var textEncoder = new TextEncoder();
74
+ function stringToChunk(content) {
75
+ return textEncoder.encode(content);
76
+ }
77
+ function byteLengthOfChunk(chunk) {
78
+ return chunk.byteLength;
79
+ }
80
+ function closeWithError(destination, error) {
81
+ "function" === typeof destination.error
82
+ ? destination.error(error)
83
+ : destination.close();
84
+ }
85
+ var CLIENT_REFERENCE_TAG$1 = Symbol.for("react.client.reference"),
86
+ SERVER_REFERENCE_TAG = Symbol.for("react.server.reference"),
87
+ FunctionBind = Function.prototype.bind,
88
+ ArraySlice = Array.prototype.slice;
89
+ function bind() {
90
+ var newFn = FunctionBind.apply(this, arguments);
91
+ if (this.$$typeof === SERVER_REFERENCE_TAG) {
92
+ var args = ArraySlice.call(arguments, 1),
93
+ $$typeof = { value: SERVER_REFERENCE_TAG },
94
+ $$id = { value: this.$$id };
95
+ args = { value: this.$$bound ? this.$$bound.concat(args) : args };
96
+ return Object.defineProperties(newFn, {
97
+ $$typeof: $$typeof,
98
+ $$id: $$id,
99
+ $$bound: args,
100
+ bind: { value: bind, configurable: !0 }
101
+ });
102
+ }
103
+ return newFn;
104
+ }
105
+ var ReactDOMSharedInternals =
106
+ ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
107
+ previousDispatcher = ReactDOMSharedInternals.d;
108
+ ReactDOMSharedInternals.d = {
109
+ f: previousDispatcher.f,
110
+ r: previousDispatcher.r,
111
+ D: prefetchDNS,
112
+ C: preconnect,
113
+ L: preload,
114
+ m: preloadModule,
115
+ X: preinitScript,
116
+ S: preinitStyle,
117
+ M: preinitModuleScript
118
+ };
119
+ function prefetchDNS(href) {
120
+ if ("string" === typeof href && href) {
121
+ var request = resolveRequest();
122
+ if (request) {
123
+ var hints = request.hints,
124
+ key = "D|" + href;
125
+ hints.has(key) || (hints.add(key), emitHint(request, "D", href));
126
+ } else previousDispatcher.D(href);
127
+ }
128
+ }
129
+ function preconnect(href, crossOrigin) {
130
+ if ("string" === typeof href) {
131
+ var request = resolveRequest();
132
+ if (request) {
133
+ var hints = request.hints,
134
+ key = "C|" + (null == crossOrigin ? "null" : crossOrigin) + "|" + href;
135
+ hints.has(key) ||
136
+ (hints.add(key),
137
+ "string" === typeof crossOrigin
138
+ ? emitHint(request, "C", [href, crossOrigin])
139
+ : emitHint(request, "C", href));
140
+ } else previousDispatcher.C(href, crossOrigin);
141
+ }
142
+ }
143
+ function preload(href, as, options) {
144
+ if ("string" === typeof href) {
145
+ var request = resolveRequest();
146
+ if (request) {
147
+ var hints = request.hints,
148
+ key = "L";
149
+ if ("image" === as && options) {
150
+ var imageSrcSet = options.imageSrcSet,
151
+ imageSizes = options.imageSizes,
152
+ uniquePart = "";
153
+ "string" === typeof imageSrcSet && "" !== imageSrcSet
154
+ ? ((uniquePart += "[" + imageSrcSet + "]"),
155
+ "string" === typeof imageSizes &&
156
+ (uniquePart += "[" + imageSizes + "]"))
157
+ : (uniquePart += "[][]" + href);
158
+ key += "[image]" + uniquePart;
159
+ } else key += "[" + as + "]" + href;
160
+ hints.has(key) ||
161
+ (hints.add(key),
162
+ (options = trimOptions(options))
163
+ ? emitHint(request, "L", [href, as, options])
164
+ : emitHint(request, "L", [href, as]));
165
+ } else previousDispatcher.L(href, as, options);
166
+ }
167
+ }
168
+ function preloadModule(href, options) {
169
+ if ("string" === typeof href) {
170
+ var request = resolveRequest();
171
+ if (request) {
172
+ var hints = request.hints,
173
+ key = "m|" + href;
174
+ if (hints.has(key)) return;
175
+ hints.add(key);
176
+ return (options = trimOptions(options))
177
+ ? emitHint(request, "m", [href, options])
178
+ : emitHint(request, "m", href);
179
+ }
180
+ previousDispatcher.m(href, options);
181
+ }
182
+ }
183
+ function preinitStyle(href, precedence, options) {
184
+ if ("string" === typeof href) {
185
+ var request = resolveRequest();
186
+ if (request) {
187
+ var hints = request.hints,
188
+ key = "S|" + href;
189
+ if (hints.has(key)) return;
190
+ hints.add(key);
191
+ return (options = trimOptions(options))
192
+ ? emitHint(request, "S", [
193
+ href,
194
+ "string" === typeof precedence ? precedence : 0,
195
+ options
196
+ ])
197
+ : "string" === typeof precedence
198
+ ? emitHint(request, "S", [href, precedence])
199
+ : emitHint(request, "S", href);
200
+ }
201
+ previousDispatcher.S(href, precedence, options);
202
+ }
203
+ }
204
+ function preinitScript(src, options) {
205
+ if ("string" === typeof src) {
206
+ var request = resolveRequest();
207
+ if (request) {
208
+ var hints = request.hints,
209
+ key = "X|" + src;
210
+ if (hints.has(key)) return;
211
+ hints.add(key);
212
+ return (options = trimOptions(options))
213
+ ? emitHint(request, "X", [src, options])
214
+ : emitHint(request, "X", src);
215
+ }
216
+ previousDispatcher.X(src, options);
217
+ }
218
+ }
219
+ function preinitModuleScript(src, options) {
220
+ if ("string" === typeof src) {
221
+ var request = resolveRequest();
222
+ if (request) {
223
+ var hints = request.hints,
224
+ key = "M|" + src;
225
+ if (hints.has(key)) return;
226
+ hints.add(key);
227
+ return (options = trimOptions(options))
228
+ ? emitHint(request, "M", [src, options])
229
+ : emitHint(request, "M", src);
230
+ }
231
+ previousDispatcher.M(src, options);
232
+ }
233
+ }
234
+ function trimOptions(options) {
235
+ if (null == options) return null;
236
+ var hasProperties = !1,
237
+ trimmed = {},
238
+ key;
239
+ for (key in options)
240
+ null != options[key] &&
241
+ ((hasProperties = !0), (trimmed[key] = options[key]));
242
+ return hasProperties ? trimmed : null;
243
+ }
244
+ var supportsRequestStorage = "function" === typeof AsyncLocalStorage,
245
+ requestStorage = supportsRequestStorage ? new AsyncLocalStorage() : null;
246
+ "object" === typeof async_hooks
247
+ ? async_hooks.createHook
248
+ : function () {
249
+ return { enable: function () {}, disable: function () {} };
250
+ };
251
+ "object" === typeof async_hooks ? async_hooks.executionAsyncId : null;
252
+ var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
253
+ proxyHandlers = {
254
+ get: function (target, name) {
255
+ switch (name) {
256
+ case "$$typeof":
257
+ return target.$$typeof;
258
+ case "name":
259
+ return;
260
+ case "displayName":
261
+ return;
262
+ case "defaultProps":
263
+ return;
264
+ case "toJSON":
265
+ return;
266
+ case Symbol.toPrimitive:
267
+ return Object.prototype[Symbol.toPrimitive];
268
+ case Symbol.toStringTag:
269
+ return Object.prototype[Symbol.toStringTag];
270
+ case "Provider":
271
+ throw Error(
272
+ "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider."
273
+ );
274
+ }
275
+ throw Error(
276
+ "Cannot access " +
277
+ String(name) +
278
+ " 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."
279
+ );
280
+ },
281
+ set: function () {
282
+ throw Error(
283
+ "Cannot assign to a temporary client reference from a server module."
284
+ );
285
+ }
286
+ };
287
+ function createTemporaryReference(temporaryReferences, id) {
288
+ var reference = Object.defineProperties(
289
+ function () {
290
+ throw Error(
291
+ "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."
292
+ );
293
+ },
294
+ { $$typeof: { value: TEMPORARY_REFERENCE_TAG } }
295
+ );
296
+ reference = new Proxy(reference, proxyHandlers);
297
+ temporaryReferences.set(reference, id);
298
+ return reference;
299
+ }
300
+ var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
301
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
302
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
303
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
304
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
305
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
306
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
307
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
308
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
309
+ REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel");
310
+ Symbol.for("react.postpone");
311
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
312
+ function getIteratorFn(maybeIterable) {
313
+ if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
314
+ maybeIterable =
315
+ (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
316
+ maybeIterable["@@iterator"];
317
+ return "function" === typeof maybeIterable ? maybeIterable : null;
318
+ }
319
+ var ASYNC_ITERATOR = Symbol.asyncIterator,
320
+ SuspenseException = Error(
321
+ "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`."
322
+ );
323
+ function noop$1() {}
324
+ function trackUsedThenable(thenableState, thenable, index) {
325
+ index = thenableState[index];
326
+ void 0 === index
327
+ ? thenableState.push(thenable)
328
+ : index !== thenable && (thenable.then(noop$1, noop$1), (thenable = index));
329
+ switch (thenable.status) {
330
+ case "fulfilled":
331
+ return thenable.value;
332
+ case "rejected":
333
+ throw thenable.reason;
334
+ default:
335
+ "string" === typeof thenable.status
336
+ ? thenable.then(noop$1, noop$1)
337
+ : ((thenableState = thenable),
338
+ (thenableState.status = "pending"),
339
+ thenableState.then(
340
+ function (fulfilledValue) {
341
+ if ("pending" === thenable.status) {
342
+ var fulfilledThenable = thenable;
343
+ fulfilledThenable.status = "fulfilled";
344
+ fulfilledThenable.value = fulfilledValue;
345
+ }
346
+ },
347
+ function (error) {
348
+ if ("pending" === thenable.status) {
349
+ var rejectedThenable = thenable;
350
+ rejectedThenable.status = "rejected";
351
+ rejectedThenable.reason = error;
352
+ }
353
+ }
354
+ ));
355
+ switch (thenable.status) {
356
+ case "fulfilled":
357
+ return thenable.value;
358
+ case "rejected":
359
+ throw thenable.reason;
360
+ }
361
+ suspendedThenable = thenable;
362
+ throw SuspenseException;
363
+ }
364
+ }
365
+ var suspendedThenable = null;
366
+ function getSuspendedThenable() {
367
+ if (null === suspendedThenable)
368
+ throw Error(
369
+ "Expected a suspended thenable. This is a bug in React. Please file an issue."
370
+ );
371
+ var thenable = suspendedThenable;
372
+ suspendedThenable = null;
373
+ return thenable;
374
+ }
375
+ var currentRequest$1 = null,
376
+ thenableIndexCounter = 0,
377
+ thenableState = null;
378
+ function getThenableStateAfterSuspending() {
379
+ var state = thenableState || [];
380
+ thenableState = null;
381
+ return state;
382
+ }
383
+ var HooksDispatcher = {
384
+ useMemo: function (nextCreate) {
385
+ return nextCreate();
386
+ },
387
+ useCallback: function (callback) {
388
+ return callback;
389
+ },
390
+ useDebugValue: function () {},
391
+ useDeferredValue: unsupportedHook,
392
+ useTransition: unsupportedHook,
393
+ readContext: unsupportedContext,
394
+ useContext: unsupportedContext,
395
+ useReducer: unsupportedHook,
396
+ useRef: unsupportedHook,
397
+ useState: unsupportedHook,
398
+ useInsertionEffect: unsupportedHook,
399
+ useLayoutEffect: unsupportedHook,
400
+ useImperativeHandle: unsupportedHook,
401
+ useEffect: unsupportedHook,
402
+ useId: useId,
403
+ useSyncExternalStore: unsupportedHook,
404
+ useCacheRefresh: function () {
405
+ return unsupportedRefresh;
406
+ },
407
+ useMemoCache: function (size) {
408
+ for (var data = Array(size), i = 0; i < size; i++)
409
+ data[i] = REACT_MEMO_CACHE_SENTINEL;
410
+ return data;
411
+ },
412
+ use: use
413
+ };
414
+ function unsupportedHook() {
415
+ throw Error("This Hook is not supported in Server Components.");
416
+ }
417
+ function unsupportedRefresh() {
418
+ throw Error("Refreshing the cache is not supported in Server Components.");
419
+ }
420
+ function unsupportedContext() {
421
+ throw Error("Cannot read a Client Context from a Server Component.");
422
+ }
423
+ function useId() {
424
+ if (null === currentRequest$1)
425
+ throw Error("useId can only be used while React is rendering");
426
+ var id = currentRequest$1.identifierCount++;
427
+ return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":";
428
+ }
429
+ function use(usable) {
430
+ if (
431
+ (null !== usable && "object" === typeof usable) ||
432
+ "function" === typeof usable
433
+ ) {
434
+ if ("function" === typeof usable.then) {
435
+ var index = thenableIndexCounter;
436
+ thenableIndexCounter += 1;
437
+ null === thenableState && (thenableState = []);
438
+ return trackUsedThenable(thenableState, usable, index);
439
+ }
440
+ usable.$$typeof === REACT_CONTEXT_TYPE && unsupportedContext();
441
+ }
442
+ if (usable.$$typeof === CLIENT_REFERENCE_TAG$1) {
443
+ if (null != usable.value && usable.value.$$typeof === REACT_CONTEXT_TYPE)
444
+ throw Error("Cannot read a Client Context from a Server Component.");
445
+ throw Error("Cannot use() an already resolved Client Reference.");
446
+ }
447
+ throw Error("An unsupported type was passed to use(): " + String(usable));
448
+ }
449
+ var DefaultAsyncDispatcher = {
450
+ getCacheForType: function (resourceType) {
451
+ var JSCompiler_inline_result = (JSCompiler_inline_result =
452
+ resolveRequest())
453
+ ? JSCompiler_inline_result.cache
454
+ : new Map();
455
+ var entry = JSCompiler_inline_result.get(resourceType);
456
+ void 0 === entry &&
457
+ ((entry = resourceType()),
458
+ JSCompiler_inline_result.set(resourceType, entry));
459
+ return entry;
460
+ }
461
+ },
462
+ ReactSharedInternalsServer =
463
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
464
+ if (!ReactSharedInternalsServer)
465
+ throw Error(
466
+ '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.'
467
+ );
468
+ var isArrayImpl = Array.isArray,
469
+ getPrototypeOf = Object.getPrototypeOf;
470
+ function objectName(object) {
471
+ return Object.prototype.toString
472
+ .call(object)
473
+ .replace(/^\[object (.*)\]$/, function (m, p0) {
474
+ return p0;
475
+ });
476
+ }
477
+ function describeValueForErrorMessage(value) {
478
+ switch (typeof value) {
479
+ case "string":
480
+ return JSON.stringify(
481
+ 10 >= value.length ? value : value.slice(0, 10) + "..."
482
+ );
483
+ case "object":
484
+ if (isArrayImpl(value)) return "[...]";
485
+ if (null !== value && value.$$typeof === CLIENT_REFERENCE_TAG)
486
+ return "client";
487
+ value = objectName(value);
488
+ return "Object" === value ? "{...}" : value;
489
+ case "function":
490
+ return value.$$typeof === CLIENT_REFERENCE_TAG
491
+ ? "client"
492
+ : (value = value.displayName || value.name)
493
+ ? "function " + value
494
+ : "function";
495
+ default:
496
+ return String(value);
497
+ }
498
+ }
499
+ function describeElementType(type) {
500
+ if ("string" === typeof type) return type;
501
+ switch (type) {
502
+ case REACT_SUSPENSE_TYPE:
503
+ return "Suspense";
504
+ case REACT_SUSPENSE_LIST_TYPE:
505
+ return "SuspenseList";
506
+ }
507
+ if ("object" === typeof type)
508
+ switch (type.$$typeof) {
509
+ case REACT_FORWARD_REF_TYPE:
510
+ return describeElementType(type.render);
511
+ case REACT_MEMO_TYPE:
512
+ return describeElementType(type.type);
513
+ case REACT_LAZY_TYPE:
514
+ var payload = type._payload;
515
+ type = type._init;
516
+ try {
517
+ return describeElementType(type(payload));
518
+ } catch (x) {}
519
+ }
520
+ return "";
521
+ }
522
+ var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference");
523
+ function describeObjectForErrorMessage(objectOrArray, expandedName) {
524
+ var objKind = objectName(objectOrArray);
525
+ if ("Object" !== objKind && "Array" !== objKind) return objKind;
526
+ objKind = -1;
527
+ var length = 0;
528
+ if (isArrayImpl(objectOrArray)) {
529
+ var str = "[";
530
+ for (var i = 0; i < objectOrArray.length; i++) {
531
+ 0 < i && (str += ", ");
532
+ var value = objectOrArray[i];
533
+ value =
534
+ "object" === typeof value && null !== value
535
+ ? describeObjectForErrorMessage(value)
536
+ : describeValueForErrorMessage(value);
537
+ "" + i === expandedName
538
+ ? ((objKind = str.length), (length = value.length), (str += value))
539
+ : (str =
540
+ 10 > value.length && 40 > str.length + value.length
541
+ ? str + value
542
+ : str + "...");
543
+ }
544
+ str += "]";
545
+ } else if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE)
546
+ str = "<" + describeElementType(objectOrArray.type) + "/>";
547
+ else {
548
+ if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) return "client";
549
+ str = "{";
550
+ i = Object.keys(objectOrArray);
551
+ for (value = 0; value < i.length; value++) {
552
+ 0 < value && (str += ", ");
553
+ var name = i[value],
554
+ encodedKey = JSON.stringify(name);
555
+ str += ('"' + name + '"' === encodedKey ? name : encodedKey) + ": ";
556
+ encodedKey = objectOrArray[name];
557
+ encodedKey =
558
+ "object" === typeof encodedKey && null !== encodedKey
559
+ ? describeObjectForErrorMessage(encodedKey)
560
+ : describeValueForErrorMessage(encodedKey);
561
+ name === expandedName
562
+ ? ((objKind = str.length),
563
+ (length = encodedKey.length),
564
+ (str += encodedKey))
565
+ : (str =
566
+ 10 > encodedKey.length && 40 > str.length + encodedKey.length
567
+ ? str + encodedKey
568
+ : str + "...");
569
+ }
570
+ str += "}";
571
+ }
572
+ return void 0 === expandedName
573
+ ? str
574
+ : -1 < objKind && 0 < length
575
+ ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)),
576
+ "\n " + str + "\n " + objectOrArray)
577
+ : "\n " + str;
578
+ }
579
+ var ObjectPrototype = Object.prototype,
580
+ stringify = JSON.stringify;
581
+ function defaultErrorHandler(error) {
582
+ console.error(error);
583
+ }
584
+ function defaultPostponeHandler() {}
585
+ function RequestInstance(
586
+ type,
587
+ model,
588
+ bundlerConfig,
589
+ onError,
590
+ identifierPrefix,
591
+ onPostpone,
592
+ temporaryReferences,
593
+ environmentName,
594
+ filterStackFrame,
595
+ onAllReady,
596
+ onFatalError
597
+ ) {
598
+ if (
599
+ null !== ReactSharedInternalsServer.A &&
600
+ ReactSharedInternalsServer.A !== DefaultAsyncDispatcher
601
+ )
602
+ throw Error("Currently React only supports one RSC renderer at a time.");
603
+ ReactSharedInternalsServer.A = DefaultAsyncDispatcher;
604
+ filterStackFrame = new Set();
605
+ environmentName = [];
606
+ var hints = new Set();
607
+ this.type = type;
608
+ this.status = 10;
609
+ this.flushScheduled = !1;
610
+ this.destination = this.fatalError = null;
611
+ this.bundlerConfig = bundlerConfig;
612
+ this.cache = new Map();
613
+ this.pendingChunks = this.nextChunkId = 0;
614
+ this.hints = hints;
615
+ this.abortListeners = new Set();
616
+ this.abortableTasks = filterStackFrame;
617
+ this.pingedTasks = environmentName;
618
+ this.completedImportChunks = [];
619
+ this.completedHintChunks = [];
620
+ this.completedRegularChunks = [];
621
+ this.completedErrorChunks = [];
622
+ this.writtenSymbols = new Map();
623
+ this.writtenClientReferences = new Map();
624
+ this.writtenServerReferences = new Map();
625
+ this.writtenObjects = new WeakMap();
626
+ this.temporaryReferences = temporaryReferences;
627
+ this.identifierPrefix = identifierPrefix || "";
628
+ this.identifierCount = 1;
629
+ this.taintCleanupQueue = [];
630
+ this.onError = void 0 === onError ? defaultErrorHandler : onError;
631
+ this.onPostpone = void 0 === onPostpone ? defaultPostponeHandler : onPostpone;
632
+ this.onAllReady = onAllReady;
633
+ this.onFatalError = onFatalError;
634
+ type = createTask(this, model, null, !1, filterStackFrame);
635
+ environmentName.push(type);
636
+ }
637
+ function noop() {}
638
+ var currentRequest = null;
639
+ function resolveRequest() {
640
+ if (currentRequest) return currentRequest;
641
+ if (supportsRequestStorage) {
642
+ var store = requestStorage.getStore();
643
+ if (store) return store;
644
+ }
645
+ return null;
646
+ }
647
+ function serializeThenable(request, task, thenable) {
648
+ var newTask = createTask(
649
+ request,
650
+ null,
651
+ task.keyPath,
652
+ task.implicitSlot,
653
+ request.abortableTasks
654
+ );
655
+ switch (thenable.status) {
656
+ case "fulfilled":
657
+ return (
658
+ (newTask.model = thenable.value), pingTask(request, newTask), newTask.id
659
+ );
660
+ case "rejected":
661
+ return (
662
+ (task = logRecoverableError(request, thenable.reason, null)),
663
+ emitErrorChunk(request, newTask.id, task),
664
+ (newTask.status = 4),
665
+ request.abortableTasks.delete(newTask),
666
+ newTask.id
667
+ );
668
+ default:
669
+ if (12 === request.status)
670
+ return (
671
+ request.abortableTasks.delete(newTask),
672
+ (newTask.status = 3),
673
+ (task = stringify(serializeByValueID(request.fatalError))),
674
+ emitModelChunk(request, newTask.id, task),
675
+ newTask.id
676
+ );
677
+ "string" !== typeof thenable.status &&
678
+ ((thenable.status = "pending"),
679
+ thenable.then(
680
+ function (fulfilledValue) {
681
+ "pending" === thenable.status &&
682
+ ((thenable.status = "fulfilled"),
683
+ (thenable.value = fulfilledValue));
684
+ },
685
+ function (error) {
686
+ "pending" === thenable.status &&
687
+ ((thenable.status = "rejected"), (thenable.reason = error));
688
+ }
689
+ ));
690
+ }
691
+ thenable.then(
692
+ function (value) {
693
+ newTask.model = value;
694
+ pingTask(request, newTask);
695
+ },
696
+ function (reason) {
697
+ 0 === newTask.status &&
698
+ ((reason = logRecoverableError(request, reason, newTask)),
699
+ emitErrorChunk(request, newTask.id, reason),
700
+ (newTask.status = 4),
701
+ request.abortableTasks.delete(newTask),
702
+ enqueueFlush(request));
703
+ }
704
+ );
705
+ return newTask.id;
706
+ }
707
+ function serializeReadableStream(request, task, stream) {
708
+ function progress(entry) {
709
+ if (!aborted)
710
+ if (entry.done)
711
+ request.abortListeners.delete(abortStream),
712
+ (entry = streamTask.id.toString(16) + ":C\n"),
713
+ request.completedRegularChunks.push(stringToChunk(entry)),
714
+ enqueueFlush(request),
715
+ (aborted = !0);
716
+ else
717
+ try {
718
+ (streamTask.model = entry.value),
719
+ request.pendingChunks++,
720
+ emitChunk(request, streamTask, streamTask.model),
721
+ enqueueFlush(request),
722
+ reader.read().then(progress, error);
723
+ } catch (x$8) {
724
+ error(x$8);
725
+ }
726
+ }
727
+ function error(reason) {
728
+ if (!aborted) {
729
+ aborted = !0;
730
+ request.abortListeners.delete(abortStream);
731
+ var digest = logRecoverableError(request, reason, streamTask);
732
+ emitErrorChunk(request, streamTask.id, digest);
733
+ enqueueFlush(request);
734
+ reader.cancel(reason).then(error, error);
735
+ }
736
+ }
737
+ function abortStream(reason) {
738
+ if (!aborted) {
739
+ aborted = !0;
740
+ request.abortListeners.delete(abortStream);
741
+ var digest = logRecoverableError(request, reason, streamTask);
742
+ emitErrorChunk(request, streamTask.id, digest);
743
+ enqueueFlush(request);
744
+ reader.cancel(reason).then(error, error);
745
+ }
746
+ }
747
+ var supportsBYOB = stream.supportsBYOB;
748
+ if (void 0 === supportsBYOB)
749
+ try {
750
+ stream.getReader({ mode: "byob" }).releaseLock(), (supportsBYOB = !0);
751
+ } catch (x) {
752
+ supportsBYOB = !1;
753
+ }
754
+ var reader = stream.getReader(),
755
+ streamTask = createTask(
756
+ request,
757
+ task.model,
758
+ task.keyPath,
759
+ task.implicitSlot,
760
+ request.abortableTasks
761
+ );
762
+ request.abortableTasks.delete(streamTask);
763
+ request.pendingChunks++;
764
+ task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n";
765
+ request.completedRegularChunks.push(stringToChunk(task));
766
+ var aborted = !1;
767
+ request.abortListeners.add(abortStream);
768
+ reader.read().then(progress, error);
769
+ return serializeByValueID(streamTask.id);
770
+ }
771
+ function serializeAsyncIterable(request, task, iterable, iterator) {
772
+ function progress(entry) {
773
+ if (!aborted)
774
+ if (entry.done) {
775
+ request.abortListeners.delete(abortIterable);
776
+ if (void 0 === entry.value)
777
+ var endStreamRow = streamTask.id.toString(16) + ":C\n";
778
+ else
779
+ try {
780
+ var chunkId = outlineModel(request, entry.value);
781
+ endStreamRow =
782
+ streamTask.id.toString(16) +
783
+ ":C" +
784
+ stringify(serializeByValueID(chunkId)) +
785
+ "\n";
786
+ } catch (x) {
787
+ error(x);
788
+ return;
789
+ }
790
+ request.completedRegularChunks.push(stringToChunk(endStreamRow));
791
+ enqueueFlush(request);
792
+ aborted = !0;
793
+ } else
794
+ try {
795
+ (streamTask.model = entry.value),
796
+ request.pendingChunks++,
797
+ emitChunk(request, streamTask, streamTask.model),
798
+ enqueueFlush(request),
799
+ iterator.next().then(progress, error);
800
+ } catch (x$9) {
801
+ error(x$9);
802
+ }
803
+ }
804
+ function error(reason) {
805
+ if (!aborted) {
806
+ aborted = !0;
807
+ request.abortListeners.delete(abortIterable);
808
+ var digest = logRecoverableError(request, reason, streamTask);
809
+ emitErrorChunk(request, streamTask.id, digest);
810
+ enqueueFlush(request);
811
+ "function" === typeof iterator.throw &&
812
+ iterator.throw(reason).then(error, error);
813
+ }
814
+ }
815
+ function abortIterable(reason) {
816
+ if (!aborted) {
817
+ aborted = !0;
818
+ request.abortListeners.delete(abortIterable);
819
+ var digest = logRecoverableError(request, reason, streamTask);
820
+ emitErrorChunk(request, streamTask.id, digest);
821
+ enqueueFlush(request);
822
+ "function" === typeof iterator.throw &&
823
+ iterator.throw(reason).then(error, error);
824
+ }
825
+ }
826
+ iterable = iterable === iterator;
827
+ var streamTask = createTask(
828
+ request,
829
+ task.model,
830
+ task.keyPath,
831
+ task.implicitSlot,
832
+ request.abortableTasks
833
+ );
834
+ request.abortableTasks.delete(streamTask);
835
+ request.pendingChunks++;
836
+ task = streamTask.id.toString(16) + ":" + (iterable ? "x" : "X") + "\n";
837
+ request.completedRegularChunks.push(stringToChunk(task));
838
+ var aborted = !1;
839
+ request.abortListeners.add(abortIterable);
840
+ iterator.next().then(progress, error);
841
+ return serializeByValueID(streamTask.id);
842
+ }
843
+ function emitHint(request, code, model) {
844
+ model = stringify(model);
845
+ var id = request.nextChunkId++;
846
+ code = "H" + code;
847
+ code = id.toString(16) + ":" + code;
848
+ model = stringToChunk(code + model + "\n");
849
+ request.completedHintChunks.push(model);
850
+ enqueueFlush(request);
851
+ }
852
+ function readThenable(thenable) {
853
+ if ("fulfilled" === thenable.status) return thenable.value;
854
+ if ("rejected" === thenable.status) throw thenable.reason;
855
+ throw thenable;
856
+ }
857
+ function createLazyWrapperAroundWakeable(wakeable) {
858
+ switch (wakeable.status) {
859
+ case "fulfilled":
860
+ case "rejected":
861
+ break;
862
+ default:
863
+ "string" !== typeof wakeable.status &&
864
+ ((wakeable.status = "pending"),
865
+ wakeable.then(
866
+ function (fulfilledValue) {
867
+ "pending" === wakeable.status &&
868
+ ((wakeable.status = "fulfilled"),
869
+ (wakeable.value = fulfilledValue));
870
+ },
871
+ function (error) {
872
+ "pending" === wakeable.status &&
873
+ ((wakeable.status = "rejected"), (wakeable.reason = error));
874
+ }
875
+ ));
876
+ }
877
+ return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable };
878
+ }
879
+ function voidHandler() {}
880
+ function renderFunctionComponent(request, task, key, Component, props) {
881
+ var prevThenableState = task.thenableState;
882
+ task.thenableState = null;
883
+ thenableIndexCounter = 0;
884
+ thenableState = prevThenableState;
885
+ Component = Component(props, void 0);
886
+ if (12 === request.status)
887
+ throw (
888
+ ("object" === typeof Component &&
889
+ null !== Component &&
890
+ "function" === typeof Component.then &&
891
+ Component.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
892
+ Component.then(voidHandler, voidHandler),
893
+ null)
894
+ );
895
+ if (
896
+ "object" === typeof Component &&
897
+ null !== Component &&
898
+ Component.$$typeof !== CLIENT_REFERENCE_TAG$1
899
+ ) {
900
+ if ("function" === typeof Component.then) {
901
+ props = Component;
902
+ if ("fulfilled" === props.status) return props.value;
903
+ Component = createLazyWrapperAroundWakeable(Component);
904
+ }
905
+ var iteratorFn = getIteratorFn(Component);
906
+ if (iteratorFn) {
907
+ var iterableChild = Component;
908
+ Component = {};
909
+ Component =
910
+ ((Component[Symbol.iterator] = function () {
911
+ return iteratorFn.call(iterableChild);
912
+ }),
913
+ Component);
914
+ } else if (
915
+ !(
916
+ "function" !== typeof Component[ASYNC_ITERATOR] ||
917
+ ("function" === typeof ReadableStream &&
918
+ Component instanceof ReadableStream)
919
+ )
920
+ ) {
921
+ var iterableChild$10 = Component;
922
+ Component = {};
923
+ Component =
924
+ ((Component[ASYNC_ITERATOR] = function () {
925
+ return iterableChild$10[ASYNC_ITERATOR]();
926
+ }),
927
+ Component);
928
+ }
929
+ }
930
+ props = task.keyPath;
931
+ prevThenableState = task.implicitSlot;
932
+ null !== key
933
+ ? (task.keyPath = null === props ? key : props + "," + key)
934
+ : null === props && (task.implicitSlot = !0);
935
+ request = renderModelDestructive(request, task, emptyRoot, "", Component);
936
+ task.keyPath = props;
937
+ task.implicitSlot = prevThenableState;
938
+ return request;
939
+ }
940
+ function renderFragment(request, task, children) {
941
+ return null !== task.keyPath
942
+ ? ((request = [
943
+ REACT_ELEMENT_TYPE,
944
+ REACT_FRAGMENT_TYPE,
945
+ task.keyPath,
946
+ { children: children }
947
+ ]),
948
+ task.implicitSlot ? [request] : request)
949
+ : children;
950
+ }
951
+ function renderElement(request, task, type, key, ref, props) {
952
+ if (null !== ref && void 0 !== ref)
953
+ throw Error(
954
+ "Refs cannot be used in Server Components, nor passed to Client Components."
955
+ );
956
+ if (
957
+ "function" === typeof type &&
958
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
959
+ type.$$typeof !== TEMPORARY_REFERENCE_TAG
960
+ )
961
+ return renderFunctionComponent(request, task, key, type, props);
962
+ if (type === REACT_FRAGMENT_TYPE && null === key)
963
+ return (
964
+ (type = task.implicitSlot),
965
+ null === task.keyPath && (task.implicitSlot = !0),
966
+ (props = renderModelDestructive(
967
+ request,
968
+ task,
969
+ emptyRoot,
970
+ "",
971
+ props.children
972
+ )),
973
+ (task.implicitSlot = type),
974
+ props
975
+ );
976
+ if (
977
+ null != type &&
978
+ "object" === typeof type &&
979
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1
980
+ )
981
+ switch (type.$$typeof) {
982
+ case REACT_LAZY_TYPE:
983
+ var init = type._init;
984
+ type = init(type._payload);
985
+ if (12 === request.status) throw null;
986
+ return renderElement(request, task, type, key, ref, props);
987
+ case REACT_FORWARD_REF_TYPE:
988
+ return renderFunctionComponent(request, task, key, type.render, props);
989
+ case REACT_MEMO_TYPE:
990
+ return renderElement(request, task, type.type, key, ref, props);
991
+ }
992
+ request = key;
993
+ key = task.keyPath;
994
+ null === request
995
+ ? (request = key)
996
+ : null !== key && (request = key + "," + request);
997
+ props = [REACT_ELEMENT_TYPE, type, request, props];
998
+ task = task.implicitSlot && null !== request ? [props] : props;
999
+ return task;
1000
+ }
1001
+ function pingTask(request, task) {
1002
+ var pingedTasks = request.pingedTasks;
1003
+ pingedTasks.push(task);
1004
+ 1 === pingedTasks.length &&
1005
+ ((request.flushScheduled = null !== request.destination),
1006
+ 21 === request.type || 10 === request.status
1007
+ ? scheduleMicrotask(function () {
1008
+ return performWork(request);
1009
+ })
1010
+ : setTimeout(function () {
1011
+ return performWork(request);
1012
+ }, 0));
1013
+ }
1014
+ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1015
+ request.pendingChunks++;
1016
+ var id = request.nextChunkId++;
1017
+ "object" !== typeof model ||
1018
+ null === model ||
1019
+ null !== keyPath ||
1020
+ implicitSlot ||
1021
+ request.writtenObjects.set(model, serializeByValueID(id));
1022
+ var task = {
1023
+ id: id,
1024
+ status: 0,
1025
+ model: model,
1026
+ keyPath: keyPath,
1027
+ implicitSlot: implicitSlot,
1028
+ ping: function () {
1029
+ return pingTask(request, task);
1030
+ },
1031
+ toJSON: function (parentPropertyName, value) {
1032
+ var prevKeyPath = task.keyPath,
1033
+ prevImplicitSlot = task.implicitSlot;
1034
+ try {
1035
+ var JSCompiler_inline_result = renderModelDestructive(
1036
+ request,
1037
+ task,
1038
+ this,
1039
+ parentPropertyName,
1040
+ value
1041
+ );
1042
+ } catch (thrownValue) {
1043
+ if (
1044
+ ((parentPropertyName = task.model),
1045
+ (parentPropertyName =
1046
+ "object" === typeof parentPropertyName &&
1047
+ null !== parentPropertyName &&
1048
+ (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1049
+ parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1050
+ 12 === request.status)
1051
+ )
1052
+ (task.status = 3),
1053
+ (prevKeyPath = request.fatalError),
1054
+ (JSCompiler_inline_result = parentPropertyName
1055
+ ? "$L" + prevKeyPath.toString(16)
1056
+ : serializeByValueID(prevKeyPath));
1057
+ else if (
1058
+ ((value =
1059
+ thrownValue === SuspenseException
1060
+ ? getSuspendedThenable()
1061
+ : thrownValue),
1062
+ "object" === typeof value &&
1063
+ null !== value &&
1064
+ "function" === typeof value.then)
1065
+ ) {
1066
+ JSCompiler_inline_result = createTask(
1067
+ request,
1068
+ task.model,
1069
+ task.keyPath,
1070
+ task.implicitSlot,
1071
+ request.abortableTasks
1072
+ );
1073
+ var ping = JSCompiler_inline_result.ping;
1074
+ value.then(ping, ping);
1075
+ JSCompiler_inline_result.thenableState =
1076
+ getThenableStateAfterSuspending();
1077
+ task.keyPath = prevKeyPath;
1078
+ task.implicitSlot = prevImplicitSlot;
1079
+ JSCompiler_inline_result = parentPropertyName
1080
+ ? "$L" + JSCompiler_inline_result.id.toString(16)
1081
+ : serializeByValueID(JSCompiler_inline_result.id);
1082
+ } else
1083
+ (task.keyPath = prevKeyPath),
1084
+ (task.implicitSlot = prevImplicitSlot),
1085
+ request.pendingChunks++,
1086
+ (prevKeyPath = request.nextChunkId++),
1087
+ (prevImplicitSlot = logRecoverableError(request, value, task)),
1088
+ emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1089
+ (JSCompiler_inline_result = parentPropertyName
1090
+ ? "$L" + prevKeyPath.toString(16)
1091
+ : serializeByValueID(prevKeyPath));
1092
+ }
1093
+ return JSCompiler_inline_result;
1094
+ },
1095
+ thenableState: null
1096
+ };
1097
+ abortSet.add(task);
1098
+ return task;
1099
+ }
1100
+ function serializeByValueID(id) {
1101
+ return "$" + id.toString(16);
1102
+ }
1103
+ function encodeReferenceChunk(request, id, reference) {
1104
+ request = stringify(reference);
1105
+ id = id.toString(16) + ":" + request + "\n";
1106
+ return stringToChunk(id);
1107
+ }
1108
+ function serializeClientReference(
1109
+ request,
1110
+ parent,
1111
+ parentPropertyName,
1112
+ clientReference
1113
+ ) {
1114
+ var clientReferenceKey = clientReference.$$id + "#" + clientReference.$$name,
1115
+ writtenClientReferences = request.writtenClientReferences,
1116
+ existingId = writtenClientReferences.get(clientReferenceKey);
1117
+ if (void 0 !== existingId)
1118
+ return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName
1119
+ ? "$L" + existingId.toString(16)
1120
+ : serializeByValueID(existingId);
1121
+ try {
1122
+ var clientReferenceMetadata = [
1123
+ clientReference.$$id,
1124
+ clientReference.$$name,
1125
+ clientReference.$$bundles
1126
+ ];
1127
+ request.pendingChunks++;
1128
+ var importId = request.nextChunkId++,
1129
+ json = stringify(clientReferenceMetadata),
1130
+ row = importId.toString(16) + ":I" + json + "\n",
1131
+ processedChunk = stringToChunk(row);
1132
+ request.completedImportChunks.push(processedChunk);
1133
+ writtenClientReferences.set(clientReferenceKey, importId);
1134
+ return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName
1135
+ ? "$L" + importId.toString(16)
1136
+ : serializeByValueID(importId);
1137
+ } catch (x) {
1138
+ return (
1139
+ request.pendingChunks++,
1140
+ (parent = request.nextChunkId++),
1141
+ (parentPropertyName = logRecoverableError(request, x, null)),
1142
+ emitErrorChunk(request, parent, parentPropertyName),
1143
+ serializeByValueID(parent)
1144
+ );
1145
+ }
1146
+ }
1147
+ function outlineModel(request, value) {
1148
+ value = createTask(request, value, null, !1, request.abortableTasks);
1149
+ retryTask(request, value);
1150
+ return value.id;
1151
+ }
1152
+ function serializeTypedArray(request, tag, typedArray) {
1153
+ request.pendingChunks++;
1154
+ var bufferId = request.nextChunkId++;
1155
+ emitTypedArrayChunk(request, bufferId, tag, typedArray);
1156
+ return serializeByValueID(bufferId);
1157
+ }
1158
+ function serializeBlob(request, blob) {
1159
+ function progress(entry) {
1160
+ if (!aborted)
1161
+ if (entry.done)
1162
+ request.abortListeners.delete(abortBlob),
1163
+ (aborted = !0),
1164
+ pingTask(request, newTask);
1165
+ else
1166
+ return (
1167
+ model.push(entry.value), reader.read().then(progress).catch(error)
1168
+ );
1169
+ }
1170
+ function error(reason) {
1171
+ if (!aborted) {
1172
+ aborted = !0;
1173
+ request.abortListeners.delete(abortBlob);
1174
+ var digest = logRecoverableError(request, reason, newTask);
1175
+ emitErrorChunk(request, newTask.id, digest);
1176
+ enqueueFlush(request);
1177
+ reader.cancel(reason).then(error, error);
1178
+ }
1179
+ }
1180
+ function abortBlob(reason) {
1181
+ if (!aborted) {
1182
+ aborted = !0;
1183
+ request.abortListeners.delete(abortBlob);
1184
+ var digest = logRecoverableError(request, reason, newTask);
1185
+ emitErrorChunk(request, newTask.id, digest);
1186
+ enqueueFlush(request);
1187
+ reader.cancel(reason).then(error, error);
1188
+ }
1189
+ }
1190
+ var model = [blob.type],
1191
+ newTask = createTask(request, model, null, !1, request.abortableTasks),
1192
+ reader = blob.stream().getReader(),
1193
+ aborted = !1;
1194
+ request.abortListeners.add(abortBlob);
1195
+ reader.read().then(progress).catch(error);
1196
+ return "$B" + newTask.id.toString(16);
1197
+ }
1198
+ var modelRoot = !1;
1199
+ function renderModelDestructive(
1200
+ request,
1201
+ task,
1202
+ parent,
1203
+ parentPropertyName,
1204
+ value
1205
+ ) {
1206
+ task.model = value;
1207
+ if (value === REACT_ELEMENT_TYPE) return "$";
1208
+ if (null === value) return null;
1209
+ if ("object" === typeof value) {
1210
+ switch (value.$$typeof) {
1211
+ case REACT_ELEMENT_TYPE:
1212
+ var elementReference = null,
1213
+ writtenObjects = request.writtenObjects;
1214
+ if (null === task.keyPath && !task.implicitSlot) {
1215
+ var existingReference = writtenObjects.get(value);
1216
+ if (void 0 !== existingReference)
1217
+ if (modelRoot === value) modelRoot = null;
1218
+ else return existingReference;
1219
+ else
1220
+ -1 === parentPropertyName.indexOf(":") &&
1221
+ ((parent = writtenObjects.get(parent)),
1222
+ void 0 !== parent &&
1223
+ ((elementReference = parent + ":" + parentPropertyName),
1224
+ writtenObjects.set(value, elementReference)));
1225
+ }
1226
+ parentPropertyName = value.props;
1227
+ parent = parentPropertyName.ref;
1228
+ request = renderElement(
1229
+ request,
1230
+ task,
1231
+ value.type,
1232
+ value.key,
1233
+ void 0 !== parent ? parent : null,
1234
+ parentPropertyName
1235
+ );
1236
+ "object" === typeof request &&
1237
+ null !== request &&
1238
+ null !== elementReference &&
1239
+ (writtenObjects.has(request) ||
1240
+ writtenObjects.set(request, elementReference));
1241
+ return request;
1242
+ case REACT_LAZY_TYPE:
1243
+ task.thenableState = null;
1244
+ parentPropertyName = value._init;
1245
+ value = parentPropertyName(value._payload);
1246
+ if (12 === request.status) throw null;
1247
+ return renderModelDestructive(request, task, emptyRoot, "", value);
1248
+ case REACT_LEGACY_ELEMENT_TYPE:
1249
+ throw Error(
1250
+ '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.'
1251
+ );
1252
+ }
1253
+ if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
1254
+ return serializeClientReference(
1255
+ request,
1256
+ parent,
1257
+ parentPropertyName,
1258
+ value
1259
+ );
1260
+ if (
1261
+ void 0 !== request.temporaryReferences &&
1262
+ ((elementReference = request.temporaryReferences.get(value)),
1263
+ void 0 !== elementReference)
1264
+ )
1265
+ return "$T" + elementReference;
1266
+ elementReference = request.writtenObjects;
1267
+ writtenObjects = elementReference.get(value);
1268
+ if ("function" === typeof value.then) {
1269
+ if (void 0 !== writtenObjects) {
1270
+ if (null !== task.keyPath || task.implicitSlot)
1271
+ return "$@" + serializeThenable(request, task, value).toString(16);
1272
+ if (modelRoot === value) modelRoot = null;
1273
+ else return writtenObjects;
1274
+ }
1275
+ request = "$@" + serializeThenable(request, task, value).toString(16);
1276
+ elementReference.set(value, request);
1277
+ return request;
1278
+ }
1279
+ if (void 0 !== writtenObjects)
1280
+ if (modelRoot === value) modelRoot = null;
1281
+ else return writtenObjects;
1282
+ else if (
1283
+ -1 === parentPropertyName.indexOf(":") &&
1284
+ ((writtenObjects = elementReference.get(parent)),
1285
+ void 0 !== writtenObjects)
1286
+ ) {
1287
+ existingReference = parentPropertyName;
1288
+ if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE)
1289
+ switch (parentPropertyName) {
1290
+ case "1":
1291
+ existingReference = "type";
1292
+ break;
1293
+ case "2":
1294
+ existingReference = "key";
1295
+ break;
1296
+ case "3":
1297
+ existingReference = "props";
1298
+ break;
1299
+ case "4":
1300
+ existingReference = "_owner";
1301
+ }
1302
+ elementReference.set(value, writtenObjects + ":" + existingReference);
1303
+ }
1304
+ if (isArrayImpl(value)) return renderFragment(request, task, value);
1305
+ if (value instanceof Map)
1306
+ return (
1307
+ (value = Array.from(value)),
1308
+ "$Q" + outlineModel(request, value).toString(16)
1309
+ );
1310
+ if (value instanceof Set)
1311
+ return (
1312
+ (value = Array.from(value)),
1313
+ "$W" + outlineModel(request, value).toString(16)
1314
+ );
1315
+ if ("function" === typeof FormData && value instanceof FormData)
1316
+ return (
1317
+ (value = Array.from(value.entries())),
1318
+ "$K" + outlineModel(request, value).toString(16)
1319
+ );
1320
+ if (value instanceof Error) return "$Z";
1321
+ if (value instanceof ArrayBuffer)
1322
+ return serializeTypedArray(request, "A", new Uint8Array(value));
1323
+ if (value instanceof Int8Array)
1324
+ return serializeTypedArray(request, "O", value);
1325
+ if (value instanceof Uint8Array)
1326
+ return serializeTypedArray(request, "o", value);
1327
+ if (value instanceof Uint8ClampedArray)
1328
+ return serializeTypedArray(request, "U", value);
1329
+ if (value instanceof Int16Array)
1330
+ return serializeTypedArray(request, "S", value);
1331
+ if (value instanceof Uint16Array)
1332
+ return serializeTypedArray(request, "s", value);
1333
+ if (value instanceof Int32Array)
1334
+ return serializeTypedArray(request, "L", value);
1335
+ if (value instanceof Uint32Array)
1336
+ return serializeTypedArray(request, "l", value);
1337
+ if (value instanceof Float32Array)
1338
+ return serializeTypedArray(request, "G", value);
1339
+ if (value instanceof Float64Array)
1340
+ return serializeTypedArray(request, "g", value);
1341
+ if (value instanceof BigInt64Array)
1342
+ return serializeTypedArray(request, "M", value);
1343
+ if (value instanceof BigUint64Array)
1344
+ return serializeTypedArray(request, "m", value);
1345
+ if (value instanceof DataView)
1346
+ return serializeTypedArray(request, "V", value);
1347
+ if ("function" === typeof Blob && value instanceof Blob)
1348
+ return serializeBlob(request, value);
1349
+ if ((elementReference = getIteratorFn(value)))
1350
+ return (
1351
+ (parentPropertyName = elementReference.call(value)),
1352
+ parentPropertyName === value
1353
+ ? "$i" +
1354
+ outlineModel(request, Array.from(parentPropertyName)).toString(16)
1355
+ : renderFragment(request, task, Array.from(parentPropertyName))
1356
+ );
1357
+ if ("function" === typeof ReadableStream && value instanceof ReadableStream)
1358
+ return serializeReadableStream(request, task, value);
1359
+ elementReference = value[ASYNC_ITERATOR];
1360
+ if ("function" === typeof elementReference)
1361
+ return (
1362
+ null !== task.keyPath
1363
+ ? ((request = [
1364
+ REACT_ELEMENT_TYPE,
1365
+ REACT_FRAGMENT_TYPE,
1366
+ task.keyPath,
1367
+ { children: value }
1368
+ ]),
1369
+ (request = task.implicitSlot ? [request] : request))
1370
+ : ((parentPropertyName = elementReference.call(value)),
1371
+ (request = serializeAsyncIterable(
1372
+ request,
1373
+ task,
1374
+ value,
1375
+ parentPropertyName
1376
+ ))),
1377
+ request
1378
+ );
1379
+ if (value instanceof Date) return "$D" + value.toJSON();
1380
+ request = getPrototypeOf(value);
1381
+ if (
1382
+ request !== ObjectPrototype &&
1383
+ (null === request || null !== getPrototypeOf(request))
1384
+ )
1385
+ throw Error(
1386
+ "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported." +
1387
+ describeObjectForErrorMessage(parent, parentPropertyName)
1388
+ );
1389
+ return value;
1390
+ }
1391
+ if ("string" === typeof value) {
1392
+ if (
1393
+ "Z" === value[value.length - 1] &&
1394
+ parent[parentPropertyName] instanceof Date
1395
+ )
1396
+ return "$D" + value;
1397
+ if (1024 <= value.length && null !== byteLengthOfChunk)
1398
+ return (
1399
+ request.pendingChunks++,
1400
+ (task = request.nextChunkId++),
1401
+ emitTextChunk(request, task, value),
1402
+ serializeByValueID(task)
1403
+ );
1404
+ request = "$" === value[0] ? "$" + value : value;
1405
+ return request;
1406
+ }
1407
+ if ("boolean" === typeof value) return value;
1408
+ if ("number" === typeof value)
1409
+ return Number.isFinite(value)
1410
+ ? 0 === value && -Infinity === 1 / value
1411
+ ? "$-0"
1412
+ : value
1413
+ : Infinity === value
1414
+ ? "$Infinity"
1415
+ : -Infinity === value
1416
+ ? "$-Infinity"
1417
+ : "$NaN";
1418
+ if ("undefined" === typeof value) return "$undefined";
1419
+ if ("function" === typeof value) {
1420
+ if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
1421
+ return serializeClientReference(
1422
+ request,
1423
+ parent,
1424
+ parentPropertyName,
1425
+ value
1426
+ );
1427
+ if (value.$$typeof === SERVER_REFERENCE_TAG)
1428
+ return (
1429
+ (task = request.writtenServerReferences),
1430
+ (parentPropertyName = task.get(value)),
1431
+ void 0 !== parentPropertyName
1432
+ ? (request = "$F" + parentPropertyName.toString(16))
1433
+ : ((parentPropertyName = value.$$bound),
1434
+ (parentPropertyName =
1435
+ null === parentPropertyName
1436
+ ? null
1437
+ : Promise.resolve(parentPropertyName)),
1438
+ (request = outlineModel(request, {
1439
+ id: value.$$id,
1440
+ bound: parentPropertyName
1441
+ })),
1442
+ task.set(value, request),
1443
+ (request = "$F" + request.toString(16))),
1444
+ request
1445
+ );
1446
+ if (
1447
+ void 0 !== request.temporaryReferences &&
1448
+ ((request = request.temporaryReferences.get(value)), void 0 !== request)
1449
+ )
1450
+ return "$T" + request;
1451
+ if (value.$$typeof === TEMPORARY_REFERENCE_TAG)
1452
+ throw Error(
1453
+ "Could not reference an opaque temporary reference. This is likely due to misconfiguring the temporaryReferences options on the server."
1454
+ );
1455
+ if (/^on[A-Z]/.test(parentPropertyName))
1456
+ throw Error(
1457
+ "Event handlers cannot be passed to Client Component props." +
1458
+ describeObjectForErrorMessage(parent, parentPropertyName) +
1459
+ "\nIf you need interactivity, consider converting part of this to a Client Component."
1460
+ );
1461
+ throw Error(
1462
+ 'Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.' +
1463
+ describeObjectForErrorMessage(parent, parentPropertyName)
1464
+ );
1465
+ }
1466
+ if ("symbol" === typeof value) {
1467
+ task = request.writtenSymbols;
1468
+ elementReference = task.get(value);
1469
+ if (void 0 !== elementReference)
1470
+ return serializeByValueID(elementReference);
1471
+ elementReference = value.description;
1472
+ if (Symbol.for(elementReference) !== value)
1473
+ throw Error(
1474
+ "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1475
+ (value.description + ") cannot be found among global symbols.") +
1476
+ describeObjectForErrorMessage(parent, parentPropertyName)
1477
+ );
1478
+ request.pendingChunks++;
1479
+ parentPropertyName = request.nextChunkId++;
1480
+ parent = encodeReferenceChunk(
1481
+ request,
1482
+ parentPropertyName,
1483
+ "$S" + elementReference
1484
+ );
1485
+ request.completedImportChunks.push(parent);
1486
+ task.set(value, parentPropertyName);
1487
+ return serializeByValueID(parentPropertyName);
1488
+ }
1489
+ if ("bigint" === typeof value) return "$n" + value.toString(10);
1490
+ throw Error(
1491
+ "Type " +
1492
+ typeof value +
1493
+ " is not supported in Client Component props." +
1494
+ describeObjectForErrorMessage(parent, parentPropertyName)
1495
+ );
1496
+ }
1497
+ function logRecoverableError(request, error) {
1498
+ var prevRequest = currentRequest;
1499
+ currentRequest = null;
1500
+ try {
1501
+ var onError = request.onError;
1502
+ var errorDigest = supportsRequestStorage
1503
+ ? requestStorage.run(void 0, onError, error)
1504
+ : onError(error);
1505
+ } finally {
1506
+ currentRequest = prevRequest;
1507
+ }
1508
+ if (null != errorDigest && "string" !== typeof errorDigest)
1509
+ throw Error(
1510
+ 'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' +
1511
+ typeof errorDigest +
1512
+ '" instead'
1513
+ );
1514
+ return errorDigest || "";
1515
+ }
1516
+ function fatalError(request, error) {
1517
+ var onFatalError = request.onFatalError;
1518
+ onFatalError(error);
1519
+ null !== request.destination
1520
+ ? ((request.status = 14), closeWithError(request.destination, error))
1521
+ : ((request.status = 13), (request.fatalError = error));
1522
+ }
1523
+ function emitErrorChunk(request, id, digest) {
1524
+ digest = { digest: digest };
1525
+ id = id.toString(16) + ":E" + stringify(digest) + "\n";
1526
+ id = stringToChunk(id);
1527
+ request.completedErrorChunks.push(id);
1528
+ }
1529
+ function emitModelChunk(request, id, json) {
1530
+ id = id.toString(16) + ":" + json + "\n";
1531
+ id = stringToChunk(id);
1532
+ request.completedRegularChunks.push(id);
1533
+ }
1534
+ function emitTypedArrayChunk(request, id, tag, typedArray) {
1535
+ request.pendingChunks++;
1536
+ var buffer = new Uint8Array(
1537
+ typedArray.buffer,
1538
+ typedArray.byteOffset,
1539
+ typedArray.byteLength
1540
+ );
1541
+ typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1542
+ buffer = typedArray.byteLength;
1543
+ id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1544
+ id = stringToChunk(id);
1545
+ request.completedRegularChunks.push(id, typedArray);
1546
+ }
1547
+ function emitTextChunk(request, id, text) {
1548
+ if (null === byteLengthOfChunk)
1549
+ throw Error(
1550
+ "Existence of byteLengthOfChunk should have already been checked. This is a bug in React."
1551
+ );
1552
+ request.pendingChunks++;
1553
+ text = stringToChunk(text);
1554
+ var binaryLength = text.byteLength;
1555
+ id = id.toString(16) + ":T" + binaryLength.toString(16) + ",";
1556
+ id = stringToChunk(id);
1557
+ request.completedRegularChunks.push(id, text);
1558
+ }
1559
+ function emitChunk(request, task, value) {
1560
+ var id = task.id;
1561
+ "string" === typeof value && null !== byteLengthOfChunk
1562
+ ? emitTextChunk(request, id, value)
1563
+ : value instanceof ArrayBuffer
1564
+ ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1565
+ : value instanceof Int8Array
1566
+ ? emitTypedArrayChunk(request, id, "O", value)
1567
+ : value instanceof Uint8Array
1568
+ ? emitTypedArrayChunk(request, id, "o", value)
1569
+ : value instanceof Uint8ClampedArray
1570
+ ? emitTypedArrayChunk(request, id, "U", value)
1571
+ : value instanceof Int16Array
1572
+ ? emitTypedArrayChunk(request, id, "S", value)
1573
+ : value instanceof Uint16Array
1574
+ ? emitTypedArrayChunk(request, id, "s", value)
1575
+ : value instanceof Int32Array
1576
+ ? emitTypedArrayChunk(request, id, "L", value)
1577
+ : value instanceof Uint32Array
1578
+ ? emitTypedArrayChunk(request, id, "l", value)
1579
+ : value instanceof Float32Array
1580
+ ? emitTypedArrayChunk(request, id, "G", value)
1581
+ : value instanceof Float64Array
1582
+ ? emitTypedArrayChunk(request, id, "g", value)
1583
+ : value instanceof BigInt64Array
1584
+ ? emitTypedArrayChunk(request, id, "M", value)
1585
+ : value instanceof BigUint64Array
1586
+ ? emitTypedArrayChunk(request, id, "m", value)
1587
+ : value instanceof DataView
1588
+ ? emitTypedArrayChunk(request, id, "V", value)
1589
+ : ((value = stringify(value, task.toJSON)),
1590
+ emitModelChunk(request, task.id, value));
1591
+ }
1592
+ var emptyRoot = {};
1593
+ function retryTask(request, task) {
1594
+ if (0 === task.status) {
1595
+ task.status = 5;
1596
+ try {
1597
+ modelRoot = task.model;
1598
+ var resolvedModel = renderModelDestructive(
1599
+ request,
1600
+ task,
1601
+ emptyRoot,
1602
+ "",
1603
+ task.model
1604
+ );
1605
+ modelRoot = resolvedModel;
1606
+ task.keyPath = null;
1607
+ task.implicitSlot = !1;
1608
+ if ("object" === typeof resolvedModel && null !== resolvedModel)
1609
+ request.writtenObjects.set(resolvedModel, serializeByValueID(task.id)),
1610
+ emitChunk(request, task, resolvedModel);
1611
+ else {
1612
+ var json = stringify(resolvedModel);
1613
+ emitModelChunk(request, task.id, json);
1614
+ }
1615
+ request.abortableTasks.delete(task);
1616
+ task.status = 1;
1617
+ } catch (thrownValue) {
1618
+ if (12 === request.status) {
1619
+ request.abortableTasks.delete(task);
1620
+ task.status = 3;
1621
+ var model = stringify(serializeByValueID(request.fatalError));
1622
+ emitModelChunk(request, task.id, model);
1623
+ } else {
1624
+ var x =
1625
+ thrownValue === SuspenseException
1626
+ ? getSuspendedThenable()
1627
+ : thrownValue;
1628
+ if (
1629
+ "object" === typeof x &&
1630
+ null !== x &&
1631
+ "function" === typeof x.then
1632
+ ) {
1633
+ task.status = 0;
1634
+ task.thenableState = getThenableStateAfterSuspending();
1635
+ var ping = task.ping;
1636
+ x.then(ping, ping);
1637
+ } else {
1638
+ request.abortableTasks.delete(task);
1639
+ task.status = 4;
1640
+ var digest = logRecoverableError(request, x, task);
1641
+ emitErrorChunk(request, task.id, digest);
1642
+ }
1643
+ }
1644
+ } finally {
1645
+ }
1646
+ }
1647
+ }
1648
+ function performWork(request) {
1649
+ var prevDispatcher = ReactSharedInternalsServer.H;
1650
+ ReactSharedInternalsServer.H = HooksDispatcher;
1651
+ var prevRequest = currentRequest;
1652
+ currentRequest$1 = currentRequest = request;
1653
+ var hadAbortableTasks = 0 < request.abortableTasks.size;
1654
+ try {
1655
+ var pingedTasks = request.pingedTasks;
1656
+ request.pingedTasks = [];
1657
+ for (var i = 0; i < pingedTasks.length; i++)
1658
+ retryTask(request, pingedTasks[i]);
1659
+ null !== request.destination &&
1660
+ flushCompletedChunks(request, request.destination);
1661
+ if (hadAbortableTasks && 0 === request.abortableTasks.size) {
1662
+ var onAllReady = request.onAllReady;
1663
+ onAllReady();
1664
+ }
1665
+ } catch (error) {
1666
+ logRecoverableError(request, error, null), fatalError(request, error);
1667
+ } finally {
1668
+ (ReactSharedInternalsServer.H = prevDispatcher),
1669
+ (currentRequest$1 = null),
1670
+ (currentRequest = prevRequest);
1671
+ }
1672
+ }
1673
+ function flushCompletedChunks(request, destination) {
1674
+ currentView = new Uint8Array(2048);
1675
+ writtenBytes = 0;
1676
+ try {
1677
+ for (
1678
+ var importsChunks = request.completedImportChunks, i = 0;
1679
+ i < importsChunks.length;
1680
+ i++
1681
+ )
1682
+ request.pendingChunks--,
1683
+ writeChunkAndReturn(destination, importsChunks[i]);
1684
+ importsChunks.splice(0, i);
1685
+ var hintChunks = request.completedHintChunks;
1686
+ for (i = 0; i < hintChunks.length; i++)
1687
+ writeChunkAndReturn(destination, hintChunks[i]);
1688
+ hintChunks.splice(0, i);
1689
+ var regularChunks = request.completedRegularChunks;
1690
+ for (i = 0; i < regularChunks.length; i++)
1691
+ request.pendingChunks--,
1692
+ writeChunkAndReturn(destination, regularChunks[i]);
1693
+ regularChunks.splice(0, i);
1694
+ var errorChunks = request.completedErrorChunks;
1695
+ for (i = 0; i < errorChunks.length; i++)
1696
+ request.pendingChunks--, writeChunkAndReturn(destination, errorChunks[i]);
1697
+ errorChunks.splice(0, i);
1698
+ } finally {
1699
+ (request.flushScheduled = !1),
1700
+ currentView &&
1701
+ 0 < writtenBytes &&
1702
+ (destination.enqueue(
1703
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
1704
+ ),
1705
+ (currentView = null),
1706
+ (writtenBytes = 0));
1707
+ }
1708
+ 0 === request.pendingChunks &&
1709
+ ((request.status = 14), destination.close(), (request.destination = null));
1710
+ }
1711
+ function startWork(request) {
1712
+ request.flushScheduled = null !== request.destination;
1713
+ supportsRequestStorage
1714
+ ? scheduleMicrotask(function () {
1715
+ requestStorage.run(request, performWork, request);
1716
+ })
1717
+ : scheduleMicrotask(function () {
1718
+ return performWork(request);
1719
+ });
1720
+ setTimeout(function () {
1721
+ 10 === request.status && (request.status = 11);
1722
+ }, 0);
1723
+ }
1724
+ function enqueueFlush(request) {
1725
+ !1 === request.flushScheduled &&
1726
+ 0 === request.pingedTasks.length &&
1727
+ null !== request.destination &&
1728
+ ((request.flushScheduled = !0),
1729
+ setTimeout(function () {
1730
+ request.flushScheduled = !1;
1731
+ var destination = request.destination;
1732
+ destination && flushCompletedChunks(request, destination);
1733
+ }, 0));
1734
+ }
1735
+ function abort(request, reason) {
1736
+ try {
1737
+ 11 >= request.status && (request.status = 12);
1738
+ var abortableTasks = request.abortableTasks;
1739
+ if (0 < abortableTasks.size) {
1740
+ var error =
1741
+ void 0 === reason
1742
+ ? Error("The render was aborted by the server without a reason.")
1743
+ : "object" === typeof reason &&
1744
+ null !== reason &&
1745
+ "function" === typeof reason.then
1746
+ ? Error("The render was aborted by the server with a promise.")
1747
+ : reason,
1748
+ digest = logRecoverableError(request, error, null),
1749
+ errorId = request.nextChunkId++;
1750
+ request.fatalError = errorId;
1751
+ request.pendingChunks++;
1752
+ emitErrorChunk(request, errorId, digest, error);
1753
+ abortableTasks.forEach(function (task) {
1754
+ if (5 !== task.status) {
1755
+ task.status = 3;
1756
+ var ref = serializeByValueID(errorId);
1757
+ task = encodeReferenceChunk(request, task.id, ref);
1758
+ request.completedErrorChunks.push(task);
1759
+ }
1760
+ });
1761
+ abortableTasks.clear();
1762
+ var onAllReady = request.onAllReady;
1763
+ onAllReady();
1764
+ }
1765
+ var abortListeners = request.abortListeners;
1766
+ if (0 < abortListeners.size) {
1767
+ var error$23 =
1768
+ void 0 === reason
1769
+ ? Error("The render was aborted by the server without a reason.")
1770
+ : "object" === typeof reason &&
1771
+ null !== reason &&
1772
+ "function" === typeof reason.then
1773
+ ? Error("The render was aborted by the server with a promise.")
1774
+ : reason;
1775
+ abortListeners.forEach(function (callback) {
1776
+ return callback(error$23);
1777
+ });
1778
+ abortListeners.clear();
1779
+ }
1780
+ null !== request.destination &&
1781
+ flushCompletedChunks(request, request.destination);
1782
+ } catch (error$24) {
1783
+ logRecoverableError(request, error$24, null), fatalError(request, error$24);
1784
+ }
1785
+ }
1786
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
1787
+ function Chunk(status, value, reason, response) {
1788
+ this.status = status;
1789
+ this.value = value;
1790
+ this.reason = reason;
1791
+ this._response = response;
1792
+ }
1793
+ Chunk.prototype = Object.create(Promise.prototype);
1794
+ Chunk.prototype.then = function (resolve, reject) {
1795
+ switch (this.status) {
1796
+ case "resolved_model":
1797
+ initializeModelChunk(this);
1798
+ }
1799
+ switch (this.status) {
1800
+ case "fulfilled":
1801
+ resolve(this.value);
1802
+ break;
1803
+ case "pending":
1804
+ case "blocked":
1805
+ case "cyclic":
1806
+ resolve &&
1807
+ (null === this.value && (this.value = []), this.value.push(resolve));
1808
+ reject &&
1809
+ (null === this.reason && (this.reason = []), this.reason.push(reject));
1810
+ break;
1811
+ default:
1812
+ reject(this.reason);
1813
+ }
1814
+ };
1815
+ function createPendingChunk(response) {
1816
+ return new Chunk("pending", null, null, response);
1817
+ }
1818
+ function wakeChunk(listeners, value) {
1819
+ for (var i = 0; i < listeners.length; i++) (0, listeners[i])(value);
1820
+ }
1821
+ function triggerErrorOnChunk(chunk, error) {
1822
+ if ("pending" !== chunk.status && "blocked" !== chunk.status)
1823
+ chunk.reason.error(error);
1824
+ else {
1825
+ var listeners = chunk.reason;
1826
+ chunk.status = "rejected";
1827
+ chunk.reason = error;
1828
+ null !== listeners && wakeChunk(listeners, error);
1829
+ }
1830
+ }
1831
+ function resolveModelChunk(chunk, value, id) {
1832
+ if ("pending" !== chunk.status)
1833
+ (chunk = chunk.reason),
1834
+ "C" === value[0]
1835
+ ? chunk.close("C" === value ? '"$undefined"' : value.slice(1))
1836
+ : chunk.enqueueModel(value);
1837
+ else {
1838
+ var resolveListeners = chunk.value,
1839
+ rejectListeners = chunk.reason;
1840
+ chunk.status = "resolved_model";
1841
+ chunk.value = value;
1842
+ chunk.reason = id;
1843
+ if (null !== resolveListeners)
1844
+ switch ((initializeModelChunk(chunk), chunk.status)) {
1845
+ case "fulfilled":
1846
+ wakeChunk(resolveListeners, chunk.value);
1847
+ break;
1848
+ case "pending":
1849
+ case "blocked":
1850
+ case "cyclic":
1851
+ if (chunk.value)
1852
+ for (value = 0; value < resolveListeners.length; value++)
1853
+ chunk.value.push(resolveListeners[value]);
1854
+ else chunk.value = resolveListeners;
1855
+ if (chunk.reason) {
1856
+ if (rejectListeners)
1857
+ for (value = 0; value < rejectListeners.length; value++)
1858
+ chunk.reason.push(rejectListeners[value]);
1859
+ } else chunk.reason = rejectListeners;
1860
+ break;
1861
+ case "rejected":
1862
+ rejectListeners && wakeChunk(rejectListeners, chunk.reason);
1863
+ }
1864
+ }
1865
+ }
1866
+ function createResolvedIteratorResultChunk(response, value, done) {
1867
+ return new Chunk(
1868
+ "resolved_model",
1869
+ (done ? '{"done":true,"value":' : '{"done":false,"value":') + value + "}",
1870
+ -1,
1871
+ response
1872
+ );
1873
+ }
1874
+ function resolveIteratorResultChunk(chunk, value, done) {
1875
+ resolveModelChunk(
1876
+ chunk,
1877
+ (done ? '{"done":true,"value":' : '{"done":false,"value":') + value + "}",
1878
+ -1
1879
+ );
1880
+ }
1881
+ function loadServerReference$1(
1882
+ response,
1883
+ id,
1884
+ bound,
1885
+ parentChunk,
1886
+ parentObject,
1887
+ key
1888
+ ) {
1889
+ var serverReference = resolveServerReference(response._bundlerConfig, id);
1890
+ id = preloadModule$1(serverReference);
1891
+ if (bound)
1892
+ bound = Promise.all([bound, id]).then(function (_ref) {
1893
+ _ref = _ref[0];
1894
+ var fn = requireModule(serverReference);
1895
+ return fn.bind.apply(fn, [null].concat(_ref));
1896
+ });
1897
+ else if (id)
1898
+ bound = Promise.resolve(id).then(function () {
1899
+ return requireModule(serverReference);
1900
+ });
1901
+ else return requireModule(serverReference);
1902
+ bound.then(
1903
+ createModelResolver(
1904
+ parentChunk,
1905
+ parentObject,
1906
+ key,
1907
+ !1,
1908
+ response,
1909
+ createModel,
1910
+ []
1911
+ ),
1912
+ createModelReject(parentChunk)
1913
+ );
1914
+ return null;
1915
+ }
1916
+ function reviveModel(response, parentObj, parentKey, value, reference) {
1917
+ if ("string" === typeof value)
1918
+ return parseModelString(response, parentObj, parentKey, value, reference);
1919
+ if ("object" === typeof value && null !== value)
1920
+ if (
1921
+ (void 0 !== reference &&
1922
+ void 0 !== response._temporaryReferences &&
1923
+ response._temporaryReferences.set(value, reference),
1924
+ Array.isArray(value))
1925
+ )
1926
+ for (var i = 0; i < value.length; i++)
1927
+ value[i] = reviveModel(
1928
+ response,
1929
+ value,
1930
+ "" + i,
1931
+ value[i],
1932
+ void 0 !== reference ? reference + ":" + i : void 0
1933
+ );
1934
+ else
1935
+ for (i in value)
1936
+ hasOwnProperty.call(value, i) &&
1937
+ ((parentObj =
1938
+ void 0 !== reference && -1 === i.indexOf(":")
1939
+ ? reference + ":" + i
1940
+ : void 0),
1941
+ (parentObj = reviveModel(response, value, i, value[i], parentObj)),
1942
+ void 0 !== parentObj ? (value[i] = parentObj) : delete value[i]);
1943
+ return value;
1944
+ }
1945
+ var initializingChunk = null,
1946
+ initializingChunkBlockedModel = null;
1947
+ function initializeModelChunk(chunk) {
1948
+ var prevChunk = initializingChunk,
1949
+ prevBlocked = initializingChunkBlockedModel;
1950
+ initializingChunk = chunk;
1951
+ initializingChunkBlockedModel = null;
1952
+ var rootReference = -1 === chunk.reason ? void 0 : chunk.reason.toString(16),
1953
+ resolvedModel = chunk.value;
1954
+ chunk.status = "cyclic";
1955
+ chunk.value = null;
1956
+ chunk.reason = null;
1957
+ try {
1958
+ var rawModel = JSON.parse(resolvedModel),
1959
+ value = reviveModel(
1960
+ chunk._response,
1961
+ { "": rawModel },
1962
+ "",
1963
+ rawModel,
1964
+ rootReference
1965
+ );
1966
+ if (
1967
+ null !== initializingChunkBlockedModel &&
1968
+ 0 < initializingChunkBlockedModel.deps
1969
+ )
1970
+ (initializingChunkBlockedModel.value = value), (chunk.status = "blocked");
1971
+ else {
1972
+ var resolveListeners = chunk.value;
1973
+ chunk.status = "fulfilled";
1974
+ chunk.value = value;
1975
+ null !== resolveListeners && wakeChunk(resolveListeners, value);
1976
+ }
1977
+ } catch (error) {
1978
+ (chunk.status = "rejected"), (chunk.reason = error);
1979
+ } finally {
1980
+ (initializingChunk = prevChunk),
1981
+ (initializingChunkBlockedModel = prevBlocked);
1982
+ }
1983
+ }
1984
+ function reportGlobalError(response, error) {
1985
+ response._chunks.forEach(function (chunk) {
1986
+ "pending" === chunk.status && triggerErrorOnChunk(chunk, error);
1987
+ });
1988
+ }
1989
+ function getChunk(response, id) {
1990
+ var chunks = response._chunks,
1991
+ chunk = chunks.get(id);
1992
+ chunk ||
1993
+ ((chunk = response._formData.get(response._prefix + id)),
1994
+ (chunk =
1995
+ null != chunk
1996
+ ? new Chunk("resolved_model", chunk, id, response)
1997
+ : createPendingChunk(response)),
1998
+ chunks.set(id, chunk));
1999
+ return chunk;
2000
+ }
2001
+ function createModelResolver(
2002
+ chunk,
2003
+ parentObject,
2004
+ key,
2005
+ cyclic,
2006
+ response,
2007
+ map,
2008
+ path
2009
+ ) {
2010
+ if (initializingChunkBlockedModel) {
2011
+ var blocked = initializingChunkBlockedModel;
2012
+ cyclic || blocked.deps++;
2013
+ } else
2014
+ blocked = initializingChunkBlockedModel = {
2015
+ deps: cyclic ? 0 : 1,
2016
+ value: null
2017
+ };
2018
+ return function (value) {
2019
+ for (var i = 1; i < path.length; i++) value = value[path[i]];
2020
+ parentObject[key] = map(response, value);
2021
+ "" === key && null === blocked.value && (blocked.value = parentObject[key]);
2022
+ blocked.deps--;
2023
+ 0 === blocked.deps &&
2024
+ "blocked" === chunk.status &&
2025
+ ((value = chunk.value),
2026
+ (chunk.status = "fulfilled"),
2027
+ (chunk.value = blocked.value),
2028
+ null !== value && wakeChunk(value, blocked.value));
2029
+ };
2030
+ }
2031
+ function createModelReject(chunk) {
2032
+ return function (error) {
2033
+ return triggerErrorOnChunk(chunk, error);
2034
+ };
2035
+ }
2036
+ function getOutlinedModel(response, reference, parentObject, key, map) {
2037
+ reference = reference.split(":");
2038
+ var id = parseInt(reference[0], 16);
2039
+ id = getChunk(response, id);
2040
+ switch (id.status) {
2041
+ case "resolved_model":
2042
+ initializeModelChunk(id);
2043
+ }
2044
+ switch (id.status) {
2045
+ case "fulfilled":
2046
+ parentObject = id.value;
2047
+ for (key = 1; key < reference.length; key++)
2048
+ parentObject = parentObject[reference[key]];
2049
+ return map(response, parentObject);
2050
+ case "pending":
2051
+ case "blocked":
2052
+ case "cyclic":
2053
+ var parentChunk = initializingChunk;
2054
+ id.then(
2055
+ createModelResolver(
2056
+ parentChunk,
2057
+ parentObject,
2058
+ key,
2059
+ "cyclic" === id.status,
2060
+ response,
2061
+ map,
2062
+ reference
2063
+ ),
2064
+ createModelReject(parentChunk)
2065
+ );
2066
+ return null;
2067
+ default:
2068
+ throw id.reason;
2069
+ }
2070
+ }
2071
+ function createMap(response, model) {
2072
+ return new Map(model);
2073
+ }
2074
+ function createSet(response, model) {
2075
+ return new Set(model);
2076
+ }
2077
+ function extractIterator(response, model) {
2078
+ return model[Symbol.iterator]();
2079
+ }
2080
+ function createModel(response, model) {
2081
+ return model;
2082
+ }
2083
+ function parseTypedArray(
2084
+ response,
2085
+ reference,
2086
+ constructor,
2087
+ bytesPerElement,
2088
+ parentObject,
2089
+ parentKey
2090
+ ) {
2091
+ reference = parseInt(reference.slice(2), 16);
2092
+ reference = response._formData.get(response._prefix + reference);
2093
+ reference =
2094
+ constructor === ArrayBuffer
2095
+ ? reference.arrayBuffer()
2096
+ : reference.arrayBuffer().then(function (buffer) {
2097
+ return new constructor(buffer);
2098
+ });
2099
+ bytesPerElement = initializingChunk;
2100
+ reference.then(
2101
+ createModelResolver(
2102
+ bytesPerElement,
2103
+ parentObject,
2104
+ parentKey,
2105
+ !1,
2106
+ response,
2107
+ createModel,
2108
+ []
2109
+ ),
2110
+ createModelReject(bytesPerElement)
2111
+ );
2112
+ return null;
2113
+ }
2114
+ function resolveStream(response, id, stream, controller) {
2115
+ var chunks = response._chunks;
2116
+ stream = new Chunk("fulfilled", stream, controller, response);
2117
+ chunks.set(id, stream);
2118
+ response = response._formData.getAll(response._prefix + id);
2119
+ for (id = 0; id < response.length; id++)
2120
+ (chunks = response[id]),
2121
+ "C" === chunks[0]
2122
+ ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2123
+ : controller.enqueueModel(chunks);
2124
+ }
2125
+ function parseReadableStream(response, reference, type) {
2126
+ reference = parseInt(reference.slice(2), 16);
2127
+ var controller = null;
2128
+ type = new ReadableStream({
2129
+ type: type,
2130
+ start: function (c) {
2131
+ controller = c;
2132
+ }
2133
+ });
2134
+ var previousBlockedChunk = null;
2135
+ resolveStream(response, reference, type, {
2136
+ enqueueModel: function (json) {
2137
+ if (null === previousBlockedChunk) {
2138
+ var chunk = new Chunk("resolved_model", json, -1, response);
2139
+ initializeModelChunk(chunk);
2140
+ "fulfilled" === chunk.status
2141
+ ? controller.enqueue(chunk.value)
2142
+ : (chunk.then(
2143
+ function (v) {
2144
+ return controller.enqueue(v);
2145
+ },
2146
+ function (e) {
2147
+ return controller.error(e);
2148
+ }
2149
+ ),
2150
+ (previousBlockedChunk = chunk));
2151
+ } else {
2152
+ chunk = previousBlockedChunk;
2153
+ var chunk$27 = createPendingChunk(response);
2154
+ chunk$27.then(
2155
+ function (v) {
2156
+ return controller.enqueue(v);
2157
+ },
2158
+ function (e) {
2159
+ return controller.error(e);
2160
+ }
2161
+ );
2162
+ previousBlockedChunk = chunk$27;
2163
+ chunk.then(function () {
2164
+ previousBlockedChunk === chunk$27 && (previousBlockedChunk = null);
2165
+ resolveModelChunk(chunk$27, json, -1);
2166
+ });
2167
+ }
2168
+ },
2169
+ close: function () {
2170
+ if (null === previousBlockedChunk) controller.close();
2171
+ else {
2172
+ var blockedChunk = previousBlockedChunk;
2173
+ previousBlockedChunk = null;
2174
+ blockedChunk.then(function () {
2175
+ return controller.close();
2176
+ });
2177
+ }
2178
+ },
2179
+ error: function (error) {
2180
+ if (null === previousBlockedChunk) controller.error(error);
2181
+ else {
2182
+ var blockedChunk = previousBlockedChunk;
2183
+ previousBlockedChunk = null;
2184
+ blockedChunk.then(function () {
2185
+ return controller.error(error);
2186
+ });
2187
+ }
2188
+ }
2189
+ });
2190
+ return type;
2191
+ }
2192
+ function asyncIterator() {
2193
+ return this;
2194
+ }
2195
+ function createIterator(next) {
2196
+ next = { next: next };
2197
+ next[ASYNC_ITERATOR] = asyncIterator;
2198
+ return next;
2199
+ }
2200
+ function parseAsyncIterable(response, reference, iterator) {
2201
+ reference = parseInt(reference.slice(2), 16);
2202
+ var buffer = [],
2203
+ closed = !1,
2204
+ nextWriteIndex = 0,
2205
+ $jscomp$compprop2 = {};
2206
+ $jscomp$compprop2 =
2207
+ (($jscomp$compprop2[ASYNC_ITERATOR] = function () {
2208
+ var nextReadIndex = 0;
2209
+ return createIterator(function (arg) {
2210
+ if (void 0 !== arg)
2211
+ throw Error(
2212
+ "Values cannot be passed to next() of AsyncIterables passed to Client Components."
2213
+ );
2214
+ if (nextReadIndex === buffer.length) {
2215
+ if (closed)
2216
+ return new Chunk(
2217
+ "fulfilled",
2218
+ { done: !0, value: void 0 },
2219
+ null,
2220
+ response
2221
+ );
2222
+ buffer[nextReadIndex] = createPendingChunk(response);
2223
+ }
2224
+ return buffer[nextReadIndex++];
2225
+ });
2226
+ }),
2227
+ $jscomp$compprop2);
2228
+ iterator = iterator ? $jscomp$compprop2[ASYNC_ITERATOR]() : $jscomp$compprop2;
2229
+ resolveStream(response, reference, iterator, {
2230
+ enqueueModel: function (value) {
2231
+ nextWriteIndex === buffer.length
2232
+ ? (buffer[nextWriteIndex] = createResolvedIteratorResultChunk(
2233
+ response,
2234
+ value,
2235
+ !1
2236
+ ))
2237
+ : resolveIteratorResultChunk(buffer[nextWriteIndex], value, !1);
2238
+ nextWriteIndex++;
2239
+ },
2240
+ close: function (value) {
2241
+ closed = !0;
2242
+ nextWriteIndex === buffer.length
2243
+ ? (buffer[nextWriteIndex] = createResolvedIteratorResultChunk(
2244
+ response,
2245
+ value,
2246
+ !0
2247
+ ))
2248
+ : resolveIteratorResultChunk(buffer[nextWriteIndex], value, !0);
2249
+ for (nextWriteIndex++; nextWriteIndex < buffer.length; )
2250
+ resolveIteratorResultChunk(
2251
+ buffer[nextWriteIndex++],
2252
+ '"$undefined"',
2253
+ !0
2254
+ );
2255
+ },
2256
+ error: function (error) {
2257
+ closed = !0;
2258
+ for (
2259
+ nextWriteIndex === buffer.length &&
2260
+ (buffer[nextWriteIndex] = createPendingChunk(response));
2261
+ nextWriteIndex < buffer.length;
2262
+
2263
+ )
2264
+ triggerErrorOnChunk(buffer[nextWriteIndex++], error);
2265
+ }
2266
+ });
2267
+ return iterator;
2268
+ }
2269
+ function parseModelString(response, obj, key, value, reference) {
2270
+ if ("$" === value[0]) {
2271
+ switch (value[1]) {
2272
+ case "$":
2273
+ return value.slice(1);
2274
+ case "@":
2275
+ return (obj = parseInt(value.slice(2), 16)), getChunk(response, obj);
2276
+ case "F":
2277
+ return (
2278
+ (value = value.slice(2)),
2279
+ (value = getOutlinedModel(response, value, obj, key, createModel)),
2280
+ loadServerReference$1(
2281
+ response,
2282
+ value.id,
2283
+ value.bound,
2284
+ initializingChunk,
2285
+ obj,
2286
+ key
2287
+ )
2288
+ );
2289
+ case "T":
2290
+ if (void 0 === reference || void 0 === response._temporaryReferences)
2291
+ throw Error(
2292
+ "Could not reference an opaque temporary reference. This is likely due to misconfiguring the temporaryReferences options on the server."
2293
+ );
2294
+ return createTemporaryReference(
2295
+ response._temporaryReferences,
2296
+ reference
2297
+ );
2298
+ case "Q":
2299
+ return (
2300
+ (value = value.slice(2)),
2301
+ getOutlinedModel(response, value, obj, key, createMap)
2302
+ );
2303
+ case "W":
2304
+ return (
2305
+ (value = value.slice(2)),
2306
+ getOutlinedModel(response, value, obj, key, createSet)
2307
+ );
2308
+ case "K":
2309
+ obj = value.slice(2);
2310
+ var formPrefix = response._prefix + obj + "_",
2311
+ data = new FormData();
2312
+ response._formData.forEach(function (entry, entryKey) {
2313
+ entryKey.startsWith(formPrefix) &&
2314
+ data.append(entryKey.slice(formPrefix.length), entry);
2315
+ });
2316
+ return data;
2317
+ case "i":
2318
+ return (
2319
+ (value = value.slice(2)),
2320
+ getOutlinedModel(response, value, obj, key, extractIterator)
2321
+ );
2322
+ case "I":
2323
+ return Infinity;
2324
+ case "-":
2325
+ return "$-0" === value ? -0 : -Infinity;
2326
+ case "N":
2327
+ return NaN;
2328
+ case "u":
2329
+ return;
2330
+ case "D":
2331
+ return new Date(Date.parse(value.slice(2)));
2332
+ case "n":
2333
+ return BigInt(value.slice(2));
2334
+ }
2335
+ switch (value[1]) {
2336
+ case "A":
2337
+ return parseTypedArray(response, value, ArrayBuffer, 1, obj, key);
2338
+ case "O":
2339
+ return parseTypedArray(response, value, Int8Array, 1, obj, key);
2340
+ case "o":
2341
+ return parseTypedArray(response, value, Uint8Array, 1, obj, key);
2342
+ case "U":
2343
+ return parseTypedArray(response, value, Uint8ClampedArray, 1, obj, key);
2344
+ case "S":
2345
+ return parseTypedArray(response, value, Int16Array, 2, obj, key);
2346
+ case "s":
2347
+ return parseTypedArray(response, value, Uint16Array, 2, obj, key);
2348
+ case "L":
2349
+ return parseTypedArray(response, value, Int32Array, 4, obj, key);
2350
+ case "l":
2351
+ return parseTypedArray(response, value, Uint32Array, 4, obj, key);
2352
+ case "G":
2353
+ return parseTypedArray(response, value, Float32Array, 4, obj, key);
2354
+ case "g":
2355
+ return parseTypedArray(response, value, Float64Array, 8, obj, key);
2356
+ case "M":
2357
+ return parseTypedArray(response, value, BigInt64Array, 8, obj, key);
2358
+ case "m":
2359
+ return parseTypedArray(response, value, BigUint64Array, 8, obj, key);
2360
+ case "V":
2361
+ return parseTypedArray(response, value, DataView, 1, obj, key);
2362
+ case "B":
2363
+ return (
2364
+ (obj = parseInt(value.slice(2), 16)),
2365
+ response._formData.get(response._prefix + obj)
2366
+ );
2367
+ }
2368
+ switch (value[1]) {
2369
+ case "R":
2370
+ return parseReadableStream(response, value, void 0);
2371
+ case "r":
2372
+ return parseReadableStream(response, value, "bytes");
2373
+ case "X":
2374
+ return parseAsyncIterable(response, value, !1);
2375
+ case "x":
2376
+ return parseAsyncIterable(response, value, !0);
2377
+ }
2378
+ value = value.slice(1);
2379
+ return getOutlinedModel(response, value, obj, key, createModel);
2380
+ }
2381
+ return value;
2382
+ }
2383
+ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
2384
+ var backingFormData =
2385
+ 3 < arguments.length && void 0 !== arguments[3]
2386
+ ? arguments[3]
2387
+ : new FormData(),
2388
+ chunks = new Map();
2389
+ return {
2390
+ _bundlerConfig: bundlerConfig,
2391
+ _prefix: formFieldPrefix,
2392
+ _formData: backingFormData,
2393
+ _chunks: chunks,
2394
+ _temporaryReferences: temporaryReferences
2395
+ };
2396
+ }
2397
+ function close(response) {
2398
+ reportGlobalError(response, Error("Connection closed."));
2399
+ }
2400
+ function loadServerReference(bundlerConfig, id, bound) {
2401
+ var serverReference = resolveServerReference(bundlerConfig, id);
2402
+ bundlerConfig = preloadModule$1(serverReference);
2403
+ return bound
2404
+ ? Promise.all([bound, bundlerConfig]).then(function (_ref) {
2405
+ _ref = _ref[0];
2406
+ var fn = requireModule(serverReference);
2407
+ return fn.bind.apply(fn, [null].concat(_ref));
2408
+ })
2409
+ : bundlerConfig
2410
+ ? Promise.resolve(bundlerConfig).then(function () {
2411
+ return requireModule(serverReference);
2412
+ })
2413
+ : Promise.resolve(requireModule(serverReference));
2414
+ }
2415
+ function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
2416
+ body = createResponse(serverManifest, formFieldPrefix, void 0, body);
2417
+ close(body);
2418
+ body = getChunk(body, 0);
2419
+ body.then(function () {});
2420
+ if ("fulfilled" !== body.status) throw body.reason;
2421
+ return body.value;
2422
+ }
2423
+ function decodeAction$1(body, serverManifest) {
2424
+ var formData = new FormData(),
2425
+ action = null;
2426
+ body.forEach(function (value, key) {
2427
+ key.startsWith("$ACTION_")
2428
+ ? key.startsWith("$ACTION_REF_")
2429
+ ? ((value = "$ACTION_" + key.slice(12) + ":"),
2430
+ (value = decodeBoundActionMetaData(body, serverManifest, value)),
2431
+ (action = loadServerReference(serverManifest, value.id, value.bound)))
2432
+ : key.startsWith("$ACTION_ID_") &&
2433
+ ((value = key.slice(11)),
2434
+ (action = loadServerReference(serverManifest, value, null)))
2435
+ : formData.append(key, value);
2436
+ });
2437
+ return null === action
2438
+ ? null
2439
+ : action.then(function (fn) {
2440
+ return fn.bind(null, formData);
2441
+ });
2442
+ }
2443
+ function decodeFormState$1(actionResult, body, serverManifest) {
2444
+ var keyPath = body.get("$ACTION_KEY");
2445
+ if ("string" !== typeof keyPath) return Promise.resolve(null);
2446
+ var metaData = null;
2447
+ body.forEach(function (value, key) {
2448
+ key.startsWith("$ACTION_REF_") &&
2449
+ ((value = "$ACTION_" + key.slice(12) + ":"),
2450
+ (metaData = decodeBoundActionMetaData(body, serverManifest, value)));
2451
+ });
2452
+ if (null === metaData) return Promise.resolve(null);
2453
+ var referenceId = metaData.id;
2454
+ return Promise.resolve(metaData.bound).then(function (bound) {
2455
+ return null === bound
2456
+ ? null
2457
+ : [actionResult, keyPath, referenceId, bound.length - 1];
2458
+ });
2459
+ }
2460
+ var serverManifest = {};
2461
+ exports.createClientReference = function (id, exportName, bundles) {
2462
+ return {
2463
+ $$typeof: CLIENT_REFERENCE_TAG$1,
2464
+ $$id: id,
2465
+ $$name: exportName,
2466
+ $$bundles: bundles
2467
+ };
2468
+ };
2469
+ exports.createTemporaryReferenceSet = function () {
2470
+ return new WeakMap();
2471
+ };
2472
+ exports.decodeAction = function (body) {
2473
+ return decodeAction$1(body, serverManifest);
2474
+ };
2475
+ exports.decodeFormState = function (actionResult, body) {
2476
+ return decodeFormState$1(actionResult, body, serverManifest);
2477
+ };
2478
+ exports.decodeReply = function (body, options) {
2479
+ if ("string" === typeof body) {
2480
+ var form = new FormData();
2481
+ form.append("0", body);
2482
+ body = form;
2483
+ }
2484
+ body = createResponse(
2485
+ serverManifest,
2486
+ "",
2487
+ options ? options.temporaryReferences : void 0,
2488
+ body
2489
+ );
2490
+ options = getChunk(body, 0);
2491
+ close(body);
2492
+ return options;
2493
+ };
2494
+ exports.loadServerAction = function (id) {
2495
+ var reference = resolveServerReference(serverManifest, id);
2496
+ return Promise.resolve(reference)
2497
+ .then(function () {
2498
+ return preloadModule$1(reference);
2499
+ })
2500
+ .then(function () {
2501
+ var fn = requireModule(reference);
2502
+ if ("function" !== typeof fn)
2503
+ throw Error("Server actions must be functions");
2504
+ return fn;
2505
+ });
2506
+ };
2507
+ exports.registerServerActions = function (manifest) {
2508
+ serverManifest = manifest;
2509
+ };
2510
+ exports.registerServerReference = function (reference, id, exportName) {
2511
+ return Object.defineProperties(reference, {
2512
+ $$typeof: { value: SERVER_REFERENCE_TAG },
2513
+ $$id: { value: id + "#" + exportName, configurable: !0 },
2514
+ $$bound: { value: null, configurable: !0 },
2515
+ bind: { value: bind, configurable: !0 }
2516
+ });
2517
+ };
2518
+ exports.renderToReadableStream = function (model, options) {
2519
+ var request = new RequestInstance(
2520
+ 20,
2521
+ model,
2522
+ null,
2523
+ options ? options.onError : void 0,
2524
+ options ? options.identifierPrefix : void 0,
2525
+ options ? options.onPostpone : void 0,
2526
+ options ? options.temporaryReferences : void 0,
2527
+ void 0,
2528
+ void 0,
2529
+ noop,
2530
+ noop
2531
+ );
2532
+ if (options && options.signal) {
2533
+ var signal = options.signal;
2534
+ if (signal.aborted) abort(request, signal.reason);
2535
+ else {
2536
+ var listener = function () {
2537
+ abort(request, signal.reason);
2538
+ signal.removeEventListener("abort", listener);
2539
+ };
2540
+ signal.addEventListener("abort", listener);
2541
+ }
2542
+ }
2543
+ return new ReadableStream(
2544
+ {
2545
+ type: "bytes",
2546
+ start: function () {
2547
+ startWork(request);
2548
+ },
2549
+ pull: function (controller) {
2550
+ if (13 === request.status)
2551
+ (request.status = 14), closeWithError(controller, request.fatalError);
2552
+ else if (14 !== request.status && null === request.destination) {
2553
+ request.destination = controller;
2554
+ try {
2555
+ flushCompletedChunks(request, controller);
2556
+ } catch (error) {
2557
+ logRecoverableError(request, error, null),
2558
+ fatalError(request, error);
2559
+ }
2560
+ }
2561
+ },
2562
+ cancel: function (reason) {
2563
+ request.destination = null;
2564
+ abort(request, reason);
2565
+ }
2566
+ },
2567
+ { highWaterMark: 0 }
2568
+ );
2569
+ };