@tdacorp/hyle-sdk 0.24.0 → 0.26.1

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.
Files changed (46) hide show
  1. package/README.md +7 -5
  2. package/dist/{embed-B7T--kTT.d.cts → brand-CwXvdSkk.d.ts} +14 -2
  3. package/dist/{embed-DavTgSU4.d.ts → brand-IuZSB9UX.d.cts} +14 -2
  4. package/dist/check-routes-bin.js +10 -5
  5. package/dist/{chunk-4REU4HJI.js → chunk-3UQGU62T.js} +22 -5
  6. package/dist/{chunk-SY2FMIRZ.js → chunk-IDBQSMWT.js} +1 -1
  7. package/dist/{chunk-5TKJH2XC.js → chunk-NUQQ6VHH.js} +267 -43
  8. package/dist/{chunk-Y3BACEWA.js → chunk-T4EZAQFU.js} +129 -3
  9. package/dist/chunk-VAR2B7S6.js +82 -0
  10. package/dist/{chunk-U74B7AUG.js → chunk-ZWKAEWEW.js} +22 -74
  11. package/dist/{client-BErei7cE.d.ts → client-B2zi_BGq.d.ts} +11 -4
  12. package/dist/{client-DrB2vcTi.d.cts → client-DBZTvcCh.d.cts} +11 -4
  13. package/dist/comments.cjs +25 -1
  14. package/dist/comments.js +4 -2
  15. package/dist/html.cjs +129 -3
  16. package/dist/html.js +1 -1
  17. package/dist/index.cjs +22 -5
  18. package/dist/index.d.cts +4 -4
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +1 -1
  21. package/dist/next.cjs +674 -211
  22. package/dist/next.d.cts +44 -18
  23. package/dist/next.d.ts +44 -18
  24. package/dist/next.js +241 -135
  25. package/dist/react.cjs +401 -46
  26. package/dist/react.d.cts +114 -4
  27. package/dist/react.d.ts +114 -4
  28. package/dist/react.js +14 -4
  29. package/dist/reactions.cjs +25 -1
  30. package/dist/reactions.js +4 -2
  31. package/dist/{resolve-03IVloXU.d.cts → resolve-0nGnsIHo.d.cts} +1 -1
  32. package/dist/{resolve-BseM68oy.d.ts → resolve-CguSaZLa.d.ts} +1 -1
  33. package/dist/{revalidation-callback-BQl77tQR.d.cts → revalidation-callback-FT9ik1dh.d.cts} +11 -0
  34. package/dist/{revalidation-callback-BQl77tQR.d.ts → revalidation-callback-FT9ik1dh.d.ts} +11 -0
  35. package/dist/share-client.cjs +498 -0
  36. package/dist/share-client.d.cts +99 -0
  37. package/dist/share-client.d.ts +99 -0
  38. package/dist/share-client.js +390 -0
  39. package/dist/styles.css +176 -1
  40. package/dist/{types-Dx-fEiZd.d.cts → types-CdaIzSjg.d.cts} +10 -3
  41. package/dist/{types-Dx-fEiZd.d.ts → types-CdaIzSjg.d.ts} +10 -3
  42. package/dist/use-cache.cjs +10 -5
  43. package/dist/use-cache.d.cts +3 -3
  44. package/dist/use-cache.d.ts +3 -3
  45. package/dist/use-cache.js +2 -2
  46. package/package.json +1 -1
package/dist/next.cjs CHANGED
@@ -149,17 +149,19 @@ function withAssetQuery(article, query) {
149
149
 
150
150
  // src/client.ts
151
151
  var RENDERER_VERSION = "4";
152
- function applyCredential(headers, credential, method, url) {
152
+ function applyCredential(headers2, credential, method, url) {
153
153
  if (!credential.auth) {
154
- headers.set("authorization", `Bearer ${credential.token}`);
154
+ headers2.set("authorization", `Bearer ${credential.token}`);
155
155
  return void 0;
156
156
  }
157
157
  const { workspaceId } = credential;
158
158
  return credential.auth({ method, url }).then((extra) => {
159
- for (const [name, value] of Object.entries(extra)) headers.set(name, value);
160
- headers.set("cp-workspace", workspaceId);
159
+ for (const [name, value] of Object.entries(extra)) headers2.set(name, value);
160
+ headers2.set("cp-workspace", workspaceId);
161
161
  });
162
162
  }
163
+ var IP_LITERAL = /^[0-9a-fA-F:.]{2,45}$/;
164
+ var visitorHeaders = ({ clientIp }) => clientIp !== void 0 && IP_LITERAL.test(clientIp) ? { "x-forwarded-for": clientIp } : {};
163
165
  var DEFAULT_TIMEOUT_MS = 1e4;
164
166
  var DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
165
167
  var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
@@ -218,13 +220,13 @@ function createHyleClient(options) {
218
220
  async function get(pathname, query, init) {
219
221
  const url = new URL(`${base}${pathname}`);
220
222
  url.search = query.toString();
221
- const headers = new Headers(init?.headers);
222
- headers.set("cp-renderer-version", RENDERER_VERSION);
223
- const applied = applyCredential(headers, options, "GET", url.toString());
223
+ const headers2 = new Headers(init?.headers);
224
+ headers2.set("cp-renderer-version", RENDERER_VERSION);
225
+ const applied = applyCredential(headers2, options, "GET", url.toString());
224
226
  if (applied) await applied;
225
227
  const timeout = AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
226
228
  const signal = init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout;
227
- const res = await fetchImpl(url.toString(), { ...init, method: "GET", headers, redirect: "error", signal });
229
+ const res = await fetchImpl(url.toString(), { ...init, method: "GET", headers: headers2, redirect: "error", signal });
228
230
  const text = await readCapped(res, options.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES);
229
231
  let parsed;
230
232
  try {
@@ -232,7 +234,7 @@ function createHyleClient(options) {
232
234
  } catch {
233
235
  parsed = void 0;
234
236
  }
235
- return { parsed, status: res.status };
237
+ return { parsed, status: res.status, retryAfter: res.headers.get("retry-after") };
236
238
  }
237
239
  const failure = ({ parsed, status }) => {
238
240
  const err = parsed?.error;
@@ -280,19 +282,22 @@ function createHyleClient(options) {
280
282
  if (data?.cp !== 1 || data.kind !== "preview" || typeof data.expires_at !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply2);
281
283
  return { kind: "preview", expires_at: data.expires_at, article: withAssetQuery(article, `${PREVIEW_PARAM}=${token}`) };
282
284
  }
283
- async function protectedGate(slug) {
285
+ const limited = ({ retryAfter }) => ({ kind: "limited", retryAfterSeconds: Math.min(3600, Math.max(1, Math.trunc(Number(retryAfter)) || 60)) });
286
+ async function protectedGate(slug, opts = {}) {
284
287
  if (!PROTECTED_SLUG.test(slug)) return { kind: "notfound" };
285
- const reply2 = await get("/cp1/read/_protected/gate", new URLSearchParams({ path: slug }), { cache: "no-store" });
288
+ const reply2 = await get("/cp1/read/_protected/gate", new URLSearchParams({ path: slug }), { headers: visitorHeaders(opts), cache: "no-store" });
289
+ if (reply2.status === 429) return limited(reply2);
286
290
  if (reply2.status === 404 && reply2.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
287
291
  const data = reply2.parsed?.data;
288
292
  if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
289
293
  if (data?.cp === 1 && data.kind === "gate") return { kind: "gate" };
290
294
  throw failure(reply2);
291
295
  }
292
- async function protectedShare(slug, password, docSlug) {
296
+ async function protectedShare(slug, password, docSlug, opts = {}) {
293
297
  if (!PROTECTED_SLUG.test(slug) || docSlug !== void 0 && !PROTECTED_DOC_SLUG.test(docSlug) || !PROTECTED_PASSWORD.test(password)) return { kind: "notfound" };
294
298
  const path = docSlug === void 0 ? slug : `${slug}/${docSlug}`;
295
- const reply2 = await get("/cp1/read/_protected", new URLSearchParams({ path }), { headers: { [PROTECTED_HEADER]: password }, cache: "no-store" });
299
+ const reply2 = await get("/cp1/read/_protected", new URLSearchParams({ path }), { headers: { ...visitorHeaders(opts), [PROTECTED_HEADER]: password }, cache: "no-store" });
300
+ if (reply2.status === 429) return limited(reply2);
296
301
  if (reply2.status === 404 && reply2.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
297
302
  const data = reply2.parsed?.data;
298
303
  if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
@@ -309,24 +314,24 @@ function createHyleClient(options) {
309
314
  if (protectedAccess !== void 0 && !(PROTECTED_SLUG.test(protectedAccess.slug) && PROTECTED_PASSWORD.test(protectedAccess.password))) throw new TypeError("protectedAccess is not a share slug and password");
310
315
  const query = protectedAccess === void 0 ? "" : `?protected=${encodeURIComponent(protectedAccess.slug)}`;
311
316
  const url = `${base}/cp1/read/assets/${file}${query}`;
312
- const headers = new Headers();
313
- const applied = applyCredential(headers, options, "GET", url);
317
+ const headers2 = new Headers();
318
+ const applied = applyCredential(headers2, options, "GET", url);
314
319
  if (applied) await applied;
315
320
  for (const name of ["range", "if-range", "if-none-match"]) {
316
321
  const value = opts.headers?.[name];
317
- if (value) headers.set(name, value);
322
+ if (value) headers2.set(name, value);
318
323
  }
319
- if (previewToken !== void 0) headers.set(PREVIEW_HEADER, previewToken);
320
- if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER, protectedAccess.password);
324
+ if (previewToken !== void 0) headers2.set(PREVIEW_HEADER, previewToken);
325
+ if (protectedAccess !== void 0) headers2.set(PROTECTED_HEADER, protectedAccess.password);
321
326
  const uncached = previewToken !== void 0 || protectedAccess !== void 0;
322
- return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...uncached ? { cache: "no-store" } : {} });
327
+ return fetchImpl(url, { method: "GET", headers: headers2, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...uncached ? { cache: "no-store" } : {} });
323
328
  }
324
329
  async function theme(opts = {}) {
325
330
  const url = `${base}/cp1/read/theme.css`;
326
- const headers = new Headers();
327
- const applied = applyCredential(headers, options, "GET", url);
331
+ const headers2 = new Headers();
332
+ const applied = applyCredential(headers2, options, "GET", url);
328
333
  if (applied) await applied;
329
- return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
334
+ return fetchImpl(url, { method: "GET", headers: headers2, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
330
335
  }
331
336
  return { resolve, mounts, pushPosts, preview, protectedGate, protected: protectedShare, asset, theme };
332
337
  }
@@ -434,6 +439,10 @@ async function runHook(hook, event) {
434
439
  clearTimeout(timer);
435
440
  }
436
441
  }
442
+ function parseIndexUrls(value) {
443
+ if (!Array.isArray(value)) return [];
444
+ return value.flatMap((item) => isRecord(item) && isEventPath(item.path) && isText(item.locale) ? [{ path: item.path, locale: item.locale }] : []);
445
+ }
437
446
  function createRevalidationCallbackRoute(options) {
438
447
  const dedupe = new DeliveryDedupe(options.dedupeCapacity);
439
448
  return {
@@ -486,6 +495,14 @@ function createRevalidationCallbackRoute(options) {
486
495
  const hook = options.onCommentEvent;
487
496
  const event = hook && parseCommentEvent(body);
488
497
  if (hook && event) await runHook(hook, event);
498
+ const indexUrls = parseIndexUrls(body.index_urls);
499
+ if (options.onIndexUrls && indexUrls.length > 0) {
500
+ try {
501
+ options.onIndexUrls(indexUrls);
502
+ } catch {
503
+ console.error("hyle: onIndexUrls failed");
504
+ }
505
+ }
489
506
  return okResponse(purged);
490
507
  }
491
508
  };
@@ -647,7 +664,31 @@ var SHAPES = {
647
664
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "8", r: "6" }),
648
665
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3.8 12.2 8.4-8.4" })
649
666
  ] }),
650
- refresh: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 8a5 5 0 1 1-1.6-3.7M13 2.5v2.8h-2.8" })
667
+ refresh: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 8a5 5 0 1 1-1.6-3.7M13 2.5v2.8h-2.8" }),
668
+ lock: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
669
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "7", width: "10", height: "7", rx: "1.3" }),
670
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5.2 7V5a2.8 2.8 0 0 1 5.6 0v2" })
671
+ ] }),
672
+ search: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
673
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "7", cy: "7", r: "4.5" }),
674
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m10.5 10.5 3.5 3.5" })
675
+ ] }),
676
+ sun: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
677
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "8", r: "2.8" }),
678
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 1.5v1.8M8 12.7v1.8M1.5 8h1.8M12.7 8h1.8M3.4 3.4l1.3 1.3M11.3 11.3l1.3 1.3M3.4 12.6l1.3-1.3M11.3 4.7l1.3-1.3" })
679
+ ] }),
680
+ moon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 9.4A5.6 5.6 0 0 1 6.6 3a5.6 5.6 0 1 0 6.4 6.4z" }),
681
+ monitor: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
682
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "2", y: "3", width: "12", height: "8", rx: "1.3" }),
683
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 14h4M8 11v3" })
684
+ ] }),
685
+ sidebar: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
686
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "2", y: "3", width: "12", height: "10", rx: "1.3" }),
687
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6.5 3v10" })
688
+ ] }),
689
+ shield: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 1.5 2.5 3.6v4c0 3.2 2.3 5.4 5.5 6.9 3.2-1.5 5.5-3.7 5.5-6.9v-4z" }),
690
+ "arrow-left": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 8H3M7 4 3 8l4 4" }),
691
+ menu: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M2.5 4.5h11M2.5 8h11M2.5 11.5h11" })
651
692
  };
652
693
  function Icon({ name, className }) {
653
694
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: className ? `hyle-ic ${className}` : "hyle-ic", viewBox: "0 0 16 16", "aria-hidden": "true", children: SHAPES[name] });
@@ -1339,7 +1380,49 @@ var en = {
1339
1380
  unTitle: "This page is temporarily unavailable",
1340
1381
  unBody: "The content could not be loaded. Please try again in a moment.",
1341
1382
  viewer: VIEWER_LABELS_EN,
1342
- comments: COMMENT_LABELS_EN
1383
+ comments: COMMENT_LABELS_EN,
1384
+ share: {
1385
+ protectedTag: "Protected",
1386
+ lock: "Lock",
1387
+ lockTitle: "Lock this share and return to the password page",
1388
+ searchLabel: "Search this share",
1389
+ searchHint: "Finds words in the titles and descriptions of its documents. Nothing outside the share is searched.",
1390
+ searchNone: "No documents match",
1391
+ searchScope: "Search covers the titles and descriptions of this share's documents.",
1392
+ searchCount: "{n} results",
1393
+ searchOne: "1 result",
1394
+ open: "Open",
1395
+ close: "Close",
1396
+ documents: "Documents",
1397
+ documentCount: "{n} documents",
1398
+ documentPosition: "Document {i} of {n}",
1399
+ privateCopy: "Private copy. Never listed or indexed.",
1400
+ noExpiry: "No expiry",
1401
+ expires: "Expires {when}",
1402
+ expiresSoon: "Expires soon",
1403
+ expired: "Expired",
1404
+ endedNotice: "This share has ended. You can finish this page, but the next one will not open.",
1405
+ soonNotice: "This share expires within 24 hours.",
1406
+ gateTitle: "Password required",
1407
+ gateBody: "Enter the password you were given to open this page.",
1408
+ gateWrong: "Wrong or expired password.",
1409
+ gatePassword: "Password",
1410
+ gateOpen: "Open",
1411
+ locked: "Locked",
1412
+ attemptsTitle: "Too many attempts",
1413
+ attemptsBody: "Try again in {n} seconds.",
1414
+ attemptsOne: "Try again in {n} second.",
1415
+ unavailableTitle: "This page is not available",
1416
+ unavailableBody: "The address may be wrong, or the share may have ended. Ask the person who sent it.",
1417
+ theme: "Theme",
1418
+ themeLight: "Light",
1419
+ themeDark: "Dark",
1420
+ themeSystem: "System",
1421
+ showDocuments: "Show documents",
1422
+ hideDocuments: "Hide documents",
1423
+ closeDocuments: "Close documents",
1424
+ skip: "Skip to content"
1425
+ }
1343
1426
  };
1344
1427
  var fr = {
1345
1428
  toc: "Sur cette page",
@@ -1399,7 +1482,49 @@ var fr = {
1399
1482
  unTitle: "Cette page est momentan\xE9ment indisponible",
1400
1483
  unBody: "Le contenu n'a pas pu \xEAtre charg\xE9. R\xE9essayez dans un instant.",
1401
1484
  viewer: VIEWER_LABELS_FR,
1402
- comments: COMMENT_LABELS_FR
1485
+ comments: COMMENT_LABELS_FR,
1486
+ share: {
1487
+ protectedTag: "Prot\xE9g\xE9",
1488
+ lock: "Verrouiller",
1489
+ lockTitle: "Verrouiller ce partage et revenir \xE0 la page du mot de passe",
1490
+ searchLabel: "Rechercher dans ce partage",
1491
+ searchHint: "Recherche des mots dans les titres et descriptions de ses documents. Rien hors du partage n'est recherch\xE9.",
1492
+ searchNone: "Aucun document ne correspond",
1493
+ searchScope: "La recherche porte sur les titres et descriptions des documents de ce partage.",
1494
+ searchCount: "{n} r\xE9sultats",
1495
+ searchOne: "1 r\xE9sultat",
1496
+ open: "Ouvrir",
1497
+ close: "Fermer",
1498
+ documents: "Documents",
1499
+ documentCount: "{n} documents",
1500
+ documentPosition: "Document {i} sur {n}",
1501
+ privateCopy: "Copie priv\xE9e. Jamais list\xE9e ni index\xE9e.",
1502
+ noExpiry: "Sans expiration",
1503
+ expires: "Expire le {when}",
1504
+ expiresSoon: "Expire bient\xF4t",
1505
+ expired: "Expir\xE9",
1506
+ endedNotice: "Ce partage a pris fin. Vous pouvez terminer cette page, mais la suivante ne s'ouvrira pas.",
1507
+ soonNotice: "Ce partage expire dans les 24 heures.",
1508
+ gateTitle: "Mot de passe requis",
1509
+ gateBody: "Saisissez le mot de passe qui vous a \xE9t\xE9 donn\xE9 pour ouvrir cette page.",
1510
+ gateWrong: "Mot de passe incorrect ou expir\xE9.",
1511
+ gatePassword: "Mot de passe",
1512
+ gateOpen: "Ouvrir",
1513
+ locked: "Verrouill\xE9",
1514
+ attemptsTitle: "Trop de tentatives",
1515
+ attemptsBody: "R\xE9essayez dans {n} secondes.",
1516
+ attemptsOne: "R\xE9essayez dans {n} seconde.",
1517
+ unavailableTitle: "Cette page n'est pas disponible",
1518
+ unavailableBody: "L'adresse est peut-\xEAtre erron\xE9e, ou le partage a pris fin. Demandez \xE0 la personne qui vous l'a envoy\xE9.",
1519
+ theme: "Th\xE8me",
1520
+ themeLight: "Clair",
1521
+ themeDark: "Sombre",
1522
+ themeSystem: "Syst\xE8me",
1523
+ showDocuments: "Afficher les documents",
1524
+ hideDocuments: "Masquer les documents",
1525
+ closeDocuments: "Fermer les documents",
1526
+ skip: "Aller au contenu"
1527
+ }
1403
1528
  };
1404
1529
  var es = {
1405
1530
  toc: "En esta p\xE1gina",
@@ -1459,7 +1584,49 @@ var es = {
1459
1584
  unTitle: "Esta p\xE1gina no est\xE1 disponible por el momento",
1460
1585
  unBody: "No se pudo cargar el contenido. Int\xE9ntalo de nuevo en un momento.",
1461
1586
  viewer: VIEWER_LABELS_ES,
1462
- comments: COMMENT_LABELS_ES
1587
+ comments: COMMENT_LABELS_ES,
1588
+ share: {
1589
+ protectedTag: "Protegido",
1590
+ lock: "Bloquear",
1591
+ lockTitle: "Bloquear este enlace compartido y volver a la p\xE1gina de contrase\xF1a",
1592
+ searchLabel: "Buscar en este enlace compartido",
1593
+ searchHint: "Busca palabras en los t\xEDtulos y descripciones de sus documentos. No se busca nada fuera del enlace compartido.",
1594
+ searchNone: "Ning\xFAn documento coincide",
1595
+ searchScope: "La b\xFAsqueda abarca los t\xEDtulos y descripciones de los documentos de este enlace compartido.",
1596
+ searchCount: "{n} resultados",
1597
+ searchOne: "1 resultado",
1598
+ open: "Abrir",
1599
+ close: "Cerrar",
1600
+ documents: "Documentos",
1601
+ documentCount: "{n} documentos",
1602
+ documentPosition: "Documento {i} de {n}",
1603
+ privateCopy: "Copia privada. Nunca se lista ni se indexa.",
1604
+ noExpiry: "Sin caducidad",
1605
+ expires: "Caduca el {when}",
1606
+ expiresSoon: "Caduca pronto",
1607
+ expired: "Caducado",
1608
+ endedNotice: "Este enlace compartido ha terminado. Puedes terminar esta p\xE1gina, pero la siguiente no se abrir\xE1.",
1609
+ soonNotice: "Este enlace compartido caduca en menos de 24 horas.",
1610
+ gateTitle: "Se requiere contrase\xF1a",
1611
+ gateBody: "Escribe la contrase\xF1a que te han dado para abrir esta p\xE1gina.",
1612
+ gateWrong: "Contrase\xF1a incorrecta o caducada.",
1613
+ gatePassword: "Contrase\xF1a",
1614
+ gateOpen: "Abrir",
1615
+ locked: "Bloqueado",
1616
+ attemptsTitle: "Demasiados intentos",
1617
+ attemptsBody: "Vuelve a intentarlo en {n} segundos.",
1618
+ attemptsOne: "Vuelve a intentarlo en {n} segundo.",
1619
+ unavailableTitle: "Esta p\xE1gina no est\xE1 disponible",
1620
+ unavailableBody: "La direcci\xF3n puede estar mal, o el enlace compartido ha terminado. Pregunta a quien te lo envi\xF3.",
1621
+ theme: "Tema",
1622
+ themeLight: "Claro",
1623
+ themeDark: "Oscuro",
1624
+ themeSystem: "Sistema",
1625
+ showDocuments: "Mostrar los documentos",
1626
+ hideDocuments: "Ocultar los documentos",
1627
+ closeDocuments: "Cerrar los documentos",
1628
+ skip: "Ir al contenido"
1629
+ }
1463
1630
  };
1464
1631
  var TABLE = { en, fr, es };
1465
1632
  function stringsFor(locale) {
@@ -2273,7 +2440,30 @@ var import_reactions = require("./reactions.cjs");
2273
2440
 
2274
2441
  // src/react/docs.tsx
2275
2442
  var import_docs_enhance = require("./docs-enhance.cjs");
2443
+
2444
+ // src/react/docs-main.tsx
2276
2445
  var import_jsx_runtime10 = require("react/jsx-runtime");
2446
+ function DocsMain({ article, c, components, narrowToc, prev, next, eyebrow }) {
2447
+ const { publication: pub } = article;
2448
+ const { s } = c;
2449
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
2450
+ eyebrow,
2451
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { className: "hyle-title", children: pub.title }),
2452
+ pub.description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
2453
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "hyle-updated", children: [
2454
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "calendar" }),
2455
+ s.updated,
2456
+ " ",
2457
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
2458
+ ] }),
2459
+ narrowToc,
2460
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Body, { article, components, locale: c.locale }),
2461
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Pager, { prev, next, c })
2462
+ ] });
2463
+ }
2464
+
2465
+ // src/react/docs.tsx
2466
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2277
2467
  var ROOT_ID = "hyle-docs";
2278
2468
  var NAV_ID = "hyle-docs-nav";
2279
2469
  function navTreeOf(article) {
@@ -2297,15 +2487,15 @@ function pathTo(nodes, path) {
2297
2487
  }
2298
2488
  function Branch({ nodes, current, onPath, c }) {
2299
2489
  const { Link } = c;
2300
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { children: nodes.map((node) => {
2301
- const link = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
2302
- if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { children: link }, node.canonical_path);
2303
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
2304
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("summary", { children: [
2305
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "chev" }),
2490
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ul", { children: nodes.map((node) => {
2491
+ const link = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
2492
+ if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: link }, node.canonical_path);
2493
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
2494
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("summary", { children: [
2495
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "chev" }),
2306
2496
  link
2307
2497
  ] }),
2308
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Branch, { nodes: node.children, current, onPath, c })
2498
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Branch, { nodes: node.children, current, onPath, c })
2309
2499
  ] }) }, node.canonical_path);
2310
2500
  }) });
2311
2501
  }
@@ -2319,52 +2509,224 @@ function DocsPage({ article, ...base }) {
2319
2509
  const siteName = article.breadcrumbs[0]?.title ?? "";
2320
2510
  const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
2321
2511
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
2322
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Shell, { theme: article.theme, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
2323
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
2324
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
2325
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "file" }),
2512
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Shell, { theme: article.theme, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
2513
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
2514
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
2515
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "file" }),
2326
2516
  s.menu,
2327
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "cur", children: pub.title }),
2328
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
2517
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "cur", children: pub.title }),
2518
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
2329
2519
  ] }),
2330
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
2331
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-side-head", children: [
2332
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("b", { children: siteName }),
2333
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
2334
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "x" }) })
2520
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
2521
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "hyle-side-head", children: [
2522
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("b", { children: siteName }),
2523
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
2524
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "x" }) })
2335
2525
  ] }),
2336
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
2337
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
2338
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
2526
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
2527
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
2528
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
2339
2529
  ] }),
2340
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
2341
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2342
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "alert" }),
2343
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
2344
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("b", { children: notTranslated }),
2530
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
2531
+ notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2532
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "alert" }),
2533
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
2534
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("b", { children: notTranslated }),
2345
2535
  " ",
2346
2536
  s.fallbackBody
2347
2537
  ] })
2348
2538
  ] }) : null,
2349
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
2350
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { className: "hyle-title", children: pub.title }),
2351
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
2352
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "hyle-updated", children: [
2353
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "calendar" }),
2354
- s.updated,
2355
- " ",
2356
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
2357
- ] }),
2358
- toc.narrow,
2359
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Body, { article, components: base.components, locale: c.locale }),
2360
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Pager, { prev: article.prev, next: article.next, c }),
2361
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
2362
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "hyle-docs-end", "aria-hidden": "true" })
2539
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
2540
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DocsMain, { article, c, components: base.components, narrowToc: toc.narrow, prev: article.prev, next: article.next }),
2541
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
2542
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "hyle-docs-end", "aria-hidden": "true" })
2363
2543
  ] }),
2364
2544
  toc.wide
2365
2545
  ] }) });
2366
2546
  }
2367
2547
 
2548
+ // src/react/share/chrome.tsx
2549
+ var import_share_client = require("./share-client.cjs");
2550
+
2551
+ // src/react/share/model.ts
2552
+ var THEME_COOKIE = "hyle_theme";
2553
+ var SIDE_COOKIE = "hyle_share_side";
2554
+ var SOON_MS = 24 * 60 * 60 * 1e3;
2555
+ function expiryState(expiresAt, now) {
2556
+ if (expiresAt === null) return "none";
2557
+ const end = Date.parse(expiresAt);
2558
+ if (Number.isNaN(end) || now >= end) return "expired";
2559
+ return end - now <= SOON_MS ? "soon" : "ok";
2560
+ }
2561
+ function shareDate(iso, locale) {
2562
+ const date = new Date(iso);
2563
+ const text = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }).format(date);
2564
+ return `${text} UTC`;
2565
+ }
2566
+ function themeFromCookie(value) {
2567
+ return value === "light" || value === "dark" ? value : "system";
2568
+ }
2569
+ function actFor(choice) {
2570
+ return choice === "system" ? void 0 : choice;
2571
+ }
2572
+
2573
+ // src/react/share/brand.tsx
2574
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2575
+ function brandFor(host, fill) {
2576
+ if (fill) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "hyle-brand", "data-slot": "chrome.brand", children: fill });
2577
+ if (!host) return null;
2578
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("a", { className: "hyle-brand", href: host.href ?? "/", children: [
2579
+ host.logo,
2580
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "nm", children: host.name })
2581
+ ] });
2582
+ }
2583
+
2584
+ // src/react/share/chrome.tsx
2585
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2586
+ function ShareChrome(props) {
2587
+ const { name, expiresAt, documents, article, docSlug, host, theme = "system", sidebarOpen = true, htmlTheme = false, hrefFor, lockAction, slug, now = Date.now(), ...base } = props;
2588
+ const { publication: pub } = article;
2589
+ const c = ctx(base, pub.locale);
2590
+ const s = c.s.share;
2591
+ const list = [...documents].sort((a, b) => a.position - b.position || (a.doc_slug < b.doc_slug ? -1 : 1));
2592
+ const index = list.findIndex((d) => d.doc_slug === docSlug);
2593
+ const single = list.length <= 1;
2594
+ const initial = expiryState(expiresAt, now);
2595
+ const labels = {
2596
+ protectedTag: s.protectedTag,
2597
+ noExpiry: s.noExpiry,
2598
+ expires: s.expires,
2599
+ expiresSoon: s.expiresSoon,
2600
+ expired: s.expired,
2601
+ soonNotice: s.soonNotice,
2602
+ endedNotice: s.endedNotice
2603
+ };
2604
+ const navItem = (d) => ({ slug: d.doc_slug, title: d.title, description: d.description ?? null, canonical_path: hrefFor(d.doc_slug) });
2605
+ const prev = index > 0 ? navItem(list[index - 1]) : null;
2606
+ const next = index >= 0 && index < list.length - 1 ? navItem(list[index + 1]) : null;
2607
+ const searchDocs = list.map((d) => ({ slug: d.doc_slug, title: d.title, description: d.description ?? null, href: hrefFor(d.doc_slug) }));
2608
+ const when = expiresAt === null ? s.noExpiry : s.expires.replace("{when}", shareDate(expiresAt, c.locale));
2609
+ const toc = Toc({ toc: article.toc, c });
2610
+ const side = single ? "none" : sidebarOpen ? "open" : "closed";
2611
+ const eyebrow = single || index < 0 ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "hyle-eyebrow", children: s.documentPosition.replace("{i}", String(index + 1)).replace("{n}", String(list.length)) });
2612
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
2613
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(HyleTheme, { theme: article.theme }),
2614
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_share_client.ShareFrame, { sidebarOpen, single, act: actFor(theme), lang: c.locale, children: [
2615
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", { className: "hyle-skip", href: "#hyle-main", children: s.skip }),
2616
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("header", { className: "hyle-bar", children: [
2617
+ single ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_share_client.ShareMenuButton, { label: s.showDocuments }),
2618
+ single ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_share_client.ShareFoldButton, { show: s.showDocuments, hide: s.hideDocuments }),
2619
+ brandFor(host, base.slots?.["chrome.brand"]),
2620
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "hyle-bar-title", children: [
2621
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "share", children: name }),
2622
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sep", "aria-hidden": "true", children: "/" }),
2623
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "doc", children: pub.title })
2624
+ ] }),
2625
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sp" }),
2626
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_share_client.ShareSearch, { docs: searchDocs, labels: { label: s.searchLabel, hint: s.searchHint, none: s.searchNone, scope: s.searchScope, count: s.searchCount, one: s.searchOne, close: s.close } }),
2627
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_share_client.ShareThemeMenu, { choice: theme, htmlTheme, labels: { label: s.theme, light: s.themeLight, dark: s.themeDark, system: s.themeSystem } }),
2628
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_share_client.ShareExpiryChip, { expiresAt, initial, locale: c.locale, labels }),
2629
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("form", { className: "hyle-lock-form", method: "post", action: lockAction, children: [
2630
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "hidden", name: "slug", value: slug }),
2631
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { type: "hidden", name: "lock", value: "1" }),
2632
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { className: "hyle-lock", type: "submit", "aria-label": s.lock, title: s.lockTitle, children: [
2633
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "lock" }),
2634
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: s.lock })
2635
+ ] })
2636
+ ] })
2637
+ ] }),
2638
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_share_client.ShareExpiryNotice, { expiresAt, initial, labels }),
2639
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "hyle-statusrow", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_share_client.ShareExpiryChip, { expiresAt, initial, locale: c.locale, labels }) }),
2640
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "hyle-share-body", "data-side": side, children: [
2641
+ single ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("aside", { className: "hyle-side", id: "hyle-side", popover: "auto", "aria-label": s.documents, children: [
2642
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "hyle-side-head", children: [
2643
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { children: [
2644
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "nm", children: name }),
2645
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "n", children: s.documentCount.replace("{n}", String(list.length)) })
2646
+ ] }),
2647
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_share_client.ShareDrawerClose, { label: s.closeDocuments })
2648
+ ] }),
2649
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("nav", { className: "hyle-side-list", "aria-label": s.documents, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ol", { children: list.map((d) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(c.Link, { href: hrefFor(d.doc_slug), title: d.title, ...d.doc_slug === docSlug ? { "aria-current": "page" } : {}, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: d.title }) }) }, d.doc_slug)) }) }),
2650
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "hyle-side-foot", children: [
2651
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
2652
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "clock" }),
2653
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: when })
2654
+ ] }),
2655
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
2656
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "lock" }),
2657
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: s.privateCopy })
2658
+ ] }),
2659
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Slot, { name: "chrome.sidebar-footer", slots: base.slots })
2660
+ ] })
2661
+ ] }) }),
2662
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("main", { className: "hyle-share-main", id: "hyle-main", tabIndex: -1, children: [
2663
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("article", { className: "hyle-doc", "data-hyle-page": "docs", lang: pub.locale, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocsMain, { article, c, components: base.components, narrowToc: toc.narrow, prev, next, eyebrow }) }),
2664
+ toc.wide
2665
+ ] })
2666
+ ] })
2667
+ ] })
2668
+ ] });
2669
+ }
2670
+
2671
+ // src/react/share/gate.tsx
2672
+ var import_share_client2 = require("./share-client.cjs");
2673
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2674
+ var PASSWORD_FIELD = "hyle-share-password";
2675
+ var ERROR_ID = "hyle-share-error";
2676
+ function ShareGate({ state, slug, unlockAction, docSlug, retryAfterSeconds = 0, host, theme = "system", htmlTheme = false, ...base }) {
2677
+ const c = ctx(base, "en");
2678
+ const s = c.s.share;
2679
+ const act = actFor(theme);
2680
+ const wrong = state === "wrong";
2681
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "hyle hyle-share", lang: c.locale, "data-hyle-chrome": "gate", ...act ? { "data-act": act } : {}, children: [
2682
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("a", { className: "hyle-skip", href: "#hyle-main", children: s.skip }),
2683
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("header", { className: "hyle-bar", children: [
2684
+ brandFor(host, base.slots?.["chrome.brand"]),
2685
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "sp" }),
2686
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_share_client2.ShareThemeMenu, { choice: theme, htmlTheme, labels: { label: s.theme, light: s.themeLight, dark: s.themeDark, system: s.themeSystem } })
2687
+ ] }),
2688
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("main", { className: "hyle-gate", id: "hyle-main", tabIndex: -1, children: state === "attempts" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: "hyle-card", "data-kind": "warn", children: [
2689
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "glyph", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "clock" }) }),
2690
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h1", { children: s.attemptsTitle }),
2691
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { role: "alert", children: (retryAfterSeconds === 1 ? s.attemptsOne : s.attemptsBody).replace("{n}", String(retryAfterSeconds)) })
2692
+ ] }) : state === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: "hyle-card", children: [
2693
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "glyph", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "x-circle" }) }),
2694
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h1", { children: s.unavailableTitle }),
2695
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children: s.unavailableBody })
2696
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: "hyle-card", children: [
2697
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "glyph", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "lock" }) }),
2698
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h1", { children: s.gateTitle }),
2699
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children: s.gateBody }),
2700
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { method: "post", action: unlockAction, autoComplete: "off", children: [
2701
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "hidden", name: "slug", value: slug }),
2702
+ docSlug !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "hidden", name: "docSlug", value: docSlug }),
2703
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: PASSWORD_FIELD, children: s.gatePassword }),
2704
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2705
+ "input",
2706
+ {
2707
+ id: PASSWORD_FIELD,
2708
+ name: "password",
2709
+ type: "password",
2710
+ autoComplete: "off",
2711
+ spellCheck: false,
2712
+ required: true,
2713
+ minLength: 12,
2714
+ maxLength: 128,
2715
+ "aria-invalid": wrong || void 0,
2716
+ "aria-describedby": wrong ? ERROR_ID : void 0
2717
+ }
2718
+ ),
2719
+ wrong ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "err", id: ERROR_ID, role: "alert", children: s.gateWrong }) : null,
2720
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { className: "hyle-btn primary", type: "submit", children: s.gateOpen })
2721
+ ] })
2722
+ ] }) }),
2723
+ state === "locked" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "hyle-toast", role: "status", children: [
2724
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "check-circle" }),
2725
+ s.locked
2726
+ ] }) : null
2727
+ ] });
2728
+ }
2729
+
2368
2730
  // src/next/options.ts
2369
2731
  var import_navigation = require("next/navigation");
2370
2732
 
@@ -2717,9 +3079,9 @@ function createEngagementRoute(options) {
2717
3079
  try {
2718
3080
  const early = await options.onRequest(req, { action: route.action(req.method) });
2719
3081
  if (early instanceof Response) {
2720
- const headers = new Headers(early.headers);
2721
- headers.set("cache-control", "no-store");
2722
- return new Response(early.body, { status: early.status, headers });
3082
+ const headers2 = new Headers(early.headers);
3083
+ headers2.set("cache-control", "no-store");
3084
+ return new Response(early.body, { status: early.status, headers: headers2 });
2723
3085
  }
2724
3086
  } catch {
2725
3087
  return refuse(502, "UPSTREAM_ERROR");
@@ -2747,11 +3109,11 @@ function createEngagementRoute(options) {
2747
3109
  if (built.body) baseHeaders.set("content-type", "application/json");
2748
3110
  const target = `${config.base}/cp1/engage${built.upstream}${built.query ? `?${built.query}` : ""}`;
2749
3111
  const call = async (withAssertion = assertion) => {
2750
- const headers = new Headers(baseHeaders);
2751
- if (withAssertion) headers.set("hyle-reader-assertion", withAssertion);
3112
+ const headers2 = new Headers(baseHeaders);
3113
+ if (withAssertion) headers2.set("hyle-reader-assertion", withAssertion);
2752
3114
  const res = await fetchImpl(target, {
2753
3115
  method: req.method,
2754
- headers,
3116
+ headers: headers2,
2755
3117
  ...built.body ? { body: JSON.stringify(built.body) } : {},
2756
3118
  redirect: "error",
2757
3119
  signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS2)
@@ -2775,7 +3137,7 @@ ${built.query.toString()}`, () => listing(viewer, call)) : await call();
2775
3137
  }
2776
3138
 
2777
3139
  // src/next/embed.tsx
2778
- var import_jsx_runtime11 = require("react/jsx-runtime");
3140
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2779
3141
  async function resolveEmbed(options, run, cursor) {
2780
3142
  try {
2781
3143
  return { result: await run() };
@@ -2790,11 +3152,11 @@ async function HyleList({ options, limit = 5, locale, layout, title, headingLeve
2790
3152
  const route = routeContext(locale ? { ...options, locale } : options, {});
2791
3153
  const path = sitePathFrom(route.basePath, void 0);
2792
3154
  if (path === void 0) return null;
2793
- const after = validCursor(cursor);
2794
- const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale, limit, after), after);
3155
+ const after2 = validCursor(cursor);
3156
+ const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale, limit, after2), after2);
2795
3157
  if (failure !== void 0) return failure;
2796
3158
  const next = olderHref && result?.kind === "list" ? validCursor(result.next_cursor) : void 0;
2797
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleListView, { items: result?.kind === "list" ? result.items : [], theme: result?.kind === "list" ? result.theme : void 0, layout, title, headingLevel, moreHref, olderHref: next ? olderHref?.(next) : void 0, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
3159
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(HyleListView, { items: result?.kind === "list" ? result.items : [], theme: result?.kind === "list" ? result.theme : void 0, layout, title, headingLevel, moreHref, olderHref: next ? olderHref?.(next) : void 0, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2798
3160
  }
2799
3161
  async function HyleArticle({ options, path, locale, headingLevel }) {
2800
3162
  if (!isSitePath2(path)) return null;
@@ -2803,7 +3165,7 @@ async function HyleArticle({ options, path, locale, headingLevel }) {
2803
3165
  const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale));
2804
3166
  if (failure !== void 0) return failure;
2805
3167
  if (result?.kind !== "article") return null;
2806
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleArticleView, { article: result, headingLevel, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
3168
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(HyleArticleView, { article: result, headingLevel, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2807
3169
  }
2808
3170
  var MAX_LISTING_BYTES = 4 * 1024 * 1024;
2809
3171
  var COMMENTS_TIMEOUT_MS = 1e4;
@@ -2835,13 +3197,13 @@ async function HyleComments({ options, path, revalidate = 60, interactive }) {
2835
3197
  return null;
2836
3198
  }
2837
3199
  if (!listing) return null;
2838
- if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleCommentsView, { listing, locale });
3200
+ if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(HyleCommentsView, { listing, locale });
2839
3201
  const config = interactive === true ? {} : interactive;
2840
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_comments2.Comments, { path, endpoint: config.endpoint ?? "/api/hyle/engage", signInHref: config.signInHref, locale, labels: stringsFor(locale).comments, initial: listing, initialAt: fetchedAt }) });
3202
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_comments2.Comments, { path, endpoint: config.endpoint ?? "/api/hyle/engage", signInHref: config.signInHref, locale, labels: stringsFor(locale).comments, initial: listing, initialAt: fetchedAt }) });
2841
3203
  }
2842
3204
 
2843
3205
  // src/next/page.tsx
2844
- var import_jsx_runtime12 = require("react/jsx-runtime");
3206
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2845
3207
  function hylePage(options) {
2846
3208
  const resolve = resolverFor(options);
2847
3209
  async function relatedItems(article) {
@@ -2863,13 +3225,13 @@ function hylePage(options) {
2863
3225
  const image = articleImage(options, result);
2864
3226
  const related = options.related && options.layout !== "docs" ? await relatedItems(result) : void 0;
2865
3227
  const props = { article: result, components: options.components, slots: options.slots, locale, toHref };
2866
- return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ArticlePage, { ...props, origin: options.siteOrigin, jsonLd: options.jsonLd, imageUrl: image?.url, imageWidth: image?.width, imageHeight: image?.height, related, ...options.engagement ? { engagement: options.engagement } : {} });
3228
+ return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ArticlePage, { ...props, origin: options.siteOrigin, jsonLd: options.jsonLd, imageUrl: image?.url, imageWidth: image?.width, imageHeight: image?.height, related, ...options.engagement ? { engagement: options.engagement } : {} });
2867
3229
  }
2868
3230
  case "list": {
2869
3231
  const list = options.list?.title ? { ...result, section: { ...result.section, title: options.list.title } } : result;
2870
3232
  const next = options.paginate === "searchParams" ? validCursor(result.next_cursor) : void 0;
2871
3233
  const olderHref = next ? `${toHref(path)}?cursor=${next}` : void 0;
2872
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ListPage, { list, ...olderHref ? { olderHref } : {}, ...options.list?.description ? { description: options.list.description } : {}, components: options.components, slots: options.slots, locale, toHref, origin: options.siteOrigin, path, jsonLd: options.jsonLd, cursor });
3234
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ListPage, { list, ...olderHref ? { olderHref } : {}, ...options.list?.description ? { description: options.list.description } : {}, components: options.components, slots: options.slots, locale, toHref, origin: options.siteOrigin, path, jsonLd: options.jsonLd, cursor });
2873
3235
  }
2874
3236
  case "redirect": {
2875
3237
  const to = safeRedirectTarget(result.to);
@@ -3073,7 +3435,7 @@ function hyleMetadata(options) {
3073
3435
  var import_navigation4 = require("next/navigation");
3074
3436
  var xml = (value) => value.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
3075
3437
  var tag = (name, value) => `<${name}>${xml(value)}</${name}>`;
3076
- var response = (body, status, headers) => new Response(body, { status, ...headers ? { headers } : {} });
3438
+ var response = (body, status, headers2) => new Response(body, { status, ...headers2 ? { headers: headers2 } : {} });
3077
3439
  async function hyleFeed(options) {
3078
3440
  const origin = options.siteOrigin;
3079
3441
  if (!origin || !BARE_HTTPS_ORIGIN.test(origin)) {
@@ -3112,10 +3474,62 @@ async function hyleFeed(options) {
3112
3474
  }
3113
3475
 
3114
3476
  // src/next/revalidate.ts
3477
+ var import_server = require("next/server");
3115
3478
  var import_cache = require("next/cache");
3479
+
3480
+ // src/indexnow.ts
3481
+ var INDEXNOW_ENDPOINT = "https://api.indexnow.org/indexnow";
3482
+ var ATTEMPTS = 3;
3483
+ var TIMEOUT_MS = 3e3;
3484
+ var RETRY_DELAY_MS = 500;
3485
+ async function submitIndexNow(site, urls) {
3486
+ try {
3487
+ const base = new URL(site.origin);
3488
+ const prefix = site.localePrefix ?? (() => "");
3489
+ const urlList = urls.map((url) => new URL(encodeURI((url.locale ? prefix(url.locale) : "") + url.path.normalize("NFC")), base)).filter((url) => url.origin === base.origin).map((url) => url.href);
3490
+ if (urlList.length === 0) return;
3491
+ const body = JSON.stringify({ host: base.host, key: site.key, urlList });
3492
+ let status;
3493
+ for (let attempt = 1; attempt <= ATTEMPTS; attempt++) {
3494
+ status = await postOnce(body);
3495
+ if (status !== void 0 && status < 500) break;
3496
+ if (attempt < ATTEMPTS) await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
3497
+ }
3498
+ console.log(`hyle: IndexNow ${status ?? "no answer"} for ${urlList.length} url(s) on ${base.host}`);
3499
+ } catch (error) {
3500
+ console.error("hyle: IndexNow not submitted", error instanceof Error ? error.name : "unknown");
3501
+ }
3502
+ }
3503
+ async function postOnce(body) {
3504
+ try {
3505
+ const res = await fetch(INDEXNOW_ENDPOINT, {
3506
+ method: "POST",
3507
+ headers: { "Content-Type": "application/json; charset=utf-8" },
3508
+ body,
3509
+ signal: AbortSignal.timeout(TIMEOUT_MS)
3510
+ });
3511
+ await res.body?.cancel().catch(() => void 0);
3512
+ return res.status;
3513
+ } catch {
3514
+ return void 0;
3515
+ }
3516
+ }
3517
+
3518
+ // src/next/revalidate.ts
3116
3519
  var isSwitchedOff2 = (value) => ["0", "false"].includes(value?.trim().toLowerCase() ?? "");
3520
+ function indexNowSite(option) {
3521
+ const key = option?.key?.trim();
3522
+ if (!option || !key) return void 0;
3523
+ try {
3524
+ return { origin: httpsOrigin(option.origin), key, localePrefix: option.localePrefix };
3525
+ } catch {
3526
+ console.error("hyle: IndexNow disabled, origin is not a bare https origin");
3527
+ return void 0;
3528
+ }
3529
+ }
3117
3530
  function createRevalidateRoute(options) {
3118
3531
  let cached;
3532
+ const indexNow = indexNowSite(options.indexNow);
3119
3533
  return {
3120
3534
  async POST(req) {
3121
3535
  if (isSwitchedOff2((options.env ?? process.env).HYLE_CONTENT_ENABLED)) return new Response(null, { status: 404 });
@@ -3125,7 +3539,19 @@ function createRevalidateRoute(options) {
3125
3539
  if (!workspaceId || secrets.length === 0) return new Response(null, { status: 503 });
3126
3540
  const key = `${workspaceId}\0${secrets.join("\0")}`;
3127
3541
  if (cached?.key !== key) {
3128
- cached = { key, route: createRevalidationCallbackRoute({ workspaceId, secrets, revalidateTag: (tag2) => (0, import_cache.revalidateTag)(tag2, { expire: 0 }), onCommentEvent: options.onCommentEvent }) };
3542
+ cached = {
3543
+ key,
3544
+ route: createRevalidationCallbackRoute({
3545
+ workspaceId,
3546
+ secrets,
3547
+ revalidateTag: (tag2) => (0, import_cache.revalidateTag)(tag2, { expire: 0 }),
3548
+ onCommentEvent: options.onCommentEvent,
3549
+ onIndexUrls: (urls) => {
3550
+ const env = options.env ?? process.env;
3551
+ if (indexNow && (env.VERCEL_ENV ?? env.NODE_ENV) === "production") (0, import_server.after)(() => submitIndexNow(indexNow, urls));
3552
+ }
3553
+ })
3554
+ };
3129
3555
  }
3130
3556
  return cached.route.POST(req);
3131
3557
  }
@@ -3133,7 +3559,7 @@ function createRevalidateRoute(options) {
3133
3559
  }
3134
3560
 
3135
3561
  // src/next/root.ts
3136
- var import_navigation7 = require("next/navigation");
3562
+ var import_navigation6 = require("next/navigation");
3137
3563
 
3138
3564
  // src/next/mount-match.ts
3139
3565
  function activeMounts(mounts) {
@@ -3161,123 +3587,106 @@ function isReserved(path, reserved) {
3161
3587
 
3162
3588
  // src/next/protected.tsx
3163
3589
  var import_headers = require("next/headers");
3164
- var import_navigation6 = require("next/navigation");
3165
-
3166
- // src/next/preview.tsx
3167
3590
  var import_navigation5 = require("next/navigation");
3168
- var import_jsx_runtime13 = require("react/jsx-runtime");
3169
- function drawArticle(article, options) {
3170
- const { locale } = article.publication;
3171
- const toHref = (sitePath, linkLocale = locale) => (options.localePrefix?.(linkLocale) ?? "") + sitePath;
3172
- const props = { article, components: options.components, slots: options.slots, locale, toHref };
3173
- return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ArticlePage, { ...props });
3174
- }
3175
- var hylePreviewMetadata = { robots: { index: false, follow: false }, referrer: "no-referrer" };
3176
- var BANNER = {
3177
- position: "sticky",
3178
- top: 0,
3179
- zIndex: 2147483647,
3180
- padding: "8px 16px",
3181
- background: "#fde047",
3182
- color: "#1a1a1a",
3183
- font: "600 14px/1.4 system-ui, sans-serif",
3184
- textAlign: "center"
3185
- };
3186
- function hylePreviewPage(options) {
3187
- return async function HylePreviewPage({ searchParams }) {
3188
- const { token } = await searchParams ?? {};
3189
- const result = await createHyleClient(options).preview(typeof token === "string" ? token : void 0);
3190
- if (result.kind !== "preview") (0, import_navigation5.notFound)();
3191
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
3192
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
3193
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("meta", { name: "referrer", content: "no-referrer" }),
3194
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { role: "status", style: BANNER, children: "Unpublished draft preview" }),
3195
- drawArticle(result.article, options)
3196
- ] });
3197
- };
3198
- }
3199
-
3200
- // src/next/protected.tsx
3201
- var import_jsx_runtime14 = require("react/jsx-runtime");
3591
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3202
3592
  var hyleProtectedMetadata = { robots: { index: false, follow: false }, referrer: "no-referrer" };
3203
3593
  var COOKIE_MAX_AGE_SECONDS = 12 * 60 * 60;
3204
3594
  var UNLOCK_MAX_BYTES = 1024;
3205
3595
  var PRIVATE_HEADERS = { "Cache-Control": "no-store", "Referrer-Policy": "no-referrer", "X-Robots-Tag": "noindex, nofollow" };
3206
3596
  var UNLOCK_PATH = "/hyle-protected/unlock";
3207
- var PASSWORD_FIELD = "hyle-protected-password";
3208
- var ERROR_ID = "hyle-protected-error";
3209
- function PasswordForm({ slug, failed }) {
3210
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("main", { children: [
3211
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h1", { children: "Password required" }),
3212
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { method: "post", action: UNLOCK_PATH, autoComplete: "off", children: [
3213
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "hidden", name: "slug", value: slug }),
3214
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: PASSWORD_FIELD, children: "Password" }),
3215
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3216
- "input",
3217
- {
3218
- id: PASSWORD_FIELD,
3219
- name: "password",
3220
- type: "password",
3221
- autoComplete: "off",
3222
- spellCheck: false,
3223
- required: true,
3224
- minLength: 12,
3225
- maxLength: 128,
3226
- "aria-invalid": failed || void 0,
3227
- "aria-describedby": failed ? ERROR_ID : void 0
3228
- }
3229
- ),
3230
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "submit", children: "Open" }),
3231
- failed ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { id: ERROR_ID, role: "alert", children: "Wrong or expired password." }) : null
3232
- ] })
3233
- ] });
3234
- }
3235
- async function drawProtectedShare(options, slug, docSlug) {
3597
+ var DOC_SLUG = /^[a-z0-9-]{1,200}$/;
3598
+ var PRIVATE_META = /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
3599
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
3600
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("meta", { name: "referrer", content: "no-referrer" })
3601
+ ] });
3602
+ function gate(state, slug, retryAfterSeconds, host) {
3603
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ShareGate, { state, slug, unlockAction: UNLOCK_PATH, retryAfterSeconds, host });
3604
+ }
3605
+ async function visitorPrefs() {
3606
+ const jar = await (0, import_headers.cookies)();
3607
+ return { theme: themeFromCookie(jar.get(THEME_COOKIE)?.value), sidebarOpen: jar.get(SIDE_COOKIE)?.value !== "closed" };
3608
+ }
3609
+ async function drawProtectedShare(options, slug, docSlug, clientIp, { locked = false } = {}) {
3236
3610
  const client = createHyleClient({ baseUrl: options.baseUrl, token: options.token });
3611
+ const visitor = { clientIp };
3237
3612
  const password = (await (0, import_headers.cookies)()).get(await protectedCookieName(slug))?.value;
3238
- const share = password === void 0 ? void 0 : await client.protected(slug, password, docSlug);
3239
- if (share?.kind === "disabled") (0, import_navigation6.notFound)();
3613
+ const share = password === void 0 ? void 0 : await client.protected(slug, password, docSlug, visitor);
3614
+ if (share?.kind === "limited") return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
3615
+ PRIVATE_META,
3616
+ gate("attempts", slug, share.retryAfterSeconds, options.host)
3617
+ ] });
3618
+ if (share?.kind === "disabled") (0, import_navigation5.notFound)();
3240
3619
  if (share?.kind === "protected") {
3241
- if (docSlug !== void 0 && share.doc_slug !== docSlug) (0, import_navigation6.notFound)();
3242
- const here = `/${slug}/${share.doc_slug}`;
3243
- const article = {
3244
- ...share.article,
3245
- publication: { ...share.article.publication, canonical_path: here },
3246
- nav: { truncated: false, items: share.documents.map((d) => ({ slug: d.doc_slug, title: d.title, canonical_path: `/${slug}/${d.doc_slug}`, children: [] })) }
3247
- };
3248
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
3249
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
3250
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "referrer", content: "no-referrer" }),
3251
- drawArticle(article, { ...options, layout: share.documents.length > 1 ? "docs" : "article" })
3620
+ if (docSlug !== void 0 && share.doc_slug !== docSlug) (0, import_navigation5.notFound)();
3621
+ const article = { ...share.article, publication: { ...share.article.publication, canonical_path: `/${slug}/${share.doc_slug}` } };
3622
+ const { theme: theme2, sidebarOpen } = await visitorPrefs();
3623
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
3624
+ PRIVATE_META,
3625
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3626
+ ShareChrome,
3627
+ {
3628
+ name: share.name,
3629
+ expiresAt: share.expires_at,
3630
+ documents: share.documents,
3631
+ article,
3632
+ docSlug: share.doc_slug,
3633
+ host: options.host,
3634
+ theme: theme2,
3635
+ sidebarOpen,
3636
+ slots: options.slots,
3637
+ components: options.components,
3638
+ hrefFor: (doc) => `/${slug}/${doc}`,
3639
+ lockAction: UNLOCK_PATH,
3640
+ slug
3641
+ }
3642
+ )
3252
3643
  ] });
3253
3644
  }
3254
- const gate = await client.protectedGate(slug);
3255
- if (gate.kind !== "gate") (0, import_navigation6.notFound)();
3256
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
3257
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
3258
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "referrer", content: "no-referrer" }),
3259
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PasswordForm, { slug, failed: password !== void 0 })
3645
+ const gateReply = await client.protectedGate(slug, visitor);
3646
+ if (gateReply.kind === "limited") return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
3647
+ PRIVATE_META,
3648
+ gate("attempts", slug, gateReply.retryAfterSeconds, options.host)
3649
+ ] });
3650
+ if (gateReply.kind !== "gate") (0, import_navigation5.notFound)();
3651
+ const { theme } = await visitorPrefs();
3652
+ const state = locked ? "locked" : password !== void 0 ? "wrong" : "password";
3653
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
3654
+ PRIVATE_META,
3655
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ShareGate, { state, slug, docSlug, unlockAction: UNLOCK_PATH, host: options.host, theme })
3260
3656
  ] });
3261
3657
  }
3658
+ async function readProtectedForm(req) {
3659
+ const site = req.headers.get("sec-fetch-site");
3660
+ if (site === null ? originMismatch(req) : site !== "same-origin") return new Response(null, { status: 403, headers: PRIVATE_HEADERS });
3661
+ if (!/^application\/x-www-form-urlencoded(\s*;|$)/i.test(req.headers.get("content-type") ?? "")) return new Response(null, { status: 415, headers: PRIVATE_HEADERS });
3662
+ if (Number(req.headers.get("content-length")) > UNLOCK_MAX_BYTES) return new Response(null, { status: 413, headers: PRIVATE_HEADERS });
3663
+ const form = await readCapped(new Response(req.body), UNLOCK_MAX_BYTES).catch(() => void 0);
3664
+ if (form === void 0) return new Response(null, { status: 413, headers: PRIVATE_HEADERS });
3665
+ return new URLSearchParams(form);
3666
+ }
3667
+ function sharePaths(slug) {
3668
+ return [`/${slug}`, ASSET_ROUTE_PREFIX];
3669
+ }
3262
3670
  function createProtectedUnlockRoute() {
3263
3671
  return {
3264
3672
  async POST(req) {
3265
- const site = req.headers.get("sec-fetch-site");
3266
- if (site === null ? originMismatch(req) : site !== "same-origin") return new Response(null, { status: 403, headers: PRIVATE_HEADERS });
3267
- if (!/^application\/x-www-form-urlencoded(\s*;|$)/i.test(req.headers.get("content-type") ?? "")) return new Response(null, { status: 415, headers: PRIVATE_HEADERS });
3268
- if (Number(req.headers.get("content-length")) > UNLOCK_MAX_BYTES) return new Response(null, { status: 413, headers: PRIVATE_HEADERS });
3269
- const form = await readCapped(new Response(req.body), UNLOCK_MAX_BYTES).catch(() => void 0);
3270
- if (form === void 0) return new Response(null, { status: 413, headers: PRIVATE_HEADERS });
3271
- const fields = new URLSearchParams(form);
3673
+ const fields = await readProtectedForm(req);
3674
+ if (fields instanceof Response) return fields;
3272
3675
  const slug = fields.get("slug") ?? "";
3273
3676
  if (!PROTECTED_SLUG.test(slug)) return new Response(null, { status: 404, headers: PRIVATE_HEADERS });
3677
+ const name = await protectedCookieName(slug);
3678
+ if (fields.get("lock") === "1") {
3679
+ const headers3 = new Headers({ ...PRIVATE_HEADERS, Location: `/${slug}?locked=1` });
3680
+ for (const path of sharePaths(slug)) headers3.append("Set-Cookie", `${name}=; Max-Age=0; Path=${path}; HttpOnly; Secure; SameSite=Lax`);
3681
+ return new Response(null, { status: 303, headers: headers3 });
3682
+ }
3683
+ const doc = fields.get("docSlug") ?? "";
3684
+ const headers2 = new Headers({ ...PRIVATE_HEADERS, Location: DOC_SLUG.test(doc) ? `/${slug}/${doc}` : `/${slug}` });
3274
3685
  const password = fields.get("password") ?? "";
3275
- const headers = new Headers({ ...PRIVATE_HEADERS, Location: `/${slug}` });
3276
3686
  if (PROTECTED_PASSWORD.test(password)) {
3277
- const name = await protectedCookieName(slug);
3278
- for (const path of [`/${slug}`, ASSET_ROUTE_PREFIX]) headers.append("Set-Cookie", `${name}=${password}; Max-Age=${COOKIE_MAX_AGE_SECONDS}; Path=${path}; HttpOnly; Secure; SameSite=Lax`);
3687
+ for (const path of sharePaths(slug)) headers2.append("Set-Cookie", `${name}=${password}; Max-Age=${COOKIE_MAX_AGE_SECONDS}; Path=${path}; HttpOnly; Secure; SameSite=Lax`);
3279
3688
  }
3280
- return new Response(null, { status: 303, headers });
3689
+ return new Response(null, { status: 303, headers: headers2 });
3281
3690
  }
3282
3691
  };
3283
3692
  }
@@ -3303,7 +3712,7 @@ function mountsLoader(config, ttlMs) {
3303
3712
  lastKnownGood.set(key, { loaded, at: Date.now() });
3304
3713
  return loaded;
3305
3714
  } catch (error) {
3306
- (0, import_navigation7.unstable_rethrow)(error);
3715
+ (0, import_navigation6.unstable_rethrow)(error);
3307
3716
  if (error instanceof Cp1ClientError && (error.status === 401 || error.status === 403)) {
3308
3717
  lastKnownGood.delete(key);
3309
3718
  throw error;
@@ -3314,10 +3723,24 @@ function mountsLoader(config, ttlMs) {
3314
3723
  }
3315
3724
  }
3316
3725
  if (ttlMs === void 0) return fetchLoaded;
3317
- let memo;
3726
+ let ready;
3727
+ let read;
3728
+ let until = 0;
3729
+ let pending = false;
3318
3730
  return function load() {
3319
- if (!memo || memo.until <= Date.now()) memo = { read: fetchLoaded(), until: Date.now() + ttlMs };
3320
- return memo.read;
3731
+ if (until <= Date.now() && !pending) {
3732
+ pending = true;
3733
+ until = Date.now() + ttlMs;
3734
+ read = fetchLoaded().then(
3735
+ (loaded) => ready = loaded,
3736
+ (error) => {
3737
+ ready = void 0;
3738
+ throw error;
3739
+ }
3740
+ );
3741
+ read.then(() => pending = false, () => pending = false);
3742
+ }
3743
+ return ready ? Promise.resolve(ready) : read;
3321
3744
  };
3322
3745
  }
3323
3746
  var asArray = (options) => Array.isArray(options) ? options : [options];
@@ -3396,10 +3819,10 @@ function createRouter(options, make, share) {
3396
3819
  };
3397
3820
  }
3398
3821
  function hyleRootPage(options) {
3399
- const route = createRouter(options, hylePage, (s) => () => drawProtectedShare(s.config, s.slug, s.docSlug));
3822
+ const route = createRouter(options, hylePage, () => async () => (0, import_navigation6.notFound)());
3400
3823
  return async function HyleRootPage({ params, searchParams }) {
3401
3824
  const hit = await route(await params ?? {});
3402
- if (!hit) (0, import_navigation7.notFound)();
3825
+ if (!hit) (0, import_navigation6.notFound)();
3403
3826
  return hit.handler({ params: Promise.resolve(hit.params), ...searchParams ? { searchParams } : {} });
3404
3827
  };
3405
3828
  }
@@ -3426,9 +3849,9 @@ function markdownRewritePath(pathname) {
3426
3849
  if (!pathname.startsWith("/") || !pathname.endsWith(".md") || pathname.endsWith("/.md") || pathname.startsWith("/api/")) return void 0;
3427
3850
  return MD_ROUTE_PREFIX + pathname.slice(0, -3);
3428
3851
  }
3429
- var reply = (body, status, headers = {}) => (
3852
+ var reply = (body, status, headers2 = {}) => (
3430
3853
  // noindex on every answer: the .md twin must never compete with the page it mirrors.
3431
- new Response(body, { status, headers: { "X-Robots-Tag": "noindex", ...headers } })
3854
+ new Response(body, { status, headers: { "X-Robots-Tag": "noindex", ...headers2 } })
3432
3855
  );
3433
3856
  function createMarkdownRoute(options) {
3434
3857
  const mounts = rootMounts(options);
@@ -3464,7 +3887,7 @@ function createMarkdownRoute(options) {
3464
3887
  }
3465
3888
 
3466
3889
  // src/next/llms.ts
3467
- var import_navigation8 = require("next/navigation");
3890
+ var import_navigation7 = require("next/navigation");
3468
3891
  var oneLine = (text) => text.replace(/\s+/g, " ").trim();
3469
3892
  var linkTarget = (url) => url.replace(/[()]/g, (c) => c === "(" ? "%28" : "%29");
3470
3893
  function createLlmsTxtRoute(options, llms) {
@@ -3489,7 +3912,7 @@ function createLlmsTxtRoute(options, llms) {
3489
3912
  return new Response(`${lines.join("\n")}
3490
3913
  `, { headers: { "Content-Type": "text/plain; charset=utf-8" } });
3491
3914
  } catch (error) {
3492
- (0, import_navigation8.unstable_rethrow)(error);
3915
+ (0, import_navigation7.unstable_rethrow)(error);
3493
3916
  console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
3494
3917
  return new Response(null, { status: 503 });
3495
3918
  }
@@ -3507,7 +3930,7 @@ var CACHE_CONTROL = "public, max-age=3600, s-maxage=86400, stale-while-revalidat
3507
3930
  var PARTIAL_CACHE_CONTROL = "no-store";
3508
3931
  var SAFE_HEADERS = { "X-Content-Type-Options": "nosniff", "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox" };
3509
3932
  var PRIVATE_HEADERS2 = { "Cache-Control": "no-store", "Referrer-Policy": "no-referrer", "X-Robots-Tag": "noindex, nofollow" };
3510
- var empty = (status, headers = {}) => new Response(null, { status, headers: { "Cache-Control": "no-store", ...headers } });
3933
+ var empty = (status, headers2 = {}) => new Response(null, { status, headers: { "Cache-Control": "no-store", ...headers2 } });
3511
3934
  var isSwitchedOff3 = (value) => ["0", "false"].includes(value?.trim().toLowerCase() ?? "");
3512
3935
  var THEME_CACHE_CONTROL = "public, max-age=31536000, immutable";
3513
3936
  var OUTDATED_THEME_CACHE_CONTROL = "public, max-age=60";
@@ -3528,8 +3951,8 @@ async function serveTheme(client, scope, hash, timeoutMs, head) {
3528
3951
  const current = await sha256Hex(css);
3529
3952
  if (current !== hash && upstream.headers.get(THEME_SCOPE_HEADER) !== scope) return empty(404);
3530
3953
  const cache = current === hash ? THEME_CACHE_CONTROL : OUTDATED_THEME_CACHE_CONTROL;
3531
- const headers = { "Content-Type": "text/css; charset=utf-8", "Cache-Control": cache, ETag: `"${current}"`, ...SAFE_HEADERS };
3532
- return new Response(head ? null : css, { status: 200, headers });
3954
+ const headers2 = { "Content-Type": "text/css; charset=utf-8", "Cache-Control": cache, ETag: `"${current}"`, ...SAFE_HEADERS };
3955
+ return new Response(head ? null : css, { status: 200, headers: headers2 });
3533
3956
  } catch {
3534
3957
  return empty(502);
3535
3958
  }
@@ -3613,22 +4036,22 @@ function createAssetRoute(options) {
3613
4036
  drop();
3614
4037
  return empty(502);
3615
4038
  }
3616
- const headers = new Headers({ "Content-Type": type, "Accept-Ranges": "bytes", "Cache-Control": upstream.status === 206 ? PARTIAL_CACHE_CONTROL : CACHE_CONTROL, Vary: "Range", ...SAFE_HEADERS });
3617
- if (etag) headers.set("ETag", etag);
4039
+ const headers2 = new Headers({ "Content-Type": type, "Accept-Ranges": "bytes", "Cache-Control": upstream.status === 206 ? PARTIAL_CACHE_CONTROL : CACHE_CONTROL, Vary: "Range", ...SAFE_HEADERS });
4040
+ if (etag) headers2.set("ETag", etag);
3618
4041
  const contentRange = upstream.headers.get("content-range");
3619
- if (upstream.status === 206 && contentRange) headers.set("Content-Range", contentRange);
3620
- if (!upstream.headers.get("content-encoding") && upstream.headers.get("content-length")) headers.set("Content-Length", String(length));
4042
+ if (upstream.status === 206 && contentRange) headers2.set("Content-Range", contentRange);
4043
+ if (!upstream.headers.get("content-encoding") && upstream.headers.get("content-length")) headers2.set("Content-Length", String(length));
3621
4044
  if (head) {
3622
4045
  drop();
3623
- return new Response(null, { status: upstream.status, headers });
4046
+ return new Response(null, { status: upstream.status, headers: headers2 });
3624
4047
  }
3625
- return new Response(capped(upstream.body, maxBytes), { status: upstream.status, headers });
4048
+ return new Response(capped(upstream.body, maxBytes), { status: upstream.status, headers: headers2 });
3626
4049
  }
3627
4050
  return { GET: (req, ctx2) => serve(req, ctx2, false), HEAD: (req, ctx2) => serve(req, ctx2, true) };
3628
4051
  }
3629
4052
 
3630
4053
  // src/next/og.tsx
3631
- var import_jsx_runtime15 = require("react/jsx-runtime");
4054
+ var import_jsx_runtime18 = require("react/jsx-runtime");
3632
4055
  var SIZE = { width: 1200, height: 630 };
3633
4056
  var MAX_TITLE = 140;
3634
4057
  function createOgImageRoute(options) {
@@ -3658,9 +4081,9 @@ function createOgImageRoute(options) {
3658
4081
  const chars = [...title];
3659
4082
  const shown = chars.length > MAX_TITLE ? `${chars.slice(0, MAX_TITLE - 1).join("")}\u2026` : title;
3660
4083
  return new import_og.ImageResponse(
3661
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
3662
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
3663
- options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { fontSize: 32, color: "#9ca3af" }, children: options.siteName }) : null
4084
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
4085
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
4086
+ options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { fontSize: 32, color: "#9ca3af" }, children: options.siteName }) : null
3664
4087
  ] }),
3665
4088
  // shortcut: @vercel/og fetches Google Fonts / emoji assets at render time for non-Latin titles and emoji (no switch to disable it), upgrade to a satori render with bundled fonts if a host needs zero egress.
3666
4089
  { ...SIZE, headers: { "cache-control": "public, max-age=3600, s-maxage=31536000, immutable" } }
@@ -3669,28 +4092,68 @@ function createOgImageRoute(options) {
3669
4092
  };
3670
4093
  }
3671
4094
 
4095
+ // src/next/preview.tsx
4096
+ var import_navigation8 = require("next/navigation");
4097
+ var import_jsx_runtime19 = require("react/jsx-runtime");
4098
+ function drawArticle(article, options) {
4099
+ const { locale } = article.publication;
4100
+ const toHref = (sitePath, linkLocale = locale) => (options.localePrefix?.(linkLocale) ?? "") + sitePath;
4101
+ const props = { article, components: options.components, slots: options.slots, locale, toHref };
4102
+ return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ArticlePage, { ...props });
4103
+ }
4104
+ var hylePreviewMetadata = { robots: { index: false, follow: false }, referrer: "no-referrer" };
4105
+ var BANNER = {
4106
+ position: "sticky",
4107
+ top: 0,
4108
+ zIndex: 2147483647,
4109
+ padding: "8px 16px",
4110
+ background: "#fde047",
4111
+ color: "#1a1a1a",
4112
+ font: "600 14px/1.4 system-ui, sans-serif",
4113
+ textAlign: "center"
4114
+ };
4115
+ function hylePreviewPage(options) {
4116
+ return async function HylePreviewPage({ searchParams }) {
4117
+ const { token } = await searchParams ?? {};
4118
+ const result = await createHyleClient(options).preview(typeof token === "string" ? token : void 0);
4119
+ if (result.kind !== "preview") (0, import_navigation8.notFound)();
4120
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
4121
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
4122
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("meta", { name: "referrer", content: "no-referrer" }),
4123
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "status", style: BANNER, children: "Unpublished draft preview" }),
4124
+ drawArticle(result.article, options)
4125
+ ] });
4126
+ };
4127
+ }
4128
+
3672
4129
  // src/next/protected-view.ts
4130
+ var import_headers2 = require("next/headers");
3673
4131
  var import_navigation9 = require("next/navigation");
3674
- var import_server = require("next/server");
4132
+ var import_server2 = require("next/server");
3675
4133
  var VIEW_PATH = "/hyle-protected/view";
3676
4134
  var MOUNTS_SNAPSHOT_MS = 3e4;
4135
+ var DEFAULT_LOOKUP_TIMEOUT_MS = 1500;
3677
4136
  var SHARE_PATH = /^\/[a-z0-9-]+(?:\/[a-z0-9-]+){0,4}$/;
3678
- function hyleProtectedProxy(options) {
4137
+ function hyleProtectedProxy(options, { lookupTimeoutMs = DEFAULT_LOOKUP_TIMEOUT_MS } = {}) {
3679
4138
  const mounts = rootMounts(options, MOUNTS_SNAPSHOT_MS);
3680
4139
  return async function protectedProxy(req) {
3681
4140
  const path = req.nextUrl.pathname;
3682
4141
  if (!SHARE_PATH.test(path)) return void 0;
3683
- const hit = await mounts.locate(path).catch(() => void 0);
3684
- return hit && "share" in hit ? import_server.NextResponse.rewrite(new URL(`${VIEW_PATH}${path}`, req.url)) : void 0;
4142
+ let timer;
4143
+ const deadline = new Promise((resolve) => timer = setTimeout(resolve, lookupTimeoutMs));
4144
+ const hit = await Promise.race([mounts.locate(path).catch(() => void 0), deadline]).finally(() => clearTimeout(timer));
4145
+ return hit && "share" in hit ? import_server2.NextResponse.rewrite(new URL(`${VIEW_PATH}${path}${req.nextUrl.search}`, req.url)) : void 0;
3685
4146
  };
3686
4147
  }
3687
- function hyleProtectedPage(options) {
4148
+ var forwardedClientIp = (h) => h.get("x-forwarded-for")?.split(",")[0]?.trim() || h.get("x-real-ip")?.trim() || void 0;
4149
+ function hyleProtectedPage(options, { clientIp = forwardedClientIp } = {}) {
3688
4150
  const mounts = rootMounts(options);
3689
- return async function HyleProtectedPage({ params }) {
4151
+ return async function HyleProtectedPage({ params, searchParams }) {
3690
4152
  const path = `/${((await params).path ?? []).join("/")}`;
3691
4153
  const hit = SHARE_PATH.test(path) ? await mounts.locate(path) : void 0;
3692
4154
  if (!hit || !("share" in hit)) (0, import_navigation9.notFound)();
3693
- return drawProtectedShare(hit.share.config, hit.share.slug, hit.share.docSlug);
4155
+ const locked = (await searchParams)?.locked === "1";
4156
+ return drawProtectedShare(hit.share.config, hit.share.slug, hit.share.docSlug, clientIp(await (0, import_headers2.headers)()), { locked });
3694
4157
  };
3695
4158
  }
3696
4159
  // Annotate the CommonJS export names for ESM import in node: