@dodopayments/nextjs 0.3.1 → 0.3.3

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.
package/dist/index.cjs CHANGED
@@ -26,10 +26,9 @@ var detectDomainLocale = {};
26
26
  detectedLocale = detectedLocale.toLowerCase();
27
27
  }
28
28
  for (const item of domainItems){
29
- var _item_domain, _item_locales;
30
29
  // remove port if present
31
- const domainHostname = (_item_domain = item.domain) == null ? void 0 : _item_domain.split(':', 1)[0].toLowerCase();
32
- if (hostname === domainHostname || detectedLocale === item.defaultLocale.toLowerCase() || ((_item_locales = item.locales) == null ? void 0 : _item_locales.some((locale)=>locale.toLowerCase() === detectedLocale))) {
30
+ const domainHostname = item.domain?.split(':', 1)[0].toLowerCase();
31
+ if (hostname === domainHostname || detectedLocale === item.defaultLocale.toLowerCase() || item.locales?.some((locale)=>locale.toLowerCase() === detectedLocale)) {
33
32
  return item;
34
33
  }
35
34
  }
@@ -124,7 +123,7 @@ var parsePath = {};
124
123
  return path;
125
124
  }
126
125
  const { pathname, query, hash } = (0, _parsepath.parsePath)(path);
127
- return "" + prefix + pathname + query + hash;
126
+ return `${prefix}${pathname}${query}${hash}`;
128
127
  }
129
128
 
130
129
 
@@ -148,7 +147,7 @@ var addPathSuffix = {};
148
147
  return path;
149
148
  }
150
149
  const { pathname, query, hash } = (0, _parsepath.parsePath)(path);
151
- return "" + pathname + suffix + query + hash;
150
+ return `${pathname}${suffix}${query}${hash}`;
152
151
  }
153
152
 
154
153
 
@@ -201,10 +200,10 @@ var pathHasPrefix = {};
201
200
  // don't need to prefix the path.
202
201
  if (!ignorePrefix) {
203
202
  if ((0, _pathhasprefix.pathHasPrefix)(lower, '/api')) return path;
204
- if ((0, _pathhasprefix.pathHasPrefix)(lower, "/" + locale.toLowerCase())) return path;
203
+ if ((0, _pathhasprefix.pathHasPrefix)(lower, `/${locale.toLowerCase()}`)) return path;
205
204
  }
206
205
  // Add the locale prefix to the path.
207
- return (0, _addpathprefix.addPathPrefix)(path, "/" + locale);
206
+ return (0, _addpathprefix.addPathPrefix)(path, `/${locale}`);
208
207
  }
209
208
 
210
209
 
@@ -230,7 +229,7 @@ var pathHasPrefix = {};
230
229
  pathname = (0, _removetrailingslash.removeTrailingSlash)(pathname);
231
230
  }
232
231
  if (info.buildId) {
233
- pathname = (0, _addpathsuffix.addPathSuffix)((0, _addpathprefix.addPathPrefix)(pathname, "/_next/data/" + info.buildId), info.pathname === '/' ? 'index.json' : '.json');
232
+ pathname = (0, _addpathsuffix.addPathSuffix)((0, _addpathprefix.addPathPrefix)(pathname, `/_next/data/${info.buildId}`), info.pathname === '/' ? 'index.json' : '.json');
234
233
  }
235
234
  pathname = (0, _addpathprefix.addPathPrefix)(pathname, info.basePath);
236
235
  return !info.buildId && info.trailingSlash ? !pathname.endsWith('/') ? (0, _addpathsuffix.addPathSuffix)(pathname, '/') : pathname : (0, _removetrailingslash.removeTrailingSlash)(pathname);
@@ -255,7 +254,7 @@ var getHostname = {};
255
254
  // Get the hostname from the headers if it exists, otherwise use the parsed
256
255
  // hostname.
257
256
  let hostname;
258
- if ((headers == null ? void 0 : headers.host) && !Array.isArray(headers.host)) {
257
+ if (headers?.host && !Array.isArray(headers.host)) {
259
258
  hostname = headers.host.toString().split(':', 1)[0];
260
259
  } else if (parsed.hostname) {
261
260
  hostname = parsed.hostname;
@@ -363,7 +362,7 @@ var removePathPrefix = {};
363
362
  }
364
363
  // If the path without the prefix doesn't start with a `/` we need to add it
365
364
  // back to the path to make sure it's a valid path.
366
- return "/" + withoutPrefix;
365
+ return `/${withoutPrefix}`;
367
366
  }
368
367
 
369
368
 
@@ -383,8 +382,7 @@ var removePathPrefix = {};
383
382
  const _removepathprefix = removePathPrefix;
384
383
  const _pathhasprefix = pathHasPrefix;
385
384
  function getNextPathnameInfo(pathname, options) {
386
- var _options_nextConfig;
387
- const { basePath, i18n, trailingSlash } = (_options_nextConfig = options.nextConfig) != null ? _options_nextConfig : {};
385
+ const { basePath, i18n, trailingSlash } = options.nextConfig ?? {};
388
386
  const info = {
389
387
  pathname,
390
388
  trailingSlash: pathname !== '/' ? pathname.endsWith('/') : trailingSlash
@@ -398,7 +396,7 @@ var removePathPrefix = {};
398
396
  const paths = info.pathname.replace(/^\/_next\/data\//, '').replace(/\.json$/, '').split('/');
399
397
  const buildId = paths[0];
400
398
  info.buildId = buildId;
401
- pathnameNoDataPrefix = paths[1] !== 'index' ? "/" + paths.slice(1).join('/') : '/';
399
+ pathnameNoDataPrefix = paths[1] !== 'index' ? `/${paths.slice(1).join('/')}` : '/';
402
400
  // update pathname with normalized if enabled although
403
401
  // we use normalized to populate locale info still
404
402
  if (options.parseData === true) {
@@ -410,8 +408,7 @@ var removePathPrefix = {};
410
408
  if (i18n) {
411
409
  let result = options.i18nProvider ? options.i18nProvider.analyze(info.pathname) : (0, _normalizelocalepath.normalizeLocalePath)(info.pathname, i18n.locales);
412
410
  info.locale = result.detectedLocale;
413
- var _result_pathname;
414
- info.pathname = (_result_pathname = result.pathname) != null ? _result_pathname : info.pathname;
411
+ info.pathname = result.pathname ?? info.pathname;
415
412
  if (!result.detectedLocale && info.buildId) {
416
413
  result = options.i18nProvider ? options.i18nProvider.analyze(pathnameNoDataPrefix) : (0, _normalizelocalepath.normalizeLocalePath)(pathnameNoDataPrefix, i18n.locales);
417
414
  if (result.detectedLocale) {
@@ -661,12 +658,18 @@ var constants = {};
661
658
  GSSP_NO_RETURNED_VALUE: function() {
662
659
  return GSSP_NO_RETURNED_VALUE;
663
660
  },
661
+ HTML_CONTENT_TYPE_HEADER: function() {
662
+ return HTML_CONTENT_TYPE_HEADER;
663
+ },
664
664
  INFINITE_CACHE: function() {
665
665
  return INFINITE_CACHE;
666
666
  },
667
667
  INSTRUMENTATION_HOOK_FILENAME: function() {
668
668
  return INSTRUMENTATION_HOOK_FILENAME;
669
669
  },
670
+ JSON_CONTENT_TYPE_HEADER: function() {
671
+ return JSON_CONTENT_TYPE_HEADER;
672
+ },
670
673
  MATCHED_PATH_HEADER: function() {
671
674
  return MATCHED_PATH_HEADER;
672
675
  },
@@ -727,6 +730,12 @@ var constants = {};
727
730
  PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER: function() {
728
731
  return PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER;
729
732
  },
733
+ PROXY_FILENAME: function() {
734
+ return PROXY_FILENAME;
735
+ },
736
+ PROXY_LOCATION_REGEXP: function() {
737
+ return PROXY_LOCATION_REGEXP;
738
+ },
730
739
  PUBLIC_DIR_MIDDLEWARE_CONFLICT: function() {
731
740
  return PUBLIC_DIR_MIDDLEWARE_CONFLICT;
732
741
  },
@@ -787,6 +796,9 @@ var constants = {};
787
796
  STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR: function() {
788
797
  return STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR;
789
798
  },
799
+ TEXT_PLAIN_CONTENT_TYPE_HEADER: function() {
800
+ return TEXT_PLAIN_CONTENT_TYPE_HEADER;
801
+ },
790
802
  UNSTABLE_REVALIDATE_RENAME_ERROR: function() {
791
803
  return UNSTABLE_REVALIDATE_RENAME_ERROR;
792
804
  },
@@ -795,8 +807,14 @@ var constants = {};
795
807
  },
796
808
  WEBPACK_RESOURCE_QUERIES: function() {
797
809
  return WEBPACK_RESOURCE_QUERIES;
810
+ },
811
+ WEB_SOCKET_MAX_RECONNECTIONS: function() {
812
+ return WEB_SOCKET_MAX_RECONNECTIONS;
798
813
  }
799
814
  });
815
+ const TEXT_PLAIN_CONTENT_TYPE_HEADER = 'text/plain';
816
+ const HTML_CONTENT_TYPE_HEADER = 'text/html; charset=utf-8';
817
+ const JSON_CONTENT_TYPE_HEADER = 'application/json; charset=utf-8';
800
818
  const NEXT_QUERY_PARAM_PREFIX = 'nxtP';
801
819
  const NEXT_INTERCEPTION_MARKER_PREFIX = 'nxtI';
802
820
  const MATCHED_PATH_HEADER = 'x-matched-path';
@@ -822,6 +840,8 @@ var constants = {};
822
840
  const INFINITE_CACHE = 0xfffffffe;
823
841
  const MIDDLEWARE_FILENAME = 'middleware';
824
842
  const MIDDLEWARE_LOCATION_REGEXP = `(?:src/)?${MIDDLEWARE_FILENAME}`;
843
+ const PROXY_FILENAME = 'proxy';
844
+ const PROXY_LOCATION_REGEXP = `(?:src/)?${PROXY_FILENAME}`;
825
845
  const INSTRUMENTATION_HOOK_FILENAME = 'instrumentation';
826
846
  const PAGES_DIR_ALIAS = 'private-next-pages';
827
847
  const DOT_NEXT_ALIAS = 'private-dot-next';
@@ -858,6 +878,7 @@ var constants = {};
858
878
  experimentalEdge: 'experimental-edge',
859
879
  nodejs: 'nodejs'
860
880
  };
881
+ const WEB_SOCKET_MAX_RECONNECTIONS = 12;
861
882
  /**
862
883
  * The names of the webpack layers. These layers are the primitives for the
863
884
  * webpack chunks.
@@ -1154,23 +1175,23 @@ var error = {};
1154
1175
 
1155
1176
  var cookies$1 = {};
1156
1177
 
1157
- var __defProp = Object.defineProperty;
1158
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1159
- var __getOwnPropNames = Object.getOwnPropertyNames;
1160
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1178
+ var __defProp$1 = Object.defineProperty;
1179
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
1180
+ var __getOwnPropNames$1 = Object.getOwnPropertyNames;
1181
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1161
1182
  var __export = (target, all) => {
1162
1183
  for (var name in all)
1163
- __defProp(target, name, { get: all[name], enumerable: true });
1184
+ __defProp$1(target, name, { get: all[name], enumerable: true });
1164
1185
  };
1165
- var __copyProps = (to, from, except, desc) => {
1186
+ var __copyProps$1 = (to, from, except, desc) => {
1166
1187
  if (from && typeof from === "object" || typeof from === "function") {
1167
- for (let key of __getOwnPropNames(from))
1168
- if (!__hasOwnProp.call(to, key) && key !== except)
1169
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1188
+ for (let key of __getOwnPropNames$1(from))
1189
+ if (!__hasOwnProp$1.call(to, key) && key !== except)
1190
+ __defProp$1(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc$1(from, key)) || desc.enumerable });
1170
1191
  }
1171
1192
  return to;
1172
1193
  };
1173
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1194
+ var __toCommonJS = (mod) => __copyProps$1(__defProp$1({}, "__esModule", { value: true }), mod);
1174
1195
 
1175
1196
  // src/index.ts
1176
1197
  var src_exports = {};
@@ -1943,7 +1964,8 @@ var asyncLocalStorage = {};
1943
1964
  }
1944
1965
  return new FakeAsyncLocalStorage();
1945
1966
  }
1946
- function bindSnapshot(fn) {
1967
+ function bindSnapshot(// WARNING: Don't pass a named function to this argument! See: https://github.com/facebook/react/pull/34911
1968
+ fn) {
1947
1969
  if (maybeGlobalAsyncLocalStorage) {
1948
1970
  return maybeGlobalAsyncLocalStorage.bind(fn);
1949
1971
  }
@@ -2095,9 +2117,15 @@ var appRouterHeaders = {exports: {}};
2095
2117
  NEXT_HMR_REFRESH_HEADER: function() {
2096
2118
  return NEXT_HMR_REFRESH_HEADER;
2097
2119
  },
2120
+ NEXT_HTML_REQUEST_ID_HEADER: function() {
2121
+ return NEXT_HTML_REQUEST_ID_HEADER;
2122
+ },
2098
2123
  NEXT_IS_PRERENDER_HEADER: function() {
2099
2124
  return NEXT_IS_PRERENDER_HEADER;
2100
2125
  },
2126
+ NEXT_REQUEST_ID_HEADER: function() {
2127
+ return NEXT_REQUEST_ID_HEADER;
2128
+ },
2101
2129
  NEXT_REWRITTEN_PATH_HEADER: function() {
2102
2130
  return NEXT_REWRITTEN_PATH_HEADER;
2103
2131
  },
@@ -2129,14 +2157,14 @@ var appRouterHeaders = {exports: {}};
2129
2157
  return RSC_HEADER;
2130
2158
  }
2131
2159
  });
2132
- const RSC_HEADER = 'RSC';
2133
- const ACTION_HEADER = 'Next-Action';
2134
- const NEXT_ROUTER_STATE_TREE_HEADER = 'Next-Router-State-Tree';
2135
- const NEXT_ROUTER_PREFETCH_HEADER = 'Next-Router-Prefetch';
2136
- const NEXT_ROUTER_SEGMENT_PREFETCH_HEADER = 'Next-Router-Segment-Prefetch';
2137
- const NEXT_HMR_REFRESH_HEADER = 'Next-HMR-Refresh';
2160
+ const RSC_HEADER = 'rsc';
2161
+ const ACTION_HEADER = 'next-action';
2162
+ const NEXT_ROUTER_STATE_TREE_HEADER = 'next-router-state-tree';
2163
+ const NEXT_ROUTER_PREFETCH_HEADER = 'next-router-prefetch';
2164
+ const NEXT_ROUTER_SEGMENT_PREFETCH_HEADER = 'next-router-segment-prefetch';
2165
+ const NEXT_HMR_REFRESH_HEADER = 'next-hmr-refresh';
2138
2166
  const NEXT_HMR_REFRESH_HASH_COOKIE = '__next_hmr_refresh_hash__';
2139
- const NEXT_URL = 'Next-Url';
2167
+ const NEXT_URL = 'next-url';
2140
2168
  const RSC_CONTENT_TYPE_HEADER = 'text/x-component';
2141
2169
  const FLIGHT_HEADERS = [
2142
2170
  RSC_HEADER,
@@ -2152,6 +2180,8 @@ var appRouterHeaders = {exports: {}};
2152
2180
  const NEXT_REWRITTEN_QUERY_HEADER = 'x-nextjs-rewritten-query';
2153
2181
  const NEXT_IS_PRERENDER_HEADER = 'x-nextjs-prerender';
2154
2182
  const NEXT_ACTION_NOT_FOUND_HEADER = 'x-nextjs-action-not-found';
2183
+ const NEXT_REQUEST_ID_HEADER = 'x-nextjs-request-id';
2184
+ const NEXT_HTML_REQUEST_ID_HEADER = 'x-nextjs-html-request-id';
2155
2185
 
2156
2186
  if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
2157
2187
  Object.defineProperty(exports.default, '__esModule', { value: true });
@@ -2164,6 +2194,28 @@ var appRouterHeaders = {exports: {}};
2164
2194
 
2165
2195
  var appRouterHeadersExports = appRouterHeaders.exports;
2166
2196
 
2197
+ var invariantError = {};
2198
+
2199
+ (function (exports) {
2200
+ Object.defineProperty(exports, "__esModule", {
2201
+ value: true
2202
+ });
2203
+ Object.defineProperty(exports, "InvariantError", {
2204
+ enumerable: true,
2205
+ get: function() {
2206
+ return InvariantError;
2207
+ }
2208
+ });
2209
+ class InvariantError extends Error {
2210
+ constructor(message, options){
2211
+ super(`Invariant: ${message.endsWith('.') ? message : message + '.'} This is a bug in Next.js.`, options);
2212
+ this.name = 'InvariantError';
2213
+ }
2214
+ }
2215
+
2216
+
2217
+ } (invariantError));
2218
+
2167
2219
  (function (exports) {
2168
2220
  Object.defineProperty(exports, "__esModule", {
2169
2221
  value: true
@@ -2175,12 +2227,12 @@ var appRouterHeadersExports = appRouterHeaders.exports;
2175
2227
  });
2176
2228
  }
2177
2229
  _export(exports, {
2230
+ getCacheSignal: function() {
2231
+ return getCacheSignal;
2232
+ },
2178
2233
  getDraftModeProviderForCacheScope: function() {
2179
2234
  return getDraftModeProviderForCacheScope;
2180
2235
  },
2181
- getExpectedRequestStore: function() {
2182
- return getExpectedRequestStore;
2183
- },
2184
2236
  getHmrRefreshHash: function() {
2185
2237
  return getHmrRefreshHash;
2186
2238
  },
@@ -2190,50 +2242,28 @@ var appRouterHeadersExports = appRouterHeaders.exports;
2190
2242
  getRenderResumeDataCache: function() {
2191
2243
  return getRenderResumeDataCache;
2192
2244
  },
2245
+ getRuntimeStagePromise: function() {
2246
+ return getRuntimeStagePromise;
2247
+ },
2248
+ getServerComponentsHmrCache: function() {
2249
+ return getServerComponentsHmrCache;
2250
+ },
2251
+ isHmrRefresh: function() {
2252
+ return isHmrRefresh;
2253
+ },
2193
2254
  throwForMissingRequestStore: function() {
2194
2255
  return throwForMissingRequestStore;
2195
2256
  },
2257
+ throwInvariantForMissingStore: function() {
2258
+ return throwInvariantForMissingStore;
2259
+ },
2196
2260
  workUnitAsyncStorage: function() {
2197
2261
  return _workunitasyncstorageinstance.workUnitAsyncStorageInstance;
2198
2262
  }
2199
2263
  });
2200
2264
  const _workunitasyncstorageinstance = workUnitAsyncStorageInstance;
2201
2265
  const _approuterheaders = appRouterHeadersExports;
2202
- function getExpectedRequestStore(callingExpression) {
2203
- const workUnitStore = _workunitasyncstorageinstance.workUnitAsyncStorageInstance.getStore();
2204
- if (!workUnitStore) {
2205
- throwForMissingRequestStore(callingExpression);
2206
- }
2207
- switch(workUnitStore.type){
2208
- case 'request':
2209
- return workUnitStore;
2210
- case 'prerender':
2211
- case 'prerender-client':
2212
- case 'prerender-ppr':
2213
- case 'prerender-legacy':
2214
- // This should not happen because we should have checked it already.
2215
- throw Object.defineProperty(new Error(`\`${callingExpression}\` cannot be called inside a prerender. This is a bug in Next.js.`), "__NEXT_ERROR_CODE", {
2216
- value: "E401",
2217
- enumerable: false,
2218
- configurable: true
2219
- });
2220
- case 'cache':
2221
- throw Object.defineProperty(new Error(`\`${callingExpression}\` cannot be called inside "use cache". Call it outside and pass an argument instead. Read more: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
2222
- value: "E37",
2223
- enumerable: false,
2224
- configurable: true
2225
- });
2226
- case 'unstable-cache':
2227
- throw Object.defineProperty(new Error(`\`${callingExpression}\` cannot be called inside unstable_cache. Call it outside and pass an argument instead. Read more: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`), "__NEXT_ERROR_CODE", {
2228
- value: "E69",
2229
- enumerable: false,
2230
- configurable: true
2231
- });
2232
- default:
2233
- const _exhaustiveCheck = workUnitStore;
2234
- return _exhaustiveCheck;
2235
- }
2236
- }
2266
+ const _invarianterror = invariantError;
2237
2267
  function throwForMissingRequestStore(callingExpression) {
2238
2268
  throw Object.defineProperty(new Error(`\`${callingExpression}\` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context`), "__NEXT_ERROR_CODE", {
2239
2269
  value: "E251",
@@ -2241,18 +2271,45 @@ var appRouterHeadersExports = appRouterHeaders.exports;
2241
2271
  configurable: true
2242
2272
  });
2243
2273
  }
2274
+ function throwInvariantForMissingStore() {
2275
+ throw Object.defineProperty(new _invarianterror.InvariantError('Expected workUnitAsyncStorage to have a store.'), "__NEXT_ERROR_CODE", {
2276
+ value: "E696",
2277
+ enumerable: false,
2278
+ configurable: true
2279
+ });
2280
+ }
2244
2281
  function getPrerenderResumeDataCache(workUnitStore) {
2245
- if (workUnitStore.type === 'prerender' || // TODO eliminate fetch caching in client scope and stop exposing this data cache during SSR
2246
- workUnitStore.type === 'prerender-client' || workUnitStore.type === 'prerender-ppr') {
2247
- return workUnitStore.prerenderResumeDataCache;
2282
+ switch(workUnitStore.type){
2283
+ case 'prerender':
2284
+ case 'prerender-runtime':
2285
+ case 'prerender-ppr':
2286
+ return workUnitStore.prerenderResumeDataCache;
2287
+ case 'prerender-client':
2288
+ // TODO eliminate fetch caching in client scope and stop exposing this data
2289
+ // cache during SSR.
2290
+ return workUnitStore.prerenderResumeDataCache;
2291
+ case 'request':
2292
+ {
2293
+ // In dev, we might fill caches even during a dynamic request.
2294
+ if (workUnitStore.prerenderResumeDataCache) {
2295
+ return workUnitStore.prerenderResumeDataCache;
2296
+ }
2297
+ // fallthrough
2298
+ }
2299
+ case 'prerender-legacy':
2300
+ case 'cache':
2301
+ case 'private-cache':
2302
+ case 'unstable-cache':
2303
+ return null;
2304
+ default:
2305
+ return workUnitStore;
2248
2306
  }
2249
- return null;
2250
2307
  }
2251
2308
  function getRenderResumeDataCache(workUnitStore) {
2252
2309
  switch(workUnitStore.type){
2253
2310
  case 'request':
2254
- return workUnitStore.renderResumeDataCache;
2255
2311
  case 'prerender':
2312
+ case 'prerender-runtime':
2256
2313
  case 'prerender-client':
2257
2314
  if (workUnitStore.renderResumeDataCache) {
2258
2315
  // If we are in a prerender, we might have a render resume data cache
@@ -2263,31 +2320,107 @@ var appRouterHeadersExports = appRouterHeaders.exports;
2263
2320
  case 'prerender-ppr':
2264
2321
  // Otherwise we return the mutable resume data cache here as an immutable
2265
2322
  // version of the cache as it can also be used for reading.
2266
- return workUnitStore.prerenderResumeDataCache;
2267
- default:
2323
+ return workUnitStore.prerenderResumeDataCache ?? null;
2324
+ case 'cache':
2325
+ case 'private-cache':
2326
+ case 'unstable-cache':
2327
+ case 'prerender-legacy':
2268
2328
  return null;
2329
+ default:
2330
+ return workUnitStore;
2269
2331
  }
2270
2332
  }
2271
2333
  function getHmrRefreshHash(workStore, workUnitStore) {
2272
- var _workUnitStore_cookies_get;
2273
- if (!workStore.dev) {
2274
- return undefined;
2334
+ if (workStore.dev) {
2335
+ switch(workUnitStore.type){
2336
+ case 'cache':
2337
+ case 'private-cache':
2338
+ case 'prerender':
2339
+ case 'prerender-runtime':
2340
+ return workUnitStore.hmrRefreshHash;
2341
+ case 'request':
2342
+ var _workUnitStore_cookies_get;
2343
+ return (_workUnitStore_cookies_get = workUnitStore.cookies.get(_approuterheaders.NEXT_HMR_REFRESH_HASH_COOKIE)) == null ? void 0 : _workUnitStore_cookies_get.value;
2344
+ }
2275
2345
  }
2276
- return workUnitStore.type === 'cache' || workUnitStore.type === 'prerender' ? workUnitStore.hmrRefreshHash : workUnitStore.type === 'request' ? (_workUnitStore_cookies_get = workUnitStore.cookies.get(_approuterheaders.NEXT_HMR_REFRESH_HASH_COOKIE)) == null ? void 0 : _workUnitStore_cookies_get.value : undefined;
2346
+ return undefined;
2347
+ }
2348
+ function isHmrRefresh(workStore, workUnitStore) {
2349
+ if (workStore.dev) {
2350
+ switch(workUnitStore.type){
2351
+ case 'cache':
2352
+ case 'private-cache':
2353
+ case 'request':
2354
+ return workUnitStore.isHmrRefresh ?? false;
2355
+ }
2356
+ }
2357
+ return false;
2358
+ }
2359
+ function getServerComponentsHmrCache(workStore, workUnitStore) {
2360
+ if (workStore.dev) {
2361
+ switch(workUnitStore.type){
2362
+ case 'cache':
2363
+ case 'private-cache':
2364
+ case 'request':
2365
+ return workUnitStore.serverComponentsHmrCache;
2366
+ }
2367
+ }
2368
+ return undefined;
2277
2369
  }
2278
2370
  function getDraftModeProviderForCacheScope(workStore, workUnitStore) {
2279
2371
  if (workStore.isDraftMode) {
2280
2372
  switch(workUnitStore.type){
2281
2373
  case 'cache':
2374
+ case 'private-cache':
2282
2375
  case 'unstable-cache':
2376
+ case 'prerender-runtime':
2283
2377
  case 'request':
2284
2378
  return workUnitStore.draftMode;
2285
- default:
2286
- return undefined;
2287
2379
  }
2288
2380
  }
2289
2381
  return undefined;
2290
2382
  }
2383
+ function getCacheSignal(workUnitStore) {
2384
+ switch(workUnitStore.type){
2385
+ case 'prerender':
2386
+ case 'prerender-client':
2387
+ case 'prerender-runtime':
2388
+ return workUnitStore.cacheSignal;
2389
+ case 'request':
2390
+ {
2391
+ // In dev, we might fill caches even during a dynamic request.
2392
+ if (workUnitStore.cacheSignal) {
2393
+ return workUnitStore.cacheSignal;
2394
+ }
2395
+ // fallthrough
2396
+ }
2397
+ case 'prerender-ppr':
2398
+ case 'prerender-legacy':
2399
+ case 'cache':
2400
+ case 'private-cache':
2401
+ case 'unstable-cache':
2402
+ return null;
2403
+ default:
2404
+ return workUnitStore;
2405
+ }
2406
+ }
2407
+ function getRuntimeStagePromise(workUnitStore) {
2408
+ switch(workUnitStore.type){
2409
+ case 'prerender-runtime':
2410
+ case 'private-cache':
2411
+ return workUnitStore.runtimeStagePromise;
2412
+ case 'prerender':
2413
+ case 'prerender-client':
2414
+ case 'prerender-ppr':
2415
+ case 'prerender-legacy':
2416
+ case 'request':
2417
+ case 'cache':
2418
+ case 'unstable-cache':
2419
+ return null;
2420
+ default:
2421
+ return workUnitStore;
2422
+ }
2423
+ }
2291
2424
 
2292
2425
 
2293
2426
  } (workUnitAsyncStorage_external));
@@ -4174,7 +4307,7 @@ var hooksServerContext = {exports: {}};
4174
4307
  const DYNAMIC_ERROR_CODE = 'DYNAMIC_SERVER_USAGE';
4175
4308
  class DynamicServerError extends Error {
4176
4309
  constructor(description){
4177
- super("Dynamic server usage: " + description), this.description = description, this.digest = DYNAMIC_ERROR_CODE;
4310
+ super(`Dynamic server usage: ${description}`), this.description = description, this.digest = DYNAMIC_ERROR_CODE;
4178
4311
  }
4179
4312
  }
4180
4313
  function isDynamicServerError(err) {
@@ -4255,6 +4388,9 @@ var dynamicRenderingUtils = {};
4255
4388
  isHangingPromiseRejectionError: function() {
4256
4389
  return isHangingPromiseRejectionError;
4257
4390
  },
4391
+ makeDevtoolsIOAwarePromise: function() {
4392
+ return makeDevtoolsIOAwarePromise;
4393
+ },
4258
4394
  makeHangingPromise: function() {
4259
4395
  return makeHangingPromise;
4260
4396
  }
@@ -4267,17 +4403,17 @@ var dynamicRenderingUtils = {};
4267
4403
  }
4268
4404
  const HANGING_PROMISE_REJECTION = 'HANGING_PROMISE_REJECTION';
4269
4405
  class HangingPromiseRejectionError extends Error {
4270
- constructor(expression){
4271
- super(`During prerendering, ${expression} rejects when the prerender is complete. Typically these errors are handled by React but if you move ${expression} to a different context by using \`setTimeout\`, \`after\`, or similar functions you may observe this error and you should handle it in that context.`), this.expression = expression, this.digest = HANGING_PROMISE_REJECTION;
4406
+ constructor(route, expression){
4407
+ super(`During prerendering, ${expression} rejects when the prerender is complete. Typically these errors are handled by React but if you move ${expression} to a different context by using \`setTimeout\`, \`after\`, or similar functions you may observe this error and you should handle it in that context. This occurred at route "${route}".`), this.route = route, this.expression = expression, this.digest = HANGING_PROMISE_REJECTION;
4272
4408
  }
4273
4409
  }
4274
4410
  const abortListenersBySignal = new WeakMap();
4275
- function makeHangingPromise(signal, expression) {
4411
+ function makeHangingPromise(signal, route, expression) {
4276
4412
  if (signal.aborted) {
4277
- return Promise.reject(new HangingPromiseRejectionError(expression));
4413
+ return Promise.reject(new HangingPromiseRejectionError(route, expression));
4278
4414
  } else {
4279
4415
  const hangingPromise = new Promise((_, reject)=>{
4280
- const boundRejection = reject.bind(null, new HangingPromiseRejectionError(expression));
4416
+ const boundRejection = reject.bind(null, new HangingPromiseRejectionError(route, expression));
4281
4417
  let currentListeners = abortListenersBySignal.get(signal);
4282
4418
  if (currentListeners) {
4283
4419
  currentListeners.push(boundRejection);
@@ -4303,11 +4439,25 @@ var dynamicRenderingUtils = {};
4303
4439
  }
4304
4440
  }
4305
4441
  function ignoreReject() {}
4442
+ function makeDevtoolsIOAwarePromise(underlying, requestStore, stage) {
4443
+ if (requestStore.stagedRendering) {
4444
+ // We resolve each stage in a timeout, so React DevTools will pick this up as IO.
4445
+ return requestStore.stagedRendering.delayUntilStage(stage, undefined, underlying);
4446
+ }
4447
+ // in React DevTools if we resolve in a setTimeout we will observe
4448
+ // the promise resolution as something that can suspend a boundary or root.
4449
+ return new Promise((resolve)=>{
4450
+ // Must use setTimeout to be considered IO React DevTools. setImmediate will not work.
4451
+ setTimeout(()=>{
4452
+ resolve(underlying);
4453
+ }, 0);
4454
+ });
4455
+ }
4306
4456
 
4307
4457
 
4308
4458
  } (dynamicRenderingUtils));
4309
4459
 
4310
- var metadataConstants = {};
4460
+ var boundaryConstants = {};
4311
4461
 
4312
4462
  (function (exports) {
4313
4463
  Object.defineProperty(exports, "__esModule", {
@@ -4326,6 +4476,9 @@ var metadataConstants = {};
4326
4476
  OUTLET_BOUNDARY_NAME: function() {
4327
4477
  return OUTLET_BOUNDARY_NAME;
4328
4478
  },
4479
+ ROOT_LAYOUT_BOUNDARY_NAME: function() {
4480
+ return ROOT_LAYOUT_BOUNDARY_NAME;
4481
+ },
4329
4482
  VIEWPORT_BOUNDARY_NAME: function() {
4330
4483
  return VIEWPORT_BOUNDARY_NAME;
4331
4484
  }
@@ -4333,9 +4486,10 @@ var metadataConstants = {};
4333
4486
  const METADATA_BOUNDARY_NAME = '__next_metadata_boundary__';
4334
4487
  const VIEWPORT_BOUNDARY_NAME = '__next_viewport_boundary__';
4335
4488
  const OUTLET_BOUNDARY_NAME = '__next_outlet_boundary__';
4489
+ const ROOT_LAYOUT_BOUNDARY_NAME = '__next_root_layout_boundary__';
4336
4490
 
4337
4491
 
4338
- } (metadataConstants));
4492
+ } (boundaryConstants));
4339
4493
 
4340
4494
  var scheduler = {};
4341
4495
 
@@ -4399,6 +4553,198 @@ var scheduler = {};
4399
4553
 
4400
4554
  } (scheduler));
4401
4555
 
4556
+ var bailoutToCsr = {};
4557
+
4558
+ (function (exports) {
4559
+ Object.defineProperty(exports, "__esModule", {
4560
+ value: true
4561
+ });
4562
+ function _export(target, all) {
4563
+ for(var name in all)Object.defineProperty(target, name, {
4564
+ enumerable: true,
4565
+ get: all[name]
4566
+ });
4567
+ }
4568
+ _export(exports, {
4569
+ BailoutToCSRError: function() {
4570
+ return BailoutToCSRError;
4571
+ },
4572
+ isBailoutToCSRError: function() {
4573
+ return isBailoutToCSRError;
4574
+ }
4575
+ });
4576
+ const BAILOUT_TO_CSR = 'BAILOUT_TO_CLIENT_SIDE_RENDERING';
4577
+ class BailoutToCSRError extends Error {
4578
+ constructor(reason){
4579
+ super(`Bail out to client-side rendering: ${reason}`), this.reason = reason, this.digest = BAILOUT_TO_CSR;
4580
+ }
4581
+ }
4582
+ function isBailoutToCSRError(err) {
4583
+ if (typeof err !== 'object' || err === null || !('digest' in err)) {
4584
+ return false;
4585
+ }
4586
+ return err.digest === BAILOUT_TO_CSR;
4587
+ }
4588
+
4589
+
4590
+ } (bailoutToCsr));
4591
+
4592
+ var stagedRendering = {};
4593
+
4594
+ var promiseWithResolvers = {};
4595
+
4596
+ (function (exports) {
4597
+ Object.defineProperty(exports, "__esModule", {
4598
+ value: true
4599
+ });
4600
+ Object.defineProperty(exports, "createPromiseWithResolvers", {
4601
+ enumerable: true,
4602
+ get: function() {
4603
+ return createPromiseWithResolvers;
4604
+ }
4605
+ });
4606
+ function createPromiseWithResolvers() {
4607
+ // Shim of Stage 4 Promise.withResolvers proposal
4608
+ let resolve;
4609
+ let reject;
4610
+ const promise = new Promise((res, rej)=>{
4611
+ resolve = res;
4612
+ reject = rej;
4613
+ });
4614
+ return {
4615
+ resolve: resolve,
4616
+ reject: reject,
4617
+ promise
4618
+ };
4619
+ }
4620
+
4621
+
4622
+ } (promiseWithResolvers));
4623
+
4624
+ (function (exports) {
4625
+ Object.defineProperty(exports, "__esModule", {
4626
+ value: true
4627
+ });
4628
+ function _export(target, all) {
4629
+ for(var name in all)Object.defineProperty(target, name, {
4630
+ enumerable: true,
4631
+ get: all[name]
4632
+ });
4633
+ }
4634
+ _export(exports, {
4635
+ RenderStage: function() {
4636
+ return RenderStage;
4637
+ },
4638
+ StagedRenderingController: function() {
4639
+ return StagedRenderingController;
4640
+ }
4641
+ });
4642
+ const _invarianterror = invariantError;
4643
+ const _promisewithresolvers = promiseWithResolvers;
4644
+ var RenderStage = /*#__PURE__*/ function(RenderStage) {
4645
+ RenderStage[RenderStage["Static"] = 1] = "Static";
4646
+ RenderStage[RenderStage["Runtime"] = 2] = "Runtime";
4647
+ RenderStage[RenderStage["Dynamic"] = 3] = "Dynamic";
4648
+ return RenderStage;
4649
+ }({});
4650
+ class StagedRenderingController {
4651
+ constructor(abortSignal = null){
4652
+ this.abortSignal = abortSignal;
4653
+ this.currentStage = 1;
4654
+ this.runtimeStagePromise = (0, _promisewithresolvers.createPromiseWithResolvers)();
4655
+ this.dynamicStagePromise = (0, _promisewithresolvers.createPromiseWithResolvers)();
4656
+ if (abortSignal) {
4657
+ abortSignal.addEventListener('abort', ()=>{
4658
+ const { reason } = abortSignal;
4659
+ if (this.currentStage < 2) {
4660
+ this.runtimeStagePromise.promise.catch(ignoreReject) // avoid unhandled rejections
4661
+ ;
4662
+ this.runtimeStagePromise.reject(reason);
4663
+ }
4664
+ if (this.currentStage < 3) {
4665
+ this.dynamicStagePromise.promise.catch(ignoreReject) // avoid unhandled rejections
4666
+ ;
4667
+ this.dynamicStagePromise.reject(reason);
4668
+ }
4669
+ }, {
4670
+ once: true
4671
+ });
4672
+ }
4673
+ }
4674
+ advanceStage(stage) {
4675
+ // If we're already at the target stage or beyond, do nothing.
4676
+ // (this can happen e.g. if sync IO advanced us to the dynamic stage)
4677
+ if (this.currentStage >= stage) {
4678
+ return;
4679
+ }
4680
+ this.currentStage = stage;
4681
+ // Note that we might be going directly from Static to Dynamic,
4682
+ // so we need to resolve the runtime stage as well.
4683
+ if (stage >= 2) {
4684
+ this.runtimeStagePromise.resolve();
4685
+ }
4686
+ if (stage >= 3) {
4687
+ this.dynamicStagePromise.resolve();
4688
+ }
4689
+ }
4690
+ getStagePromise(stage) {
4691
+ switch(stage){
4692
+ case 2:
4693
+ {
4694
+ return this.runtimeStagePromise.promise;
4695
+ }
4696
+ case 3:
4697
+ {
4698
+ return this.dynamicStagePromise.promise;
4699
+ }
4700
+ default:
4701
+ {
4702
+ throw Object.defineProperty(new _invarianterror.InvariantError(`Invalid render stage: ${stage}`), "__NEXT_ERROR_CODE", {
4703
+ value: "E881",
4704
+ enumerable: false,
4705
+ configurable: true
4706
+ });
4707
+ }
4708
+ }
4709
+ }
4710
+ waitForStage(stage) {
4711
+ return this.getStagePromise(stage);
4712
+ }
4713
+ delayUntilStage(stage, displayName, resolvedValue) {
4714
+ const ioTriggerPromise = this.getStagePromise(stage);
4715
+ const promise = makeDevtoolsIOPromiseFromIOTrigger(ioTriggerPromise, displayName, resolvedValue);
4716
+ // Analogously to `makeHangingPromise`, we might reject this promise if the signal is invoked.
4717
+ // (e.g. in the case where we don't want want the render to proceed to the dynamic stage and abort it).
4718
+ // We shouldn't consider this an unhandled rejection, so we attach a noop catch handler here to suppress this warning.
4719
+ if (this.abortSignal) {
4720
+ promise.catch(ignoreReject);
4721
+ }
4722
+ return promise;
4723
+ }
4724
+ }
4725
+ function ignoreReject() {}
4726
+ // TODO(restart-on-cache-miss): the layering of `delayUntilStage`,
4727
+ // `makeDevtoolsIOPromiseFromIOTrigger` and and `makeDevtoolsIOAwarePromise`
4728
+ // is confusing, we should clean it up.
4729
+ function makeDevtoolsIOPromiseFromIOTrigger(ioTrigger, displayName, resolvedValue) {
4730
+ // If we create a `new Promise` and give it a displayName
4731
+ // (with no userspace code above us in the stack)
4732
+ // React Devtools will use it as the IO cause when determining "suspended by".
4733
+ // In particular, it should shadow any inner IO that resolved/rejected the promise
4734
+ // (in case of staged rendering, this will be the `setTimeout` that triggers the relevant stage)
4735
+ const promise = new Promise((resolve, reject)=>{
4736
+ ioTrigger.then(resolve.bind(null, resolvedValue), reject);
4737
+ });
4738
+ if (displayName !== undefined) {
4739
+ // @ts-expect-error
4740
+ promise.displayName = displayName;
4741
+ }
4742
+ return promise;
4743
+ }
4744
+
4745
+
4746
+ } (stagedRendering));
4747
+
4402
4748
  /**
4403
4749
  * The functions provided by this module are used to communicate certain properties
4404
4750
  * about the currently running code so that Next.js can make decisions on how to handle
@@ -4462,8 +4808,11 @@ var scheduler = {};
4462
4808
  createHangingInputAbortSignal: function() {
4463
4809
  return createHangingInputAbortSignal;
4464
4810
  },
4465
- createPostponedAbortSignal: function() {
4466
- return createPostponedAbortSignal;
4811
+ createRenderInBrowserAbortSignal: function() {
4812
+ return createRenderInBrowserAbortSignal;
4813
+ },
4814
+ delayUntilRuntimeStage: function() {
4815
+ return delayUntilRuntimeStage;
4467
4816
  },
4468
4817
  formatDynamicAPIAccesses: function() {
4469
4818
  return formatDynamicAPIAccesses;
@@ -4477,6 +4826,9 @@ var scheduler = {};
4477
4826
  isPrerenderInterruptedError: function() {
4478
4827
  return isPrerenderInterruptedError;
4479
4828
  },
4829
+ logDisallowedDynamicError: function() {
4830
+ return logDisallowedDynamicError;
4831
+ },
4480
4832
  markCurrentScopeAsDynamic: function() {
4481
4833
  return markCurrentScopeAsDynamic;
4482
4834
  },
@@ -4495,17 +4847,14 @@ var scheduler = {};
4495
4847
  trackDynamicDataInDynamicRender: function() {
4496
4848
  return trackDynamicDataInDynamicRender;
4497
4849
  },
4498
- trackFallbackParamAccessed: function() {
4499
- return trackFallbackParamAccessed;
4500
- },
4501
4850
  trackSynchronousPlatformIOAccessInDev: function() {
4502
4851
  return trackSynchronousPlatformIOAccessInDev;
4503
4852
  },
4504
- trackSynchronousRequestDataAccessInDev: function() {
4505
- return trackSynchronousRequestDataAccessInDev;
4506
- },
4507
4853
  useDynamicRouteParams: function() {
4508
4854
  return useDynamicRouteParams;
4855
+ },
4856
+ useDynamicSearchParams: function() {
4857
+ return useDynamicSearchParams;
4509
4858
  }
4510
4859
  });
4511
4860
  const _react = /*#__PURE__*/ _interop_require_default(reactExports);
@@ -4514,8 +4863,11 @@ var scheduler = {};
4514
4863
  const _workunitasyncstorageexternal = workUnitAsyncStorage_external;
4515
4864
  const _workasyncstorageexternal = workAsyncStorage_external;
4516
4865
  const _dynamicrenderingutils = dynamicRenderingUtils;
4517
- const _metadataconstants = metadataConstants;
4866
+ const _boundaryconstants = boundaryConstants;
4518
4867
  const _scheduler = scheduler;
4868
+ const _bailouttocsr = bailoutToCsr;
4869
+ const _invarianterror = invariantError;
4870
+ const _stagedrendering = stagedRendering;
4519
4871
  function _interop_require_default(obj) {
4520
4872
  return obj && obj.__esModule ? obj : {
4521
4873
  default: obj
@@ -4544,11 +4896,17 @@ var scheduler = {};
4544
4896
  }
4545
4897
  function markCurrentScopeAsDynamic(store, workUnitStore, expression) {
4546
4898
  if (workUnitStore) {
4547
- if (workUnitStore.type === 'cache' || workUnitStore.type === 'unstable-cache') {
4548
- // inside cache scopes marking a scope as dynamic has no effect because the outer cache scope
4549
- // creates a cache boundary. This is subtly different from reading a dynamic data source which is
4550
- // forbidden inside a cache scope.
4551
- return;
4899
+ switch(workUnitStore.type){
4900
+ case 'cache':
4901
+ case 'unstable-cache':
4902
+ // Inside cache scopes, marking a scope as dynamic has no effect,
4903
+ // because the outer cache scope creates a cache boundary. This is
4904
+ // subtly different from reading a dynamic data source, which is
4905
+ // forbidden inside a cache scope.
4906
+ return;
4907
+ case 'private-cache':
4908
+ // A private cache scope is already dynamic by definition.
4909
+ return;
4552
4910
  }
4553
4911
  }
4554
4912
  // If we're forcing dynamic rendering or we're forcing static rendering, we
@@ -4563,29 +4921,29 @@ var scheduler = {};
4563
4921
  });
4564
4922
  }
4565
4923
  if (workUnitStore) {
4566
- if (workUnitStore.type === 'prerender-ppr') {
4567
- postponeWithTracking(store.route, expression, workUnitStore.dynamicTracking);
4568
- } else if (workUnitStore.type === 'prerender-legacy') {
4569
- workUnitStore.revalidate = 0;
4570
- // We aren't prerendering but we are generating a static page. We need to bail out of static generation
4571
- const err = Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${store.route} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
4572
- value: "E550",
4573
- enumerable: false,
4574
- configurable: true
4575
- });
4576
- store.dynamicUsageDescription = expression;
4577
- store.dynamicUsageStack = err.stack;
4578
- throw err;
4579
- } else if (process.env.NODE_ENV === 'development' && workUnitStore && workUnitStore.type === 'request') {
4580
- workUnitStore.usedDynamic = true;
4924
+ switch(workUnitStore.type){
4925
+ case 'prerender-ppr':
4926
+ return postponeWithTracking(store.route, expression, workUnitStore.dynamicTracking);
4927
+ case 'prerender-legacy':
4928
+ workUnitStore.revalidate = 0;
4929
+ // We aren't prerendering, but we are generating a static page. We need
4930
+ // to bail out of static generation.
4931
+ const err = Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${store.route} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
4932
+ value: "E550",
4933
+ enumerable: false,
4934
+ configurable: true
4935
+ });
4936
+ store.dynamicUsageDescription = expression;
4937
+ store.dynamicUsageStack = err.stack;
4938
+ throw err;
4939
+ case 'request':
4940
+ if (process.env.NODE_ENV !== 'production') {
4941
+ workUnitStore.usedDynamic = true;
4942
+ }
4943
+ break;
4581
4944
  }
4582
4945
  }
4583
4946
  }
4584
- function trackFallbackParamAccessed(store, expression) {
4585
- const prerenderStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
4586
- if (!prerenderStore || prerenderStore.type !== 'prerender-ppr') return;
4587
- postponeWithTracking(store.route, expression, prerenderStore.dynamicTracking);
4588
- }
4589
4947
  function throwToInterruptStaticGeneration(expression, store, prerenderStore) {
4590
4948
  // We aren't prerendering but we are generating a static page. We need to bail out of static generation
4591
4949
  const err = Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${store.route} couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
@@ -4598,21 +4956,29 @@ var scheduler = {};
4598
4956
  store.dynamicUsageStack = err.stack;
4599
4957
  throw err;
4600
4958
  }
4601
- function trackDynamicDataInDynamicRender(_store, workUnitStore) {
4602
- if (workUnitStore) {
4603
- if (workUnitStore.type === 'cache' || workUnitStore.type === 'unstable-cache') {
4604
- // inside cache scopes marking a scope as dynamic has no effect because the outer cache scope
4605
- // creates a cache boundary. This is subtly different from reading a dynamic data source which is
4959
+ function trackDynamicDataInDynamicRender(workUnitStore) {
4960
+ switch(workUnitStore.type){
4961
+ case 'cache':
4962
+ case 'unstable-cache':
4963
+ // Inside cache scopes, marking a scope as dynamic has no effect,
4964
+ // because the outer cache scope creates a cache boundary. This is
4965
+ // subtly different from reading a dynamic data source, which is
4606
4966
  // forbidden inside a cache scope.
4607
4967
  return;
4608
- }
4609
- // TODO: it makes no sense to have these work unit store types during a dev render.
4610
- if (workUnitStore.type === 'prerender' || workUnitStore.type === 'prerender-client' || workUnitStore.type === 'prerender-legacy') {
4611
- workUnitStore.revalidate = 0;
4612
- }
4613
- if (process.env.NODE_ENV === 'development' && workUnitStore.type === 'request') {
4614
- workUnitStore.usedDynamic = true;
4615
- }
4968
+ case 'private-cache':
4969
+ // A private cache scope is already dynamic by definition.
4970
+ return;
4971
+ case 'prerender':
4972
+ case 'prerender-runtime':
4973
+ case 'prerender-legacy':
4974
+ case 'prerender-ppr':
4975
+ case 'prerender-client':
4976
+ break;
4977
+ case 'request':
4978
+ if (process.env.NODE_ENV !== 'production') {
4979
+ workUnitStore.usedDynamic = true;
4980
+ }
4981
+ break;
4616
4982
  }
4617
4983
  }
4618
4984
  function abortOnSynchronousDynamicDataAccess(route, expression, prerenderStore) {
@@ -4644,8 +5010,12 @@ var scheduler = {};
4644
5010
  }
4645
5011
  function trackSynchronousPlatformIOAccessInDev(requestStore) {
4646
5012
  // We don't actually have a controller to abort but we do the semantic equivalent by
4647
- // advancing the request store out of prerender mode
4648
- requestStore.prerenderPhase = false;
5013
+ // advancing the request store out of the prerender stage
5014
+ if (requestStore.stagedRendering) {
5015
+ // TODO: error for sync IO in the runtime stage
5016
+ // (which is not currently covered by the validation render in `spawnDynamicValidationInDev`)
5017
+ requestStore.stagedRendering.advanceStage(_stagedrendering.RenderStage.Dynamic);
5018
+ }
4649
5019
  }
4650
5020
  function abortAndThrowOnSynchronousRequestDataAccess(route, expression, errorWithStack, prerenderStore) {
4651
5021
  const prerenderSignal = prerenderStore.controller.signal;
@@ -4669,7 +5039,6 @@ var scheduler = {};
4669
5039
  }
4670
5040
  throw createPrerenderInterruptedError(`Route ${route} needs to bail out of prerendering at this point because it used ${expression}.`);
4671
5041
  }
4672
- const trackSynchronousRequestDataAccessInDev = trackSynchronousPlatformIOAccessInDev;
4673
5042
  function Postpone({ reason, route }) {
4674
5043
  const prerenderStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
4675
5044
  const dynamicTracking = prerenderStore && prerenderStore.type === 'prerender-ppr' ? prerenderStore.dynamicTracking : null;
@@ -4761,35 +5130,57 @@ var scheduler = {};
4761
5130
  });
4762
5131
  }
4763
5132
  }
4764
- function createPostponedAbortSignal(reason) {
4765
- assertPostpone();
5133
+ function createRenderInBrowserAbortSignal() {
4766
5134
  const controller = new AbortController();
4767
- // We get our hands on a postpone instance by calling postpone and catching the throw
4768
- try {
4769
- _react.default.unstable_postpone(reason);
4770
- } catch (x) {
4771
- controller.abort(x);
4772
- }
5135
+ controller.abort(Object.defineProperty(new _bailouttocsr.BailoutToCSRError('Render in Browser'), "__NEXT_ERROR_CODE", {
5136
+ value: "E721",
5137
+ enumerable: false,
5138
+ configurable: true
5139
+ }));
4773
5140
  return controller.signal;
4774
5141
  }
4775
5142
  function createHangingInputAbortSignal(workUnitStore) {
4776
- const controller = new AbortController();
4777
- if (workUnitStore.cacheSignal) {
4778
- // If we have a cacheSignal it means we're in a prospective render. If the input
4779
- // we're waiting on is coming from another cache, we do want to wait for it so that
4780
- // we can resolve this cache entry too.
4781
- workUnitStore.cacheSignal.inputReady().then(()=>{
4782
- controller.abort();
4783
- });
4784
- } else {
4785
- // Otherwise we're in the final render and we should already have all our caches
4786
- // filled. We might still be waiting on some microtasks so we wait one tick before
4787
- // giving up. When we give up, we still want to render the content of this cache
4788
- // as deeply as we can so that we can suspend as deeply as possible in the tree
4789
- // or not at all if we don't end up waiting for the input.
4790
- (0, _scheduler.scheduleOnNextTick)(()=>controller.abort());
5143
+ switch(workUnitStore.type){
5144
+ case 'prerender':
5145
+ case 'prerender-runtime':
5146
+ const controller = new AbortController();
5147
+ if (workUnitStore.cacheSignal) {
5148
+ // If we have a cacheSignal it means we're in a prospective render. If
5149
+ // the input we're waiting on is coming from another cache, we do want
5150
+ // to wait for it so that we can resolve this cache entry too.
5151
+ workUnitStore.cacheSignal.inputReady().then(()=>{
5152
+ controller.abort();
5153
+ });
5154
+ } else {
5155
+ // Otherwise we're in the final render and we should already have all
5156
+ // our caches filled.
5157
+ // If the prerender uses stages, we have wait until the runtime stage,
5158
+ // at which point all runtime inputs will be resolved.
5159
+ // (otherwise, a runtime prerender might consider `cookies()` hanging
5160
+ // even though they'd resolve in the next task.)
5161
+ //
5162
+ // We might still be waiting on some microtasks so we
5163
+ // wait one tick before giving up. When we give up, we still want to
5164
+ // render the content of this cache as deeply as we can so that we can
5165
+ // suspend as deeply as possible in the tree or not at all if we don't
5166
+ // end up waiting for the input.
5167
+ const runtimeStagePromise = (0, _workunitasyncstorageexternal.getRuntimeStagePromise)(workUnitStore);
5168
+ if (runtimeStagePromise) {
5169
+ runtimeStagePromise.then(()=>(0, _scheduler.scheduleOnNextTick)(()=>controller.abort()));
5170
+ } else {
5171
+ (0, _scheduler.scheduleOnNextTick)(()=>controller.abort());
5172
+ }
5173
+ }
5174
+ return controller.signal;
5175
+ case 'prerender-client':
5176
+ case 'prerender-ppr':
5177
+ case 'prerender-legacy':
5178
+ case 'request':
5179
+ case 'cache':
5180
+ case 'private-cache':
5181
+ case 'unstable-cache':
5182
+ return undefined;
4791
5183
  }
4792
- return controller.signal;
4793
5184
  }
4794
5185
  function annotateDynamicAccess(expression, prerenderStore) {
4795
5186
  const dynamicTracking = prerenderStore.dynamicTracking;
@@ -4799,34 +5190,114 @@ var scheduler = {};
4799
5190
  expression
4800
5191
  });
4801
5192
  }
4802
- }
4803
- function useDynamicRouteParams(expression) {
4804
- const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
4805
- if (workStore && workStore.isStaticGeneration && workStore.fallbackRouteParams && workStore.fallbackRouteParams.size > 0) {
4806
- // There are fallback route params, we should track these as dynamic
4807
- // accesses.
4808
- const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
4809
- if (workUnitStore) {
4810
- // We're prerendering with dynamicIO or PPR or both
4811
- if (workUnitStore.type === 'prerender-client') {
4812
- // We are in a prerender with dynamicIO semantics
4813
- // We are going to hang here and never resolve. This will cause the currently
4814
- // rendering component to effectively be a dynamic hole
4815
- _react.default.use((0, _dynamicrenderingutils.makeHangingPromise)(workUnitStore.renderSignal, expression));
4816
- } else if (workUnitStore.type === 'prerender-ppr') {
4817
- // We're prerendering with PPR
4818
- postponeWithTracking(workStore.route, expression, workUnitStore.dynamicTracking);
4819
- } else if (workUnitStore.type === 'prerender-legacy') {
4820
- throwToInterruptStaticGeneration(expression, workStore, workUnitStore);
5193
+ }
5194
+ function useDynamicRouteParams(expression) {
5195
+ const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
5196
+ const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
5197
+ if (workStore && workUnitStore) {
5198
+ switch(workUnitStore.type){
5199
+ case 'prerender-client':
5200
+ case 'prerender':
5201
+ {
5202
+ const fallbackParams = workUnitStore.fallbackRouteParams;
5203
+ if (fallbackParams && fallbackParams.size > 0) {
5204
+ // We are in a prerender with cacheComponents semantics. We are going to
5205
+ // hang here and never resolve. This will cause the currently
5206
+ // rendering component to effectively be a dynamic hole.
5207
+ _react.default.use((0, _dynamicrenderingutils.makeHangingPromise)(workUnitStore.renderSignal, workStore.route, expression));
5208
+ }
5209
+ break;
5210
+ }
5211
+ case 'prerender-ppr':
5212
+ {
5213
+ const fallbackParams = workUnitStore.fallbackRouteParams;
5214
+ if (fallbackParams && fallbackParams.size > 0) {
5215
+ return postponeWithTracking(workStore.route, expression, workUnitStore.dynamicTracking);
5216
+ }
5217
+ break;
5218
+ }
5219
+ case 'prerender-runtime':
5220
+ throw Object.defineProperty(new _invarianterror.InvariantError(`\`${expression}\` was called during a runtime prerender. Next.js should be preventing ${expression} from being included in server components statically, but did not in this case.`), "__NEXT_ERROR_CODE", {
5221
+ value: "E771",
5222
+ enumerable: false,
5223
+ configurable: true
5224
+ });
5225
+ case 'cache':
5226
+ case 'private-cache':
5227
+ throw Object.defineProperty(new _invarianterror.InvariantError(`\`${expression}\` was called inside a cache scope. Next.js should be preventing ${expression} from being included in server components statically, but did not in this case.`), "__NEXT_ERROR_CODE", {
5228
+ value: "E745",
5229
+ enumerable: false,
5230
+ configurable: true
5231
+ });
5232
+ }
5233
+ }
5234
+ }
5235
+ function useDynamicSearchParams(expression) {
5236
+ const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
5237
+ const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
5238
+ if (!workStore) {
5239
+ // We assume pages router context and just return
5240
+ return;
5241
+ }
5242
+ if (!workUnitStore) {
5243
+ (0, _workunitasyncstorageexternal.throwForMissingRequestStore)(expression);
5244
+ }
5245
+ switch(workUnitStore.type){
5246
+ case 'prerender-client':
5247
+ {
5248
+ _react.default.use((0, _dynamicrenderingutils.makeHangingPromise)(workUnitStore.renderSignal, workStore.route, expression));
5249
+ break;
4821
5250
  }
4822
- }
5251
+ case 'prerender-legacy':
5252
+ case 'prerender-ppr':
5253
+ {
5254
+ if (workStore.forceStatic) {
5255
+ return;
5256
+ }
5257
+ throw Object.defineProperty(new _bailouttocsr.BailoutToCSRError(expression), "__NEXT_ERROR_CODE", {
5258
+ value: "E394",
5259
+ enumerable: false,
5260
+ configurable: true
5261
+ });
5262
+ }
5263
+ case 'prerender':
5264
+ case 'prerender-runtime':
5265
+ throw Object.defineProperty(new _invarianterror.InvariantError(`\`${expression}\` was called from a Server Component. Next.js should be preventing ${expression} from being included in server components statically, but did not in this case.`), "__NEXT_ERROR_CODE", {
5266
+ value: "E795",
5267
+ enumerable: false,
5268
+ configurable: true
5269
+ });
5270
+ case 'cache':
5271
+ case 'unstable-cache':
5272
+ case 'private-cache':
5273
+ throw Object.defineProperty(new _invarianterror.InvariantError(`\`${expression}\` was called inside a cache scope. Next.js should be preventing ${expression} from being included in server components statically, but did not in this case.`), "__NEXT_ERROR_CODE", {
5274
+ value: "E745",
5275
+ enumerable: false,
5276
+ configurable: true
5277
+ });
5278
+ case 'request':
5279
+ return;
4823
5280
  }
4824
5281
  }
4825
5282
  const hasSuspenseRegex = /\n\s+at Suspense \(<anonymous>\)/;
4826
- const hasSuspenseAfterBodyOrHtmlRegex = /\n\s+at (?:body|html) \(<anonymous>\)[\s\S]*?\n\s+at Suspense \(<anonymous>\)/;
4827
- const hasMetadataRegex = new RegExp(`\\n\\s+at ${_metadataconstants.METADATA_BOUNDARY_NAME}[\\n\\s]`);
4828
- const hasViewportRegex = new RegExp(`\\n\\s+at ${_metadataconstants.VIEWPORT_BOUNDARY_NAME}[\\n\\s]`);
4829
- const hasOutletRegex = new RegExp(`\\n\\s+at ${_metadataconstants.OUTLET_BOUNDARY_NAME}[\\n\\s]`);
5283
+ // Common implicit body tags that React will treat as body when placed directly in html
5284
+ const bodyAndImplicitTags = 'body|div|main|section|article|aside|header|footer|nav|form|p|span|h1|h2|h3|h4|h5|h6';
5285
+ // Detects when RootLayoutBoundary (our framework marker component) appears
5286
+ // after Suspense in the component stack, indicating the root layout is wrapped
5287
+ // within a Suspense boundary. Ensures no body/html/implicit-body components are in between.
5288
+ //
5289
+ // Example matches:
5290
+ // at Suspense (<anonymous>)
5291
+ // at __next_root_layout_boundary__ (<anonymous>)
5292
+ //
5293
+ // Or with other components in between (but not body/html/implicit-body):
5294
+ // at Suspense (<anonymous>)
5295
+ // at SomeComponent (<anonymous>)
5296
+ // at __next_root_layout_boundary__ (<anonymous>)
5297
+ const hasSuspenseBeforeRootLayoutWithoutBodyOrImplicitBodyRegex = new RegExp(`\\n\\s+at Suspense \\(<anonymous>\\)(?:(?!\\n\\s+at (?:${bodyAndImplicitTags}) \\(<anonymous>\\))[\\s\\S])*?\\n\\s+at ${_boundaryconstants.ROOT_LAYOUT_BOUNDARY_NAME} \\([^\\n]*\\)`);
5298
+ const hasMetadataRegex = new RegExp(`\\n\\s+at ${_boundaryconstants.METADATA_BOUNDARY_NAME}[\\n\\s]`);
5299
+ const hasViewportRegex = new RegExp(`\\n\\s+at ${_boundaryconstants.VIEWPORT_BOUNDARY_NAME}[\\n\\s]`);
5300
+ const hasOutletRegex = new RegExp(`\\n\\s+at ${_boundaryconstants.OUTLET_BOUNDARY_NAME}[\\n\\s]`);
4830
5301
  function trackAllowedDynamicAccess(workStore, componentStack, dynamicValidation, clientDynamic) {
4831
5302
  if (hasOutletRegex.test(componentStack)) {
4832
5303
  // We don't need to track that this is dynamic. It is only so when something else is also dynamic.
@@ -4837,9 +5308,10 @@ var scheduler = {};
4837
5308
  } else if (hasViewportRegex.test(componentStack)) {
4838
5309
  dynamicValidation.hasDynamicViewport = true;
4839
5310
  return;
4840
- } else if (hasSuspenseAfterBodyOrHtmlRegex.test(componentStack)) {
4841
- // This prerender has a Suspense boundary above the body which
4842
- // effectively opts the page into allowing 100% dynamic rendering
5311
+ } else if (hasSuspenseBeforeRootLayoutWithoutBodyOrImplicitBodyRegex.test(componentStack)) {
5312
+ // For Suspense within body, the prelude wouldn't be empty so it wouldn't violate the empty static shells rule.
5313
+ // But if you have Suspense above body, the prelude is empty but we allow that because having Suspense
5314
+ // is an explicit signal from the user that they acknowledge the empty shell and want dynamic rendering.
4843
5315
  dynamicValidation.hasAllowedDynamic = true;
4844
5316
  dynamicValidation.hasSuspenseAboveBody = true;
4845
5317
  return;
@@ -4853,7 +5325,7 @@ var scheduler = {};
4853
5325
  dynamicValidation.dynamicErrors.push(clientDynamic.syncDynamicErrorWithStack);
4854
5326
  return;
4855
5327
  } else {
4856
- const message = `Route "${workStore.route}": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it. See more info: https://nextjs.org/docs/messages/next-prerender-missing-suspense`;
5328
+ const message = `Route "${workStore.route}": Uncached data was accessed outside of ` + '<Suspense>. This delays the entire page from rendering, resulting in a ' + 'slow user experience. Learn more: ' + 'https://nextjs.org/docs/messages/blocking-route';
4857
5329
  const error = createErrorWithComponentOrOwnerStack(message, componentStack);
4858
5330
  dynamicValidation.dynamicErrors.push(error);
4859
5331
  return;
@@ -4891,8 +5363,8 @@ var scheduler = {};
4891
5363
  }
4892
5364
  }
4893
5365
  function throwIfDisallowedDynamic(workStore, prelude, dynamicValidation, serverDynamic) {
4894
- if (workStore.invalidDynamicUsageError) {
4895
- logDisallowedDynamicError(workStore, workStore.invalidDynamicUsageError);
5366
+ if (serverDynamic.syncDynamicErrorWithStack) {
5367
+ logDisallowedDynamicError(workStore, serverDynamic.syncDynamicErrorWithStack);
4896
5368
  throw new _staticgenerationbailout.StaticGenBailoutError();
4897
5369
  }
4898
5370
  if (prelude !== 0) {
@@ -4902,13 +5374,6 @@ var scheduler = {};
4902
5374
  // a lack of a shell is not considered disallowed so we simply return
4903
5375
  return;
4904
5376
  }
4905
- if (serverDynamic.syncDynamicErrorWithStack) {
4906
- // There is no shell and the server did something sync dynamic likely
4907
- // leading to an early termination of the prerender before the shell
4908
- // could be completed. We terminate the build/validating render.
4909
- logDisallowedDynamicError(workStore, serverDynamic.syncDynamicErrorWithStack);
4910
- throw new _staticgenerationbailout.StaticGenBailoutError();
4911
- }
4912
5377
  // We didn't have any sync bailouts but there may be user code which
4913
5378
  // blocked the root. We would have captured these during the prerender
4914
5379
  // and can log them here and then terminate the build/validating render
@@ -4941,6 +5406,12 @@ var scheduler = {};
4941
5406
  }
4942
5407
  }
4943
5408
  }
5409
+ function delayUntilRuntimeStage(prerenderStore, result) {
5410
+ if (prerenderStore.runtimeStagePromise) {
5411
+ return prerenderStore.runtimeStagePromise.then(()=>result);
5412
+ }
5413
+ return result;
5414
+ }
4944
5415
 
4945
5416
 
4946
5417
  } (dynamicRendering));
@@ -4999,22 +5470,12 @@ var afterTaskAsyncStorageInstance = {};
4999
5470
  throwForSearchParamsAccessInUseCache: function() {
5000
5471
  return throwForSearchParamsAccessInUseCache;
5001
5472
  },
5002
- throwWithStaticGenerationBailoutError: function() {
5003
- return throwWithStaticGenerationBailoutError;
5004
- },
5005
5473
  throwWithStaticGenerationBailoutErrorWithDynamicError: function() {
5006
5474
  return throwWithStaticGenerationBailoutErrorWithDynamicError;
5007
5475
  }
5008
5476
  });
5009
5477
  const _staticgenerationbailout = staticGenerationBailoutExports;
5010
5478
  const _aftertaskasyncstorageexternal = afterTaskAsyncStorage_external;
5011
- function throwWithStaticGenerationBailoutError(route, expression) {
5012
- throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${route} couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
5013
- value: "E576",
5014
- enumerable: false,
5015
- configurable: true
5016
- });
5017
- }
5018
5479
  function throwWithStaticGenerationBailoutErrorWithDynamicError(route, expression) {
5019
5480
  throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${route} with \`dynamic = "error"\` couldn't be rendered statically because it used ${expression}. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
5020
5481
  value: "E543",
@@ -5023,8 +5484,8 @@ var afterTaskAsyncStorageInstance = {};
5023
5484
  });
5024
5485
  }
5025
5486
  function throwForSearchParamsAccessInUseCache(workStore, constructorOpt) {
5026
- const error = Object.defineProperty(new Error(`Route ${workStore.route} used "searchParams" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "searchParams" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
5027
- value: "E634",
5487
+ const error = Object.defineProperty(new Error(`Route ${workStore.route} used \`searchParams\` inside "use cache". Accessing dynamic request data inside a cache scope is not supported. If you need some search params inside a cached function await \`searchParams\` outside of the cached function and pass only the required search params as arguments to the cached function. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
5488
+ value: "E842",
5028
5489
  enumerable: false,
5029
5490
  configurable: true
5030
5491
  });
@@ -5056,294 +5517,100 @@ var afterTaskAsyncStorageInstance = {};
5056
5517
  const _staticgenerationbailout = staticGenerationBailoutExports;
5057
5518
  const _dynamicrenderingutils = dynamicRenderingUtils;
5058
5519
  const _utils = utils;
5520
+ const _stagedrendering = stagedRendering;
5059
5521
  function connection() {
5522
+ const callingExpression = 'connection';
5060
5523
  const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
5061
5524
  const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
5062
5525
  if (workStore) {
5063
5526
  if (workUnitStore && workUnitStore.phase === 'after' && !(0, _utils.isRequestAPICallableInsideAfter)()) {
5064
- throw Object.defineProperty(new Error(`Route ${workStore.route} used "connection" inside "after(...)". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but "after(...)" executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`), "__NEXT_ERROR_CODE", {
5065
- value: "E186",
5527
+ throw Object.defineProperty(new Error(`Route ${workStore.route} used \`connection()\` inside \`after()\`. The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but \`after()\` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`), "__NEXT_ERROR_CODE", {
5528
+ value: "E827",
5066
5529
  enumerable: false,
5067
5530
  configurable: true
5068
5531
  });
5069
5532
  }
5070
5533
  if (workStore.forceStatic) {
5071
- // When using forceStatic we override all other logic and always just return an empty
5072
- // headers object without tracking
5534
+ // When using forceStatic, we override all other logic and always just
5535
+ // return a resolving promise without tracking.
5073
5536
  return Promise.resolve(undefined);
5074
5537
  }
5075
- if (workUnitStore) {
5076
- if (workUnitStore.type === 'cache') {
5077
- throw Object.defineProperty(new Error(`Route ${workStore.route} used "connection" inside "use cache". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
5078
- value: "E111",
5079
- enumerable: false,
5080
- configurable: true
5081
- });
5082
- } else if (workUnitStore.type === 'unstable-cache') {
5083
- throw Object.defineProperty(new Error(`Route ${workStore.route} used "connection" inside a function cached with "unstable_cache(...)". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`), "__NEXT_ERROR_CODE", {
5084
- value: "E1",
5085
- enumerable: false,
5086
- configurable: true
5087
- });
5088
- }
5089
- }
5090
5538
  if (workStore.dynamicShouldError) {
5091
- throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${workStore.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`connection\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
5092
- value: "E562",
5539
+ throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${workStore.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`connection()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
5540
+ value: "E847",
5093
5541
  enumerable: false,
5094
5542
  configurable: true
5095
5543
  });
5096
5544
  }
5097
5545
  if (workUnitStore) {
5098
- if (workUnitStore.type === 'prerender' || workUnitStore.type === 'prerender-client') {
5099
- // dynamicIO Prerender
5100
- // We return a promise that never resolves to allow the prender to stall at this point
5101
- return (0, _dynamicrenderingutils.makeHangingPromise)(workUnitStore.renderSignal, '`connection()`');
5102
- } else if (workUnitStore.type === 'prerender-ppr') {
5103
- // PPR Prerender (no dynamicIO)
5104
- // We use React's postpone API to interrupt rendering here to create a dynamic hole
5105
- (0, _dynamicrendering.postponeWithTracking)(workStore.route, 'connection', workUnitStore.dynamicTracking);
5106
- } else if (workUnitStore.type === 'prerender-legacy') {
5107
- // Legacy Prerender
5108
- // We throw an error here to interrupt prerendering to mark the route as dynamic
5109
- (0, _dynamicrendering.throwToInterruptStaticGeneration)('connection', workStore, workUnitStore);
5110
- }
5111
- }
5112
- // We fall through to the dynamic context below but we still track dynamic access
5113
- // because in dev we can still error for things like using headers inside a cache context
5114
- (0, _dynamicrendering.trackDynamicDataInDynamicRender)(workStore, workUnitStore);
5115
- }
5116
- return Promise.resolve(undefined);
5117
- }
5118
-
5119
-
5120
- } (connection));
5121
-
5122
- var rootParams = {};
5123
-
5124
- var invariantError = {};
5125
-
5126
- (function (exports) {
5127
- Object.defineProperty(exports, "__esModule", {
5128
- value: true
5129
- });
5130
- Object.defineProperty(exports, "InvariantError", {
5131
- enumerable: true,
5132
- get: function() {
5133
- return InvariantError;
5134
- }
5135
- });
5136
- class InvariantError extends Error {
5137
- constructor(message, options){
5138
- super("Invariant: " + (message.endsWith('.') ? message : message + '.') + " This is a bug in Next.js.", options);
5139
- this.name = 'InvariantError';
5140
- }
5141
- }
5142
-
5143
-
5144
- } (invariantError));
5145
-
5146
- var reflectUtils = {};
5147
-
5148
- (function (exports) {
5149
- Object.defineProperty(exports, "__esModule", {
5150
- value: true
5151
- });
5152
- function _export(target, all) {
5153
- for(var name in all)Object.defineProperty(target, name, {
5154
- enumerable: true,
5155
- get: all[name]
5156
- });
5157
- }
5158
- _export(exports, {
5159
- describeHasCheckingStringProperty: function() {
5160
- return describeHasCheckingStringProperty;
5161
- },
5162
- describeStringPropertyAccess: function() {
5163
- return describeStringPropertyAccess;
5164
- },
5165
- wellKnownProperties: function() {
5166
- return wellKnownProperties;
5167
- }
5168
- });
5169
- const isDefinitelyAValidIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
5170
- function describeStringPropertyAccess(target, prop) {
5171
- if (isDefinitelyAValidIdentifier.test(prop)) {
5172
- return "`" + target + "." + prop + "`";
5173
- }
5174
- return "`" + target + "[" + JSON.stringify(prop) + "]`";
5175
- }
5176
- function describeHasCheckingStringProperty(target, prop) {
5177
- const stringifiedProp = JSON.stringify(prop);
5178
- return "`Reflect.has(" + target + ", " + stringifiedProp + ")`, `" + stringifiedProp + " in " + target + "`, or similar";
5179
- }
5180
- const wellKnownProperties = new Set([
5181
- 'hasOwnProperty',
5182
- 'isPrototypeOf',
5183
- 'propertyIsEnumerable',
5184
- 'toString',
5185
- 'valueOf',
5186
- 'toLocaleString',
5187
- // Promise prototype
5188
- // fallthrough
5189
- 'then',
5190
- 'catch',
5191
- 'finally',
5192
- // React Promise extension
5193
- // fallthrough
5194
- 'status',
5195
- // React introspection
5196
- 'displayName',
5197
- '_debugInfo',
5198
- // Common tested properties
5199
- // fallthrough
5200
- 'toJSON',
5201
- '$$typeof',
5202
- '__esModule'
5203
- ]);
5204
-
5205
-
5206
- } (reflectUtils));
5207
-
5208
- (function (exports) {
5209
- Object.defineProperty(exports, "__esModule", {
5210
- value: true
5211
- });
5212
- Object.defineProperty(exports, "unstable_rootParams", {
5213
- enumerable: true,
5214
- get: function() {
5215
- return unstable_rootParams;
5216
- }
5217
- });
5218
- const _invarianterror = invariantError;
5219
- const _dynamicrendering = dynamicRendering;
5220
- const _workasyncstorageexternal = workAsyncStorage_external;
5221
- const _workunitasyncstorageexternal = workUnitAsyncStorage_external;
5222
- const _dynamicrenderingutils = dynamicRenderingUtils;
5223
- const _reflectutils = reflectUtils;
5224
- const CachedParams = new WeakMap();
5225
- async function unstable_rootParams() {
5226
- const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
5227
- if (!workStore) {
5228
- throw Object.defineProperty(new _invarianterror.InvariantError('Missing workStore in unstable_rootParams'), "__NEXT_ERROR_CODE", {
5229
- value: "E615",
5230
- enumerable: false,
5231
- configurable: true
5232
- });
5233
- }
5234
- const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
5235
- if (!workUnitStore) {
5236
- throw Object.defineProperty(new Error(`Route ${workStore.route} used \`unstable_rootParams()\` in Pages Router. This API is only available within App Router.`), "__NEXT_ERROR_CODE", {
5237
- value: "E641",
5238
- enumerable: false,
5239
- configurable: true
5240
- });
5241
- }
5242
- switch(workUnitStore.type){
5243
- case 'unstable-cache':
5244
- case 'cache':
5245
- {
5246
- throw Object.defineProperty(new Error(`Route ${workStore.route} used \`unstable_rootParams()\` inside \`"use cache"\` or \`unstable_cache\`. Support for this API inside cache scopes is planned for a future version of Next.js.`), "__NEXT_ERROR_CODE", {
5247
- value: "E642",
5248
- enumerable: false,
5249
- configurable: true
5250
- });
5251
- }
5252
- case 'prerender':
5253
- case 'prerender-client':
5254
- case 'prerender-ppr':
5255
- case 'prerender-legacy':
5256
- return createPrerenderRootParams(workUnitStore.rootParams, workStore, workUnitStore);
5257
- default:
5258
- return Promise.resolve(workUnitStore.rootParams);
5259
- }
5260
- }
5261
- function createPrerenderRootParams(underlyingParams, workStore, prerenderStore) {
5262
- const fallbackParams = workStore.fallbackRouteParams;
5263
- if (fallbackParams) {
5264
- let hasSomeFallbackParams = false;
5265
- for(const key in underlyingParams){
5266
- if (fallbackParams.has(key)) {
5267
- hasSomeFallbackParams = true;
5268
- break;
5269
- }
5270
- }
5271
- if (hasSomeFallbackParams) {
5272
- // params need to be treated as dynamic because we have at least one fallback param
5273
- switch(prerenderStore.type){
5274
- case 'prerender':
5275
- // We are in a dynamicIO prerender
5276
- const cachedParams = CachedParams.get(underlyingParams);
5277
- if (cachedParams) {
5278
- return cachedParams;
5546
+ switch(workUnitStore.type){
5547
+ case 'cache':
5548
+ {
5549
+ const error = Object.defineProperty(new Error(`Route ${workStore.route} used \`connection()\` inside "use cache". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual request, but caches must be able to be produced before a request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
5550
+ value: "E841",
5551
+ enumerable: false,
5552
+ configurable: true
5553
+ });
5554
+ Error.captureStackTrace(error, connection);
5555
+ workStore.invalidDynamicUsageError ??= error;
5556
+ throw error;
5279
5557
  }
5280
- const promise = (0, _dynamicrenderingutils.makeHangingPromise)(prerenderStore.renderSignal, '`unstable_rootParams`');
5281
- CachedParams.set(underlyingParams, promise);
5282
- return promise;
5283
- case 'prerender-client':
5284
- const exportName = '`unstable_rootParams`';
5285
- throw Object.defineProperty(new _invarianterror.InvariantError(`${exportName} must not be used within a client component. Next.js should be preventing ${exportName} from being included in client components statically, but did not in this case.`), "__NEXT_ERROR_CODE", {
5286
- value: "E693",
5558
+ case 'private-cache':
5559
+ {
5560
+ // It might not be intuitive to throw for private caches as well, but
5561
+ // we don't consider runtime prefetches as "actual requests" (in the
5562
+ // navigation sense), despite allowing them to read cookies.
5563
+ const error = Object.defineProperty(new Error(`Route ${workStore.route} used \`connection()\` inside "use cache: private". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual navigation request, but caches must be able to be produced before a navigation request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
5564
+ value: "E837",
5565
+ enumerable: false,
5566
+ configurable: true
5567
+ });
5568
+ Error.captureStackTrace(error, connection);
5569
+ workStore.invalidDynamicUsageError ??= error;
5570
+ throw error;
5571
+ }
5572
+ case 'unstable-cache':
5573
+ throw Object.defineProperty(new Error(`Route ${workStore.route} used \`connection()\` inside a function cached with \`unstable_cache()\`. The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`), "__NEXT_ERROR_CODE", {
5574
+ value: "E840",
5287
5575
  enumerable: false,
5288
5576
  configurable: true
5289
5577
  });
5290
- default:
5291
- // remaining cases are prerender-ppr and prerender-legacy
5292
- // We aren't in a dynamicIO prerender but we do have fallback params at this
5293
- // level so we need to make an erroring params object which will postpone
5294
- // if you access the fallback params
5295
- return makeErroringRootParams(underlyingParams, fallbackParams, workStore, prerenderStore);
5296
- }
5297
- }
5298
- }
5299
- // We don't have any fallback params so we have an entirely static safe params object
5300
- return Promise.resolve(underlyingParams);
5301
- }
5302
- function makeErroringRootParams(underlyingParams, fallbackParams, workStore, prerenderStore) {
5303
- const cachedParams = CachedParams.get(underlyingParams);
5304
- if (cachedParams) {
5305
- return cachedParams;
5306
- }
5307
- const augmentedUnderlying = {
5308
- ...underlyingParams
5309
- };
5310
- // We don't use makeResolvedReactPromise here because params
5311
- // supports copying with spread and we don't want to unnecessarily
5312
- // instrument the promise with spreadable properties of ReactPromise.
5313
- const promise = Promise.resolve(augmentedUnderlying);
5314
- CachedParams.set(underlyingParams, promise);
5315
- Object.keys(underlyingParams).forEach((prop)=>{
5316
- if (_reflectutils.wellKnownProperties.has(prop)) ; else {
5317
- if (fallbackParams.has(prop)) {
5318
- Object.defineProperty(augmentedUnderlying, prop, {
5319
- get () {
5320
- const expression = (0, _reflectutils.describeStringPropertyAccess)('unstable_rootParams', prop);
5321
- // In most dynamic APIs we also throw if `dynamic = "error"` however
5322
- // for params is only dynamic when we're generating a fallback shell
5323
- // and even when `dynamic = "error"` we still support generating dynamic
5324
- // fallback shells
5325
- // TODO remove this comment when dynamicIO is the default since there
5326
- // will be no `dynamic = "error"`
5327
- if (prerenderStore.type === 'prerender-ppr') {
5328
- // PPR Prerender (no dynamicIO)
5329
- (0, _dynamicrendering.postponeWithTracking)(workStore.route, expression, prerenderStore.dynamicTracking);
5330
- } else {
5331
- // Legacy Prerender
5332
- (0, _dynamicrendering.throwToInterruptStaticGeneration)(expression, workStore, prerenderStore);
5578
+ case 'prerender':
5579
+ case 'prerender-client':
5580
+ case 'prerender-runtime':
5581
+ // We return a promise that never resolves to allow the prerender to
5582
+ // stall at this point.
5583
+ return (0, _dynamicrenderingutils.makeHangingPromise)(workUnitStore.renderSignal, workStore.route, '`connection()`');
5584
+ case 'prerender-ppr':
5585
+ // We use React's postpone API to interrupt rendering here to create a
5586
+ // dynamic hole
5587
+ return (0, _dynamicrendering.postponeWithTracking)(workStore.route, 'connection', workUnitStore.dynamicTracking);
5588
+ case 'prerender-legacy':
5589
+ // We throw an error here to interrupt prerendering to mark the route
5590
+ // as dynamic
5591
+ return (0, _dynamicrendering.throwToInterruptStaticGeneration)('connection', workStore, workUnitStore);
5592
+ case 'request':
5593
+ (0, _dynamicrendering.trackDynamicDataInDynamicRender)(workUnitStore);
5594
+ if (process.env.NODE_ENV === 'development') {
5595
+ // Semantically we only need the dev tracking when running in `next dev`
5596
+ // but since you would never use next dev with production NODE_ENV we use this
5597
+ // as a proxy so we can statically exclude this code from production builds.
5598
+ if (workUnitStore.asyncApiPromises) {
5599
+ return workUnitStore.asyncApiPromises.connection;
5333
5600
  }
5334
- },
5335
- enumerable: true
5336
- });
5337
- } else {
5338
- promise[prop] = underlyingParams[prop];
5601
+ return (0, _dynamicrenderingutils.makeDevtoolsIOAwarePromise)(undefined, workUnitStore, _stagedrendering.RenderStage.Dynamic);
5602
+ } else {
5603
+ return Promise.resolve(undefined);
5604
+ }
5339
5605
  }
5340
5606
  }
5341
- });
5342
- return promise;
5607
+ }
5608
+ // If we end up here, there was no work store or work unit store present.
5609
+ (0, _workunitasyncstorageexternal.throwForMissingRequestStore)(callingExpression);
5343
5610
  }
5344
5611
 
5345
5612
 
5346
- } (rootParams));
5613
+ } (connection));
5347
5614
 
5348
5615
  (function (module, exports) {
5349
5616
  const serverExports = {
@@ -5361,8 +5628,6 @@ var reflectUtils = {};
5361
5628
  .URLPattern,
5362
5629
  after: after$1.after,
5363
5630
  connection: connection.connection,
5364
- unstable_rootParams: rootParams
5365
- .unstable_rootParams,
5366
5631
  };
5367
5632
 
5368
5633
  // https://nodejs.org/api/esm.html#commonjs-namespaces
@@ -5377,8 +5642,7 @@ var reflectUtils = {};
5377
5642
  exports.userAgent = serverExports.userAgent;
5378
5643
  exports.URLPattern = serverExports.URLPattern;
5379
5644
  exports.after = serverExports.after;
5380
- exports.connection = serverExports.connection;
5381
- exports.unstable_rootParams = serverExports.unstable_rootParams;
5645
+ exports.connection = serverExports.connection;
5382
5646
  } (server, server.exports));
5383
5647
 
5384
5648
  var serverExports = server.exports;
@@ -12546,6 +12810,13 @@ var checkoutSessionCustomizationSchema = objectType({
12546
12810
  }).optional();
12547
12811
  var checkoutSessionFeatureFlagsSchema = objectType({
12548
12812
  allow_currency_selection: booleanType().optional(),
12813
+ allow_customer_editing_city: booleanType().optional(),
12814
+ allow_customer_editing_country: booleanType().optional(),
12815
+ allow_customer_editing_email: booleanType().optional(),
12816
+ allow_customer_editing_name: booleanType().optional(),
12817
+ allow_customer_editing_state: booleanType().optional(),
12818
+ allow_customer_editing_street: booleanType().optional(),
12819
+ allow_customer_editing_zipcode: booleanType().optional(),
12549
12820
  allow_discount_code: booleanType().optional(),
12550
12821
  allow_phone_number_collection: booleanType().optional(),
12551
12822
  allow_tax_id: booleanType().optional(),
@@ -12646,7 +12917,11 @@ var buildCheckoutUrl = async ({
12646
12917
  if (!sessionPayload) {
12647
12918
  throw new Error("sessionPayload is required when type is 'session'");
12648
12919
  }
12649
- const session = await createCheckoutSession(sessionPayload, {
12920
+ const finalPayload = {
12921
+ ...sessionPayload,
12922
+ return_url: sessionPayload.return_url ?? returnUrl
12923
+ };
12924
+ const session = await createCheckoutSession(finalPayload, {
12650
12925
  bearerToken,
12651
12926
  environment
12652
12927
  });
@@ -12878,6 +13153,32 @@ var buildCheckoutUrl = async ({
12878
13153
  }
12879
13154
  };
12880
13155
 
13156
+ var __create = Object.create;
13157
+ var __defProp = Object.defineProperty;
13158
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13159
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13160
+ var __getProtoOf = Object.getPrototypeOf;
13161
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13162
+ var __commonJS = (cb, mod) => function __require2() {
13163
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13164
+ };
13165
+ var __copyProps = (to, from, except, desc) => {
13166
+ if (from && typeof from === "object" || typeof from === "function") {
13167
+ for (let key of __getOwnPropNames(from))
13168
+ if (!__hasOwnProp.call(to, key) && key !== except)
13169
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13170
+ }
13171
+ return to;
13172
+ };
13173
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
13174
+ // If the importer is in node compatibility mode or this is not an ESM
13175
+ // file that has been converted to a CommonJS file using a Babel-
13176
+ // compatible transform (i.e. "__esModule" has not been set), then set
13177
+ // "default" to the CommonJS "module.exports" for node compatibility.
13178
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
13179
+ mod
13180
+ ));
13181
+
12881
13182
  const Checkout = (config) => {
12882
13183
  const getHandler = async (req) => {
12883
13184
  const { searchParams } = new URL(req.url);
@@ -13277,6 +13578,12 @@ var SubscriptionExpiredPayloadSchema = objectType({
13277
13578
  timestamp: stringType().transform((d) => new Date(d)),
13278
13579
  data: SubscriptionSchema
13279
13580
  });
13581
+ var SubscriptionUpdatedPayloadSchema = objectType({
13582
+ business_id: stringType(),
13583
+ type: literalType("subscription.updated"),
13584
+ timestamp: stringType().transform((d) => new Date(d)),
13585
+ data: SubscriptionSchema
13586
+ });
13280
13587
  var LicenseKeyCreatedPayloadSchema = objectType({
13281
13588
  business_id: stringType(),
13282
13589
  type: literalType("license_key.created"),
@@ -13305,9 +13612,679 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
13305
13612
  SubscriptionCancelledPayloadSchema,
13306
13613
  SubscriptionFailedPayloadSchema,
13307
13614
  SubscriptionExpiredPayloadSchema,
13615
+ SubscriptionUpdatedPayloadSchema,
13308
13616
  LicenseKeyCreatedPayloadSchema
13309
13617
  ]);
13310
13618
 
13619
+ // ../../node_modules/@stablelib/base64/lib/base64.js
13620
+ var require_base64 = __commonJS({
13621
+ "../../node_modules/@stablelib/base64/lib/base64.js"(exports) {
13622
+ var __extends = exports && exports.__extends || /* @__PURE__ */ function() {
13623
+ var extendStatics = function(d, b) {
13624
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
13625
+ d2.__proto__ = b2;
13626
+ } || function(d2, b2) {
13627
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
13628
+ };
13629
+ return extendStatics(d, b);
13630
+ };
13631
+ return function(d, b) {
13632
+ extendStatics(d, b);
13633
+ function __() {
13634
+ this.constructor = d;
13635
+ }
13636
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13637
+ };
13638
+ }();
13639
+ Object.defineProperty(exports, "__esModule", { value: true });
13640
+ var INVALID_BYTE = 256;
13641
+ var Coder = (
13642
+ /** @class */
13643
+ function() {
13644
+ function Coder2(_paddingCharacter) {
13645
+ if (_paddingCharacter === void 0) {
13646
+ _paddingCharacter = "=";
13647
+ }
13648
+ this._paddingCharacter = _paddingCharacter;
13649
+ }
13650
+ Coder2.prototype.encodedLength = function(length) {
13651
+ if (!this._paddingCharacter) {
13652
+ return (length * 8 + 5) / 6 | 0;
13653
+ }
13654
+ return (length + 2) / 3 * 4 | 0;
13655
+ };
13656
+ Coder2.prototype.encode = function(data) {
13657
+ var out = "";
13658
+ var i = 0;
13659
+ for (; i < data.length - 2; i += 3) {
13660
+ var c = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
13661
+ out += this._encodeByte(c >>> 3 * 6 & 63);
13662
+ out += this._encodeByte(c >>> 2 * 6 & 63);
13663
+ out += this._encodeByte(c >>> 1 * 6 & 63);
13664
+ out += this._encodeByte(c >>> 0 * 6 & 63);
13665
+ }
13666
+ var left = data.length - i;
13667
+ if (left > 0) {
13668
+ var c = data[i] << 16 | (left === 2 ? data[i + 1] << 8 : 0);
13669
+ out += this._encodeByte(c >>> 3 * 6 & 63);
13670
+ out += this._encodeByte(c >>> 2 * 6 & 63);
13671
+ if (left === 2) {
13672
+ out += this._encodeByte(c >>> 1 * 6 & 63);
13673
+ } else {
13674
+ out += this._paddingCharacter || "";
13675
+ }
13676
+ out += this._paddingCharacter || "";
13677
+ }
13678
+ return out;
13679
+ };
13680
+ Coder2.prototype.maxDecodedLength = function(length) {
13681
+ if (!this._paddingCharacter) {
13682
+ return (length * 6 + 7) / 8 | 0;
13683
+ }
13684
+ return length / 4 * 3 | 0;
13685
+ };
13686
+ Coder2.prototype.decodedLength = function(s) {
13687
+ return this.maxDecodedLength(s.length - this._getPaddingLength(s));
13688
+ };
13689
+ Coder2.prototype.decode = function(s) {
13690
+ if (s.length === 0) {
13691
+ return new Uint8Array(0);
13692
+ }
13693
+ var paddingLength = this._getPaddingLength(s);
13694
+ var length = s.length - paddingLength;
13695
+ var out = new Uint8Array(this.maxDecodedLength(length));
13696
+ var op = 0;
13697
+ var i = 0;
13698
+ var haveBad = 0;
13699
+ var v0 = 0, v1 = 0, v2 = 0, v3 = 0;
13700
+ for (; i < length - 4; i += 4) {
13701
+ v0 = this._decodeChar(s.charCodeAt(i + 0));
13702
+ v1 = this._decodeChar(s.charCodeAt(i + 1));
13703
+ v2 = this._decodeChar(s.charCodeAt(i + 2));
13704
+ v3 = this._decodeChar(s.charCodeAt(i + 3));
13705
+ out[op++] = v0 << 2 | v1 >>> 4;
13706
+ out[op++] = v1 << 4 | v2 >>> 2;
13707
+ out[op++] = v2 << 6 | v3;
13708
+ haveBad |= v0 & INVALID_BYTE;
13709
+ haveBad |= v1 & INVALID_BYTE;
13710
+ haveBad |= v2 & INVALID_BYTE;
13711
+ haveBad |= v3 & INVALID_BYTE;
13712
+ }
13713
+ if (i < length - 1) {
13714
+ v0 = this._decodeChar(s.charCodeAt(i));
13715
+ v1 = this._decodeChar(s.charCodeAt(i + 1));
13716
+ out[op++] = v0 << 2 | v1 >>> 4;
13717
+ haveBad |= v0 & INVALID_BYTE;
13718
+ haveBad |= v1 & INVALID_BYTE;
13719
+ }
13720
+ if (i < length - 2) {
13721
+ v2 = this._decodeChar(s.charCodeAt(i + 2));
13722
+ out[op++] = v1 << 4 | v2 >>> 2;
13723
+ haveBad |= v2 & INVALID_BYTE;
13724
+ }
13725
+ if (i < length - 3) {
13726
+ v3 = this._decodeChar(s.charCodeAt(i + 3));
13727
+ out[op++] = v2 << 6 | v3;
13728
+ haveBad |= v3 & INVALID_BYTE;
13729
+ }
13730
+ if (haveBad !== 0) {
13731
+ throw new Error("Base64Coder: incorrect characters for decoding");
13732
+ }
13733
+ return out;
13734
+ };
13735
+ Coder2.prototype._encodeByte = function(b) {
13736
+ var result = b;
13737
+ result += 65;
13738
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
13739
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
13740
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 43;
13741
+ result += 62 - b >>> 8 & 62 - 43 - 63 + 47;
13742
+ return String.fromCharCode(result);
13743
+ };
13744
+ Coder2.prototype._decodeChar = function(c) {
13745
+ var result = INVALID_BYTE;
13746
+ result += (42 - c & c - 44) >>> 8 & -INVALID_BYTE + c - 43 + 62;
13747
+ result += (46 - c & c - 48) >>> 8 & -INVALID_BYTE + c - 47 + 63;
13748
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
13749
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
13750
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
13751
+ return result;
13752
+ };
13753
+ Coder2.prototype._getPaddingLength = function(s) {
13754
+ var paddingLength = 0;
13755
+ if (this._paddingCharacter) {
13756
+ for (var i = s.length - 1; i >= 0; i--) {
13757
+ if (s[i] !== this._paddingCharacter) {
13758
+ break;
13759
+ }
13760
+ paddingLength++;
13761
+ }
13762
+ if (s.length < 4 || paddingLength > 2) {
13763
+ throw new Error("Base64Coder: incorrect padding");
13764
+ }
13765
+ }
13766
+ return paddingLength;
13767
+ };
13768
+ return Coder2;
13769
+ }()
13770
+ );
13771
+ exports.Coder = Coder;
13772
+ var stdCoder = new Coder();
13773
+ function encode2(data) {
13774
+ return stdCoder.encode(data);
13775
+ }
13776
+ exports.encode = encode2;
13777
+ function decode2(s) {
13778
+ return stdCoder.decode(s);
13779
+ }
13780
+ exports.decode = decode2;
13781
+ var URLSafeCoder = (
13782
+ /** @class */
13783
+ function(_super) {
13784
+ __extends(URLSafeCoder2, _super);
13785
+ function URLSafeCoder2() {
13786
+ return _super !== null && _super.apply(this, arguments) || this;
13787
+ }
13788
+ URLSafeCoder2.prototype._encodeByte = function(b) {
13789
+ var result = b;
13790
+ result += 65;
13791
+ result += 25 - b >>> 8 & 0 - 65 - 26 + 97;
13792
+ result += 51 - b >>> 8 & 26 - 97 - 52 + 48;
13793
+ result += 61 - b >>> 8 & 52 - 48 - 62 + 45;
13794
+ result += 62 - b >>> 8 & 62 - 45 - 63 + 95;
13795
+ return String.fromCharCode(result);
13796
+ };
13797
+ URLSafeCoder2.prototype._decodeChar = function(c) {
13798
+ var result = INVALID_BYTE;
13799
+ result += (44 - c & c - 46) >>> 8 & -INVALID_BYTE + c - 45 + 62;
13800
+ result += (94 - c & c - 96) >>> 8 & -INVALID_BYTE + c - 95 + 63;
13801
+ result += (47 - c & c - 58) >>> 8 & -INVALID_BYTE + c - 48 + 52;
13802
+ result += (64 - c & c - 91) >>> 8 & -INVALID_BYTE + c - 65 + 0;
13803
+ result += (96 - c & c - 123) >>> 8 & -INVALID_BYTE + c - 97 + 26;
13804
+ return result;
13805
+ };
13806
+ return URLSafeCoder2;
13807
+ }(Coder)
13808
+ );
13809
+ exports.URLSafeCoder = URLSafeCoder;
13810
+ var urlSafeCoder = new URLSafeCoder();
13811
+ function encodeURLSafe(data) {
13812
+ return urlSafeCoder.encode(data);
13813
+ }
13814
+ exports.encodeURLSafe = encodeURLSafe;
13815
+ function decodeURLSafe(s) {
13816
+ return urlSafeCoder.decode(s);
13817
+ }
13818
+ exports.decodeURLSafe = decodeURLSafe;
13819
+ exports.encodedLength = function(length) {
13820
+ return stdCoder.encodedLength(length);
13821
+ };
13822
+ exports.maxDecodedLength = function(length) {
13823
+ return stdCoder.maxDecodedLength(length);
13824
+ };
13825
+ exports.decodedLength = function(s) {
13826
+ return stdCoder.decodedLength(s);
13827
+ };
13828
+ }
13829
+ });
13830
+
13831
+ // ../../node_modules/fast-sha256/sha256.js
13832
+ var require_sha256 = __commonJS({
13833
+ "../../node_modules/fast-sha256/sha256.js"(exports, module) {
13834
+ (function(root, factory) {
13835
+ var exports2 = {};
13836
+ factory(exports2);
13837
+ var sha2562 = exports2["default"];
13838
+ for (var k in exports2) {
13839
+ sha2562[k] = exports2[k];
13840
+ }
13841
+ if (typeof module === "object" && typeof module.exports === "object") {
13842
+ module.exports = sha2562;
13843
+ } else if (typeof define === "function" && define.amd) {
13844
+ define(function() {
13845
+ return sha2562;
13846
+ });
13847
+ } else {
13848
+ root.sha256 = sha2562;
13849
+ }
13850
+ })(exports, function(exports2) {
13851
+ exports2.__esModule = true;
13852
+ exports2.digestLength = 32;
13853
+ exports2.blockSize = 64;
13854
+ var K = new Uint32Array([
13855
+ 1116352408,
13856
+ 1899447441,
13857
+ 3049323471,
13858
+ 3921009573,
13859
+ 961987163,
13860
+ 1508970993,
13861
+ 2453635748,
13862
+ 2870763221,
13863
+ 3624381080,
13864
+ 310598401,
13865
+ 607225278,
13866
+ 1426881987,
13867
+ 1925078388,
13868
+ 2162078206,
13869
+ 2614888103,
13870
+ 3248222580,
13871
+ 3835390401,
13872
+ 4022224774,
13873
+ 264347078,
13874
+ 604807628,
13875
+ 770255983,
13876
+ 1249150122,
13877
+ 1555081692,
13878
+ 1996064986,
13879
+ 2554220882,
13880
+ 2821834349,
13881
+ 2952996808,
13882
+ 3210313671,
13883
+ 3336571891,
13884
+ 3584528711,
13885
+ 113926993,
13886
+ 338241895,
13887
+ 666307205,
13888
+ 773529912,
13889
+ 1294757372,
13890
+ 1396182291,
13891
+ 1695183700,
13892
+ 1986661051,
13893
+ 2177026350,
13894
+ 2456956037,
13895
+ 2730485921,
13896
+ 2820302411,
13897
+ 3259730800,
13898
+ 3345764771,
13899
+ 3516065817,
13900
+ 3600352804,
13901
+ 4094571909,
13902
+ 275423344,
13903
+ 430227734,
13904
+ 506948616,
13905
+ 659060556,
13906
+ 883997877,
13907
+ 958139571,
13908
+ 1322822218,
13909
+ 1537002063,
13910
+ 1747873779,
13911
+ 1955562222,
13912
+ 2024104815,
13913
+ 2227730452,
13914
+ 2361852424,
13915
+ 2428436474,
13916
+ 2756734187,
13917
+ 3204031479,
13918
+ 3329325298
13919
+ ]);
13920
+ function hashBlocks(w, v, p, pos, len) {
13921
+ var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
13922
+ while (len >= 64) {
13923
+ a = v[0];
13924
+ b = v[1];
13925
+ c = v[2];
13926
+ d = v[3];
13927
+ e = v[4];
13928
+ f = v[5];
13929
+ g = v[6];
13930
+ h = v[7];
13931
+ for (i = 0; i < 16; i++) {
13932
+ j = pos + i * 4;
13933
+ w[i] = (p[j] & 255) << 24 | (p[j + 1] & 255) << 16 | (p[j + 2] & 255) << 8 | p[j + 3] & 255;
13934
+ }
13935
+ for (i = 16; i < 64; i++) {
13936
+ u = w[i - 2];
13937
+ t1 = (u >>> 17 | u << 32 - 17) ^ (u >>> 19 | u << 32 - 19) ^ u >>> 10;
13938
+ u = w[i - 15];
13939
+ t2 = (u >>> 7 | u << 32 - 7) ^ (u >>> 18 | u << 32 - 18) ^ u >>> 3;
13940
+ w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
13941
+ }
13942
+ for (i = 0; i < 64; i++) {
13943
+ t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f ^ ~e & g) | 0) + (h + (K[i] + w[i] | 0) | 0) | 0;
13944
+ t2 = ((a >>> 2 | a << 32 - 2) ^ (a >>> 13 | a << 32 - 13) ^ (a >>> 22 | a << 32 - 22)) + (a & b ^ a & c ^ b & c) | 0;
13945
+ h = g;
13946
+ g = f;
13947
+ f = e;
13948
+ e = d + t1 | 0;
13949
+ d = c;
13950
+ c = b;
13951
+ b = a;
13952
+ a = t1 + t2 | 0;
13953
+ }
13954
+ v[0] += a;
13955
+ v[1] += b;
13956
+ v[2] += c;
13957
+ v[3] += d;
13958
+ v[4] += e;
13959
+ v[5] += f;
13960
+ v[6] += g;
13961
+ v[7] += h;
13962
+ pos += 64;
13963
+ len -= 64;
13964
+ }
13965
+ return pos;
13966
+ }
13967
+ var Hash = (
13968
+ /** @class */
13969
+ function() {
13970
+ function Hash2() {
13971
+ this.digestLength = exports2.digestLength;
13972
+ this.blockSize = exports2.blockSize;
13973
+ this.state = new Int32Array(8);
13974
+ this.temp = new Int32Array(64);
13975
+ this.buffer = new Uint8Array(128);
13976
+ this.bufferLength = 0;
13977
+ this.bytesHashed = 0;
13978
+ this.finished = false;
13979
+ this.reset();
13980
+ }
13981
+ Hash2.prototype.reset = function() {
13982
+ this.state[0] = 1779033703;
13983
+ this.state[1] = 3144134277;
13984
+ this.state[2] = 1013904242;
13985
+ this.state[3] = 2773480762;
13986
+ this.state[4] = 1359893119;
13987
+ this.state[5] = 2600822924;
13988
+ this.state[6] = 528734635;
13989
+ this.state[7] = 1541459225;
13990
+ this.bufferLength = 0;
13991
+ this.bytesHashed = 0;
13992
+ this.finished = false;
13993
+ return this;
13994
+ };
13995
+ Hash2.prototype.clean = function() {
13996
+ for (var i = 0; i < this.buffer.length; i++) {
13997
+ this.buffer[i] = 0;
13998
+ }
13999
+ for (var i = 0; i < this.temp.length; i++) {
14000
+ this.temp[i] = 0;
14001
+ }
14002
+ this.reset();
14003
+ };
14004
+ Hash2.prototype.update = function(data, dataLength) {
14005
+ if (dataLength === void 0) {
14006
+ dataLength = data.length;
14007
+ }
14008
+ if (this.finished) {
14009
+ throw new Error("SHA256: can't update because hash was finished.");
14010
+ }
14011
+ var dataPos = 0;
14012
+ this.bytesHashed += dataLength;
14013
+ if (this.bufferLength > 0) {
14014
+ while (this.bufferLength < 64 && dataLength > 0) {
14015
+ this.buffer[this.bufferLength++] = data[dataPos++];
14016
+ dataLength--;
14017
+ }
14018
+ if (this.bufferLength === 64) {
14019
+ hashBlocks(this.temp, this.state, this.buffer, 0, 64);
14020
+ this.bufferLength = 0;
14021
+ }
14022
+ }
14023
+ if (dataLength >= 64) {
14024
+ dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
14025
+ dataLength %= 64;
14026
+ }
14027
+ while (dataLength > 0) {
14028
+ this.buffer[this.bufferLength++] = data[dataPos++];
14029
+ dataLength--;
14030
+ }
14031
+ return this;
14032
+ };
14033
+ Hash2.prototype.finish = function(out) {
14034
+ if (!this.finished) {
14035
+ var bytesHashed = this.bytesHashed;
14036
+ var left = this.bufferLength;
14037
+ var bitLenHi = bytesHashed / 536870912 | 0;
14038
+ var bitLenLo = bytesHashed << 3;
14039
+ var padLength = bytesHashed % 64 < 56 ? 64 : 128;
14040
+ this.buffer[left] = 128;
14041
+ for (var i = left + 1; i < padLength - 8; i++) {
14042
+ this.buffer[i] = 0;
14043
+ }
14044
+ this.buffer[padLength - 8] = bitLenHi >>> 24 & 255;
14045
+ this.buffer[padLength - 7] = bitLenHi >>> 16 & 255;
14046
+ this.buffer[padLength - 6] = bitLenHi >>> 8 & 255;
14047
+ this.buffer[padLength - 5] = bitLenHi >>> 0 & 255;
14048
+ this.buffer[padLength - 4] = bitLenLo >>> 24 & 255;
14049
+ this.buffer[padLength - 3] = bitLenLo >>> 16 & 255;
14050
+ this.buffer[padLength - 2] = bitLenLo >>> 8 & 255;
14051
+ this.buffer[padLength - 1] = bitLenLo >>> 0 & 255;
14052
+ hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
14053
+ this.finished = true;
14054
+ }
14055
+ for (var i = 0; i < 8; i++) {
14056
+ out[i * 4 + 0] = this.state[i] >>> 24 & 255;
14057
+ out[i * 4 + 1] = this.state[i] >>> 16 & 255;
14058
+ out[i * 4 + 2] = this.state[i] >>> 8 & 255;
14059
+ out[i * 4 + 3] = this.state[i] >>> 0 & 255;
14060
+ }
14061
+ return this;
14062
+ };
14063
+ Hash2.prototype.digest = function() {
14064
+ var out = new Uint8Array(this.digestLength);
14065
+ this.finish(out);
14066
+ return out;
14067
+ };
14068
+ Hash2.prototype._saveState = function(out) {
14069
+ for (var i = 0; i < this.state.length; i++) {
14070
+ out[i] = this.state[i];
14071
+ }
14072
+ };
14073
+ Hash2.prototype._restoreState = function(from, bytesHashed) {
14074
+ for (var i = 0; i < this.state.length; i++) {
14075
+ this.state[i] = from[i];
14076
+ }
14077
+ this.bytesHashed = bytesHashed;
14078
+ this.finished = false;
14079
+ this.bufferLength = 0;
14080
+ };
14081
+ return Hash2;
14082
+ }()
14083
+ );
14084
+ exports2.Hash = Hash;
14085
+ var HMAC = (
14086
+ /** @class */
14087
+ function() {
14088
+ function HMAC2(key) {
14089
+ this.inner = new Hash();
14090
+ this.outer = new Hash();
14091
+ this.blockSize = this.inner.blockSize;
14092
+ this.digestLength = this.inner.digestLength;
14093
+ var pad = new Uint8Array(this.blockSize);
14094
+ if (key.length > this.blockSize) {
14095
+ new Hash().update(key).finish(pad).clean();
14096
+ } else {
14097
+ for (var i = 0; i < key.length; i++) {
14098
+ pad[i] = key[i];
14099
+ }
14100
+ }
14101
+ for (var i = 0; i < pad.length; i++) {
14102
+ pad[i] ^= 54;
14103
+ }
14104
+ this.inner.update(pad);
14105
+ for (var i = 0; i < pad.length; i++) {
14106
+ pad[i] ^= 54 ^ 92;
14107
+ }
14108
+ this.outer.update(pad);
14109
+ this.istate = new Uint32Array(8);
14110
+ this.ostate = new Uint32Array(8);
14111
+ this.inner._saveState(this.istate);
14112
+ this.outer._saveState(this.ostate);
14113
+ for (var i = 0; i < pad.length; i++) {
14114
+ pad[i] = 0;
14115
+ }
14116
+ }
14117
+ HMAC2.prototype.reset = function() {
14118
+ this.inner._restoreState(this.istate, this.inner.blockSize);
14119
+ this.outer._restoreState(this.ostate, this.outer.blockSize);
14120
+ return this;
14121
+ };
14122
+ HMAC2.prototype.clean = function() {
14123
+ for (var i = 0; i < this.istate.length; i++) {
14124
+ this.ostate[i] = this.istate[i] = 0;
14125
+ }
14126
+ this.inner.clean();
14127
+ this.outer.clean();
14128
+ };
14129
+ HMAC2.prototype.update = function(data) {
14130
+ this.inner.update(data);
14131
+ return this;
14132
+ };
14133
+ HMAC2.prototype.finish = function(out) {
14134
+ if (this.outer.finished) {
14135
+ this.outer.finish(out);
14136
+ } else {
14137
+ this.inner.finish(out);
14138
+ this.outer.update(out, this.digestLength).finish(out);
14139
+ }
14140
+ return this;
14141
+ };
14142
+ HMAC2.prototype.digest = function() {
14143
+ var out = new Uint8Array(this.digestLength);
14144
+ this.finish(out);
14145
+ return out;
14146
+ };
14147
+ return HMAC2;
14148
+ }()
14149
+ );
14150
+ exports2.HMAC = HMAC;
14151
+ function hash(data) {
14152
+ var h = new Hash().update(data);
14153
+ var digest = h.digest();
14154
+ h.clean();
14155
+ return digest;
14156
+ }
14157
+ exports2.hash = hash;
14158
+ exports2["default"] = hash;
14159
+ function hmac2(key, data) {
14160
+ var h = new HMAC(key).update(data);
14161
+ var digest = h.digest();
14162
+ h.clean();
14163
+ return digest;
14164
+ }
14165
+ exports2.hmac = hmac2;
14166
+ function fillBuffer(buffer, hmac3, info, counter) {
14167
+ var num = counter[0];
14168
+ if (num === 0) {
14169
+ throw new Error("hkdf: cannot expand more");
14170
+ }
14171
+ hmac3.reset();
14172
+ if (num > 1) {
14173
+ hmac3.update(buffer);
14174
+ }
14175
+ if (info) {
14176
+ hmac3.update(info);
14177
+ }
14178
+ hmac3.update(counter);
14179
+ hmac3.finish(buffer);
14180
+ counter[0]++;
14181
+ }
14182
+ var hkdfSalt = new Uint8Array(exports2.digestLength);
14183
+ function hkdf(key, salt, info, length) {
14184
+ if (salt === void 0) {
14185
+ salt = hkdfSalt;
14186
+ }
14187
+ if (length === void 0) {
14188
+ length = 32;
14189
+ }
14190
+ var counter = new Uint8Array([1]);
14191
+ var okm = hmac2(salt, key);
14192
+ var hmac_ = new HMAC(okm);
14193
+ var buffer = new Uint8Array(hmac_.digestLength);
14194
+ var bufpos = buffer.length;
14195
+ var out = new Uint8Array(length);
14196
+ for (var i = 0; i < length; i++) {
14197
+ if (bufpos === buffer.length) {
14198
+ fillBuffer(buffer, hmac_, info, counter);
14199
+ bufpos = 0;
14200
+ }
14201
+ out[i] = buffer[bufpos++];
14202
+ }
14203
+ hmac_.clean();
14204
+ buffer.fill(0);
14205
+ counter.fill(0);
14206
+ return out;
14207
+ }
14208
+ exports2.hkdf = hkdf;
14209
+ function pbkdf2(password, salt, iterations, dkLen) {
14210
+ var prf = new HMAC(password);
14211
+ var len = prf.digestLength;
14212
+ var ctr = new Uint8Array(4);
14213
+ var t = new Uint8Array(len);
14214
+ var u = new Uint8Array(len);
14215
+ var dk = new Uint8Array(dkLen);
14216
+ for (var i = 0; i * len < dkLen; i++) {
14217
+ var c = i + 1;
14218
+ ctr[0] = c >>> 24 & 255;
14219
+ ctr[1] = c >>> 16 & 255;
14220
+ ctr[2] = c >>> 8 & 255;
14221
+ ctr[3] = c >>> 0 & 255;
14222
+ prf.reset();
14223
+ prf.update(salt);
14224
+ prf.update(ctr);
14225
+ prf.finish(u);
14226
+ for (var j = 0; j < len; j++) {
14227
+ t[j] = u[j];
14228
+ }
14229
+ for (var j = 2; j <= iterations; j++) {
14230
+ prf.reset();
14231
+ prf.update(u).finish(u);
14232
+ for (var k = 0; k < len; k++) {
14233
+ t[k] ^= u[k];
14234
+ }
14235
+ }
14236
+ for (var j = 0; j < len && i * len + j < dkLen; j++) {
14237
+ dk[i * len + j] = t[j];
14238
+ }
14239
+ }
14240
+ for (var i = 0; i < len; i++) {
14241
+ t[i] = u[i] = 0;
14242
+ }
14243
+ for (var i = 0; i < 4; i++) {
14244
+ ctr[i] = 0;
14245
+ }
14246
+ prf.clean();
14247
+ return dk;
14248
+ }
14249
+ exports2.pbkdf2 = pbkdf2;
14250
+ });
14251
+ }
14252
+ });
14253
+
14254
+ // src/webhook/vendor/standardwebhook.ts
14255
+ __toESM(require_base64());
14256
+ __toESM(require_sha256());
14257
+ /**
14258
+ * The MIT License
14259
+ *
14260
+ * Copyright (c) 2023 Svix (https://www.svix.com)
14261
+ *
14262
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14263
+ * of this software and associated documentation files (the "Software"), to deal
14264
+ * in the Software without restriction, including without limitation the rights
14265
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14266
+ * copies of the Software, and to permit persons to whom the Software is
14267
+ * furnished to do so, subject to the following conditions:
14268
+ *
14269
+ * The above copyright notice and this permission notice shall be included in
14270
+ * all copies or substantial portions of the Software.
14271
+ *
14272
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14273
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14274
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14275
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14276
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14277
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
14278
+ * THE SOFTWARE.
14279
+ *
14280
+ * @fileoverview Server-only webhook verification implementation.
14281
+ * @description Vendored from standardwebhooks package to avoid bundling issues.
14282
+ * Uses Node.js crypto module - DO NOT import in client/browser code.
14283
+ * @license MIT
14284
+ * @internal
14285
+ */
14286
+
14287
+ // src/webhook/webhook.ts
13311
14288
  async function handleWebhookPayload(payload, config, context) {
13312
14289
  const callHandler = (handler, payload2) => {
13313
14290
  if (!handler) return;
@@ -13379,6 +14356,9 @@ async function handleWebhookPayload(payload, config, context) {
13379
14356
  if (payload.type === "subscription.expired") {
13380
14357
  await callHandler(config.onSubscriptionExpired, payload);
13381
14358
  }
14359
+ if (payload.type === "subscription.updated") {
14360
+ await callHandler(config.onSubscriptionUpdated, payload);
14361
+ }
13382
14362
  if (payload.type === "license_key.created") {
13383
14363
  await callHandler(config.onLicenseKeyCreated, payload);
13384
14364
  }