@astrasyncai/verification-gateway 5.10.0 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +4 -0
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +359 -30
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +359 -30
  7. package/dist/adapters/express.mjs.map +1 -1
  8. package/dist/adapters/mcp.d.mts +5 -1
  9. package/dist/adapters/mcp.d.ts +5 -1
  10. package/dist/adapters/mcp.js +168 -41
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +168 -41
  13. package/dist/adapters/mcp.mjs.map +1 -1
  14. package/dist/adapters/nextjs.d.mts +1 -1
  15. package/dist/adapters/nextjs.d.ts +1 -1
  16. package/dist/adapters/nextjs.js +352 -13
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +352 -13
  19. package/dist/adapters/nextjs.mjs.map +1 -1
  20. package/dist/adapters/sdk.d.mts +9 -1
  21. package/dist/adapters/sdk.d.ts +9 -1
  22. package/dist/adapters/sdk.js +100 -8
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +100 -8
  25. package/dist/adapters/sdk.mjs.map +1 -1
  26. package/dist/agent/index.js +1 -1
  27. package/dist/agent/index.js.map +1 -1
  28. package/dist/agent/index.mjs +1 -1
  29. package/dist/agent/index.mjs.map +1 -1
  30. package/dist/bin/astrasync-claude-hook.js +805 -16
  31. package/dist/bin/astrasync-codex-hook.js +805 -16
  32. package/dist/bin/astrasync-guard.js +894 -71
  33. package/dist/bin/astrasync.js +951 -74
  34. package/dist/browser/background.js +284 -7
  35. package/dist/browser/background.js.map +1 -1
  36. package/dist/browser/background.mjs +284 -7
  37. package/dist/browser/background.mjs.map +1 -1
  38. package/dist/cli/index.d.mts +8 -8
  39. package/dist/cli/index.d.ts +8 -8
  40. package/dist/cli/index.js +22 -64
  41. package/dist/cli/index.js.map +1 -1
  42. package/dist/cli/index.mjs +22 -64
  43. package/dist/cli/index.mjs.map +1 -1
  44. package/dist/codex/index.d.mts +5 -0
  45. package/dist/codex/index.d.ts +5 -0
  46. package/dist/codex/index.js +821 -24
  47. package/dist/codex/index.js.map +1 -1
  48. package/dist/codex/index.mjs +823 -26
  49. package/dist/codex/index.mjs.map +1 -1
  50. package/dist/cursor/extension.d.mts +9 -2
  51. package/dist/cursor/extension.d.ts +9 -2
  52. package/dist/cursor/extension.js +787 -11
  53. package/dist/cursor/extension.js.map +1 -1
  54. package/dist/cursor/extension.mjs +789 -11
  55. package/dist/cursor/extension.mjs.map +1 -1
  56. package/dist/edge-config.d.mts +1 -1
  57. package/dist/edge-config.d.ts +1 -1
  58. package/dist/edge-config.js +1 -1
  59. package/dist/edge-config.js.map +1 -1
  60. package/dist/edge-config.mjs +1 -1
  61. package/dist/edge-config.mjs.map +1 -1
  62. package/dist/edge-core/index.d.mts +128 -13
  63. package/dist/edge-core/index.d.ts +128 -13
  64. package/dist/edge-core/index.js +337 -55
  65. package/dist/edge-core/index.js.map +1 -1
  66. package/dist/edge-core/index.mjs +334 -55
  67. package/dist/edge-core/index.mjs.map +1 -1
  68. package/dist/enrolment-store-8DyaIOLe.d.mts +26 -0
  69. package/dist/enrolment-store-8DyaIOLe.d.ts +26 -0
  70. package/dist/gateway/gateway.js +284 -7
  71. package/dist/gateway/gateway.js.map +1 -1
  72. package/dist/gateway/gateway.mjs +284 -7
  73. package/dist/gateway/gateway.mjs.map +1 -1
  74. package/dist/git-trigger/git-hooks.d.mts +1 -1
  75. package/dist/git-trigger/git-hooks.d.ts +1 -1
  76. package/dist/index.d.mts +215 -5
  77. package/dist/index.d.ts +215 -5
  78. package/dist/index.js +3756 -80
  79. package/dist/index.js.map +1 -1
  80. package/dist/index.mjs +3748 -80
  81. package/dist/index.mjs.map +1 -1
  82. package/dist/platform-signatures.js +4 -1
  83. package/dist/platform-signatures.js.map +1 -1
  84. package/dist/platform-signatures.mjs +4 -1
  85. package/dist/platform-signatures.mjs.map +1 -1
  86. package/dist/registration/index.js +1 -1
  87. package/dist/registration/index.js.map +1 -1
  88. package/dist/registration/index.mjs +1 -1
  89. package/dist/registration/index.mjs.map +1 -1
  90. package/dist/transport/index.js +1 -1
  91. package/dist/transport/index.js.map +1 -1
  92. package/dist/transport/index.mjs +1 -1
  93. package/dist/transport/index.mjs.map +1 -1
  94. package/dist/{types-CTmUpNpS.d.mts → types-BCkwBA84.d.mts} +12 -0
  95. package/dist/{types-CTmUpNpS.d.ts → types-BCkwBA84.d.ts} +12 -0
  96. package/dist/{types-CtFXmDzm.d.ts → types-C_b4QTyO.d.ts} +18 -0
  97. package/dist/{types-DQrn_kei.d.mts → types-DlshIIR-.d.mts} +18 -0
  98. package/dist/ui/index.d.mts +1 -1
  99. package/dist/ui/index.d.ts +1 -1
  100. package/dist/verify.d.mts +35 -4
  101. package/dist/verify.d.ts +35 -4
  102. package/dist/verify.js +130 -16
  103. package/dist/verify.js.map +1 -1
  104. package/dist/verify.mjs +129 -16
  105. package/dist/verify.mjs.map +1 -1
  106. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -19,7 +19,7 @@ function getTrustLevel(score) {
19
19
  }
20
20
 
21
21
  // src/version.ts
22
- var SDK_VERSION = "5.10.0";
22
+ var SDK_VERSION = "5.12.0";
23
23
 
24
24
  // src/http.ts
25
25
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -98,6 +98,59 @@ function getCachedWellKnownUrls(apiBaseUrl) {
98
98
  return cache.get(apiBaseUrl)?.data;
99
99
  }
100
100
 
101
+ // src/failure-posture.ts
102
+ var VERIFICATION_STATUS_HEADER = "X-Astra-Verification";
103
+ var DEFAULT_UNAVAILABLE_RETRY_AFTER_S = 30;
104
+ var REJECTED_IDENTITY_DIMENSIONS = /* @__PURE__ */ new Set([
105
+ "identity.invalid_agent_id",
106
+ "identity.unknown_agent",
107
+ "agent.lookup"
108
+ ]);
109
+ var UNKNOWN_AGENT_GUIDANCE = "Register your agent with AstraSync (or, inside an MCP host, add the AstraSync MCP connector for keyless, human-approved registration), then present the canonical ASTRA-* id issued after owner approval.";
110
+ var UNAVAILABLE_DIMENSIONS = /* @__PURE__ */ new Set([
111
+ "verify_access.api_error",
112
+ "middleware.internal_error"
113
+ ]);
114
+ function isVerificationUnavailable(result) {
115
+ if (result.misconfigured) return false;
116
+ return (result.failures ?? []).some((f) => UNAVAILABLE_DIMENSIONS.has(f.dimension));
117
+ }
118
+ function unavailableRetryAfterSeconds(result) {
119
+ if (typeof result.retryAfterMs === "number" && Number.isFinite(result.retryAfterMs)) {
120
+ return Math.max(1, Math.ceil(result.retryAfterMs / 1e3));
121
+ }
122
+ return DEFAULT_UNAVAILABLE_RETRY_AFTER_S;
123
+ }
124
+ function isAnonymousRead(method, credentials) {
125
+ const m = (method ?? "").toUpperCase();
126
+ if (m !== "GET" && m !== "HEAD") return false;
127
+ return !credentials.astraId && !credentials.jwt;
128
+ }
129
+ function buildVerificationUnavailableBody(result) {
130
+ return {
131
+ success: false,
132
+ error: {
133
+ code: "VERIFICATION_UNAVAILABLE",
134
+ message: "Agent verification is temporarily unavailable and this path enforces verification. Your identity was not evaluated and no denial was recorded \u2014 retry after the Retry-After interval.",
135
+ retryable: true,
136
+ retryAfterSeconds: unavailableRetryAfterSeconds(result),
137
+ ...result.failures && { failures: result.failures },
138
+ ...result.correlationId && { correlationId: result.correlationId },
139
+ guidance: {
140
+ message: "Retry the request after the Retry-After interval, with exponential backoff; the condition is transient."
141
+ }
142
+ }
143
+ };
144
+ }
145
+ function isRejectedIdentityClaim(result) {
146
+ return (result.failures ?? []).some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
147
+ }
148
+ function denyStatusFor(result, policyDeniedCode) {
149
+ if (isRejectedIdentityClaim(result)) return { status: 403, code: "AGENT_IDENTITY_REJECTED" };
150
+ if (result.identityVerified) return { status: 403, code: policyDeniedCode };
151
+ return { status: 401, code: "UNAUTHORIZED" };
152
+ }
153
+
101
154
  // src/verify.ts
102
155
  var DEFAULT_CONFIG = {
103
156
  apiBaseUrl: "https://astrasync.ai/api",
@@ -349,11 +402,44 @@ function createGuidanceResponse(_config, reason, options = {}) {
349
402
  // coercing the absent recommendation to a policy 'deny'. Misconfig is
350
403
  // deterministic and intentionally NOT marked retryable.
351
404
  ...isApiError && { retryable: true },
405
+ ...options.httpStatus !== void 0 && { httpStatus: options.httpStatus },
406
+ ...options.retryAfterMs !== void 0 && { retryAfterMs: options.retryAfterMs },
352
407
  correlationId: options.correlationId,
353
408
  attemptId: options.attemptId,
354
409
  verifiedAt: /* @__PURE__ */ new Date()
355
410
  };
356
411
  }
412
+ async function readJsonSafe(response) {
413
+ try {
414
+ const parsed = await response.json();
415
+ return parsed && typeof parsed === "object" ? parsed : {};
416
+ } catch {
417
+ return {};
418
+ }
419
+ }
420
+ function rejectedIdentityGuidance(failures) {
421
+ const f = failures?.find((x) => REJECTED_IDENTITY_DIMENSIONS.has(x.dimension));
422
+ if (!f) return void 0;
423
+ if (f.dimension === "agent.lookup") {
424
+ return `The presented agent identifier is not registered with AstraSync. ${UNKNOWN_AGENT_GUIDANCE}`;
425
+ }
426
+ return f.guidance ? `${f.message} ${f.guidance}` : f.message;
427
+ }
428
+ var MAX_RETRY_AFTER_MS = 15 * 60 * 1e3;
429
+ function parseRetryAfterMs(response) {
430
+ const raw = response.headers?.get?.("retry-after");
431
+ if (!raw) return void 0;
432
+ const trimmed = raw.trim();
433
+ let ms;
434
+ if (/^\d+(\.\d+)?$/.test(trimmed)) {
435
+ ms = Number(trimmed) * 1e3;
436
+ } else {
437
+ const at = Date.parse(trimmed);
438
+ if (Number.isNaN(at)) return void 0;
439
+ ms = at - Date.now();
440
+ }
441
+ return Math.min(MAX_RETRY_AFTER_MS, Math.max(0, Math.round(ms)));
442
+ }
357
443
  async function callVerifyAccessAPI(config, request) {
358
444
  const { credentials, ...requestData } = request;
359
445
  const body = {
@@ -410,7 +496,8 @@ async function callVerifyAccessAPI(config, request) {
410
496
  body: JSON.stringify(body),
411
497
  signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
412
498
  });
413
- const data = await response.json();
499
+ const data = await readJsonSafe(response);
500
+ const retryAfterMs = parseRetryAfterMs(response);
414
501
  if (response.status === 410) {
415
502
  return {
416
503
  success: true,
@@ -448,6 +535,23 @@ async function callVerifyAccessAPI(config, request) {
448
535
  }
449
536
  };
450
537
  }
538
+ if (response.status === 404 && credentials.astraId && (data?.error === "AGENT_NOT_FOUND" || typeof data?.message === "string" && /agent/i.test(data.message))) {
539
+ return {
540
+ success: true,
541
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
542
+ access: {
543
+ allowed: false,
544
+ reason: "unknown_agent",
545
+ failures: [
546
+ {
547
+ dimension: "identity.unknown_agent",
548
+ message: "The presented agent identifier is not registered with AstraSync.",
549
+ guidance: UNKNOWN_AGENT_GUIDANCE
550
+ }
551
+ ]
552
+ }
553
+ };
554
+ }
451
555
  if (!response.ok) {
452
556
  if (response.status === 401) {
453
557
  return {
@@ -462,9 +566,11 @@ async function callVerifyAccessAPI(config, request) {
462
566
  }
463
567
  return {
464
568
  success: false,
465
- error: data.message || data.error || `API returned ${response.status}`,
569
+ error: typeof data?.message === "string" && data.message || typeof data?.error === "string" && data.error || `API returned ${response.status}`,
466
570
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
467
- attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
571
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
572
+ httpStatus: response.status,
573
+ ...retryAfterMs !== void 0 && { retryAfterMs }
468
574
  };
469
575
  }
470
576
  return data;
@@ -536,12 +642,14 @@ async function verify(config, request, options) {
536
642
  correlationId: apiResponse.correlationId,
537
643
  attemptId: apiResponse.attemptId,
538
644
  remediation: apiResponse.remediation,
645
+ httpStatus: apiResponse.httpStatus,
646
+ retryAfterMs: apiResponse.retryAfterMs,
539
647
  urls
540
648
  });
541
649
  }
542
650
  if (!apiResponse.access?.allowed) {
543
651
  const aggregatedFailures = apiResponse.access?.failures;
544
- const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true;
652
+ const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
545
653
  const result2 = {
546
654
  identityVerified: idVerifiedFromBackend,
547
655
  policyAllowed: false,
@@ -553,7 +661,10 @@ async function verify(config, request, options) {
553
661
  requiresStepUp: apiResponse.access?.requiresStepUp,
554
662
  requiresApproval: apiResponse.access?.requiresApproval,
555
663
  guidance: {
556
- message: apiResponse.access?.reason || "Access denied by PDLSS policy",
664
+ // 5.12.0: a presented-but-rejected id (malformed / unknown) carries
665
+ // actionable registration guidance on its failure — surface it
666
+ // instead of the bare machine reason ('unknown_agent').
667
+ message: rejectedIdentityGuidance(aggregatedFailures) ?? (apiResponse.access?.reason || "Access denied by PDLSS policy"),
557
668
  registrationUrl: urls?.registrationUrl ?? "",
558
669
  documentationUrl: urls?.documentationUrl ?? "",
559
670
  // 5.1.0: anonymous callers land on this branch — steer MCP-hosted
@@ -653,7 +764,7 @@ async function verify(config, request, options) {
653
764
  registrationUrl: urls?.registrationUrl ?? "",
654
765
  documentationUrl: urls?.documentationUrl ?? ""
655
766
  };
656
- } else if (result.recommendation === "step_up_required") {
767
+ } else if (result.recommendation === "step_up_required" && result.identityVerified) {
657
768
  result.requiresStepUp = true;
658
769
  result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Step-up verification required"];
659
770
  }
@@ -676,7 +787,7 @@ async function recordDecision(config, sessionId, decision, reason) {
676
787
  }).catch(() => {
677
788
  });
678
789
  }
679
- async function reportAttempt(config, report) {
790
+ async function reportAttempt(config, report, options = {}) {
680
791
  const apiBaseUrl = config.apiBaseUrl || DEFAULT_CONFIG.apiBaseUrl;
681
792
  const headers = { "Content-Type": "application/json" };
682
793
  if (config.apiKey) {
@@ -687,13 +798,37 @@ async function reportAttempt(config, report) {
687
798
  ...report,
688
799
  ...!report.counterpartyId && config.counterpartyId && { counterpartyId: config.counterpartyId }
689
800
  };
690
- await sdkFetch(`${apiBaseUrl}/agents/verify-access/attempt-report`, {
691
- method: "POST",
692
- headers,
693
- body: JSON.stringify(body)
694
- }).catch(() => {
695
- });
801
+ const url = `${apiBaseUrl}/agents/verify-access/attempt-report`;
802
+ const init = { method: "POST", headers, body: JSON.stringify(body) };
803
+ const fail = (failure) => {
804
+ try {
805
+ options.onFailure?.(failure);
806
+ } catch {
807
+ }
808
+ };
809
+ let response;
810
+ try {
811
+ response = await sdkFetch(url, init);
812
+ } catch (err) {
813
+ fail({ error: err instanceof Error ? err.message : String(err), retried: false });
814
+ return;
815
+ }
816
+ if (response.ok) return;
817
+ if (response.status !== 429 && response.status < 500) {
818
+ fail({ status: response.status, retried: false });
819
+ return;
820
+ }
821
+ const delayMs = Math.min(ATTEMPT_REPORT_MAX_RETRY_DELAY_MS, parseRetryAfterMs(response) ?? 500);
822
+ const timer = setTimeout(() => {
823
+ sdkFetch(url, init).then((retry) => {
824
+ if (!retry.ok) fail({ status: retry.status, retried: true });
825
+ }).catch((err) => {
826
+ fail({ error: err instanceof Error ? err.message : String(err), retried: true });
827
+ });
828
+ }, delayMs);
829
+ timer.unref?.();
696
830
  }
831
+ var ATTEMPT_REPORT_MAX_RETRY_DELAY_MS = 2e3;
697
832
  async function fetchRoutes(config, counterpartyId) {
698
833
  if (!counterpartyId) return null;
699
834
  const headers = { "Content-Type": "application/json" };
@@ -723,7 +858,10 @@ async function reportUnregisteredAttempt(config, data) {
723
858
  };
724
859
  await sdkFetch(`${apiBaseUrl}/verification-activity/unregistered-attempt`, {
725
860
  method: "POST",
726
- headers: { "Content-Type": "application/json" },
861
+ headers: {
862
+ "Content-Type": "application/json",
863
+ ...config.apiKey && { Authorization: `Bearer ${config.apiKey}` }
864
+ },
727
865
  body: JSON.stringify(body)
728
866
  }).catch(() => {
729
867
  });
@@ -745,7 +883,11 @@ async function quickVerify(config, credentials) {
745
883
  return {
746
884
  identityVerified: result.identityVerified,
747
885
  policyAllowed: result.policyAllowed,
748
- reason: result.denialReasons?.[0]
886
+ reason: result.denialReasons?.[0],
887
+ ...isVerificationUnavailable(result) && {
888
+ unavailable: true,
889
+ retryAfterMs: unavailableRetryAfterSeconds(result) * 1e3
890
+ }
749
891
  };
750
892
  }
751
893
 
@@ -1493,7 +1635,10 @@ var PLATFORM_AGENT_SIGNATURES = [
1493
1635
  {
1494
1636
  vendor: "chatgpt",
1495
1637
  displayName: "OpenAI ChatGPT",
1496
- uaPatterns: [/chatgpt/i, /openai/i, /gpt-?\d/i],
1638
+ // GPTBot (training crawler) and OAI-SearchBot (ChatGPT search) are
1639
+ // OpenAI's declared crawler UAs — `gpt-?\d` never matched them, so they
1640
+ // classified as unattributed crawlers (round-27.4 W5).
1641
+ uaPatterns: [/chatgpt/i, /openai/i, /gpt-?\d/i, /\bGPTBot\b/i, /\bOAI-SearchBot\b/i],
1497
1642
  agentCardPatterns: [/openai\.com/i, /chatgpt\.com/i],
1498
1643
  apiKeyFormatPatterns: [/^sk-proj/i, /^sk-svcacct/i],
1499
1644
  headerPatterns: [/^openai-organization/i, /^openai-project/i, /^openai-version/i]
@@ -1628,6 +1773,215 @@ var BROWSER_UA_PATTERN = /mozilla\/\d/i;
1628
1773
  var _patterns = { STATIC_EXTENSIONS, BOT_UA_PATTERN, BROWSER_UA_PATTERN, SELF_UA_PATTERN };
1629
1774
 
1630
1775
  // src/edge-core/events.ts
1776
+ async function withBudget(promise, ms) {
1777
+ let timer;
1778
+ try {
1779
+ return await Promise.race([
1780
+ promise,
1781
+ new Promise((resolve) => {
1782
+ timer = setTimeout(() => resolve(void 0), ms);
1783
+ })
1784
+ ]);
1785
+ } catch {
1786
+ return void 0;
1787
+ } finally {
1788
+ if (timer) clearTimeout(timer);
1789
+ }
1790
+ }
1791
+ var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
1792
+ var BeaconBuffer = class {
1793
+ constructor(options = {}) {
1794
+ this.queue = [];
1795
+ this.droppedSinceLast = 0;
1796
+ this.droppedTotal = 0;
1797
+ this.deliveredTotal = 0;
1798
+ this.backoffUntil = 0;
1799
+ this.collapse = /* @__PURE__ */ new Map();
1800
+ /** Keys the backend answered 401 for — later batches go unauthenticated. */
1801
+ this.rejectedKeys = /* @__PURE__ */ new Set();
1802
+ this.opts = {
1803
+ maxItems: options.maxItems ?? 1e3,
1804
+ maxBatch: options.maxBatch ?? 100,
1805
+ maxAttempts: options.maxAttempts ?? 3,
1806
+ collapseWindowMs: options.collapseWindowMs ?? 6e4,
1807
+ collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
1808
+ requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
1809
+ retryBackoffMs: options.retryBackoffMs ?? 1e3,
1810
+ now: options.now ?? Date.now
1811
+ };
1812
+ }
1813
+ /**
1814
+ * Queue one beacon. With a `collapseKey`, a repeat inside the window is
1815
+ * merged into a held aggregate (sent when the window closes) instead of
1816
+ * becoming its own item.
1817
+ */
1818
+ enqueue(dest, item, collapseKey) {
1819
+ const now = this.opts.now();
1820
+ if (collapseKey) {
1821
+ const entry = this.collapse.get(collapseKey);
1822
+ if (entry && now - entry.firstSeenAt < this.opts.collapseWindowMs) {
1823
+ for (const target of [entry.first, entry.held]) {
1824
+ if (target && !target.inFlight && this.queue.includes(target)) {
1825
+ target.item.repeatCount = (target.item.repeatCount ?? 1) + 1;
1826
+ return;
1827
+ }
1828
+ }
1829
+ const held = this.push(
1830
+ dest,
1831
+ { ...item, repeatCount: 1 },
1832
+ entry.firstSeenAt + this.opts.collapseWindowMs
1833
+ );
1834
+ entry.held = held;
1835
+ return;
1836
+ }
1837
+ this.collapse.delete(collapseKey);
1838
+ if (this.collapse.size >= this.opts.collapseMaxKeys) {
1839
+ const oldest = this.collapse.keys().next().value;
1840
+ if (oldest !== void 0) this.collapse.delete(oldest);
1841
+ }
1842
+ const fresh = { firstSeenAt: now };
1843
+ this.collapse.set(collapseKey, fresh);
1844
+ fresh.first = this.push(dest, item, now);
1845
+ return;
1846
+ }
1847
+ this.push(dest, item, now);
1848
+ }
1849
+ /**
1850
+ * Deliver every eligible queued item. Concurrent callers share ONE
1851
+ * in-flight drain (it survives the caller's budget and a Lambda freeze),
1852
+ * so nothing in flight is ever sent twice; items queued while it runs are
1853
+ * picked up by the same drain.
1854
+ */
1855
+ flush() {
1856
+ if (!this.inFlight) {
1857
+ this.inFlight = this.drain().finally(() => {
1858
+ this.inFlight = void 0;
1859
+ });
1860
+ }
1861
+ return this.inFlight;
1862
+ }
1863
+ /** Counters for tests and diagnostics. */
1864
+ stats() {
1865
+ return {
1866
+ queueDepth: this.queue.length,
1867
+ droppedSinceLast: this.droppedSinceLast,
1868
+ droppedTotal: this.droppedTotal,
1869
+ deliveredTotal: this.deliveredTotal,
1870
+ flushing: this.inFlight !== void 0
1871
+ };
1872
+ }
1873
+ push(dest, item, eligibleAt) {
1874
+ while (this.queue.length >= this.opts.maxItems) this.dropOldest();
1875
+ const entry = {
1876
+ dest,
1877
+ destKey: destKeyOf(dest),
1878
+ item,
1879
+ attempts: 0,
1880
+ eligibleAt,
1881
+ inFlight: false
1882
+ };
1883
+ this.queue.push(entry);
1884
+ return entry;
1885
+ }
1886
+ dropOldest() {
1887
+ if (this.queue.shift()) this.countDropped(1);
1888
+ }
1889
+ countDropped(n) {
1890
+ this.droppedSinceLast += n;
1891
+ this.droppedTotal += n;
1892
+ }
1893
+ async drain() {
1894
+ for (; ; ) {
1895
+ const now = this.opts.now();
1896
+ if (now < this.backoffUntil) return;
1897
+ const batch = this.takeBatch(now);
1898
+ if (batch.length === 0) return;
1899
+ const ok = await this.send(batch);
1900
+ if (!ok) return;
1901
+ }
1902
+ }
1903
+ /** Oldest eligible item + up to maxBatch-1 more for the same destination. */
1904
+ takeBatch(now) {
1905
+ const first = this.queue.find((q) => q.eligibleAt <= now);
1906
+ if (!first) return [];
1907
+ const batch = [];
1908
+ const rest = [];
1909
+ for (const q of this.queue) {
1910
+ if (batch.length < this.opts.maxBatch && q.destKey === first.destKey && q.eligibleAt <= now) {
1911
+ q.inFlight = true;
1912
+ batch.push(q);
1913
+ } else {
1914
+ rest.push(q);
1915
+ }
1916
+ }
1917
+ this.queue = rest;
1918
+ return batch;
1919
+ }
1920
+ /** POST one batch. Returns false when the drain should pause (backoff). */
1921
+ async send(batch) {
1922
+ const dest = batch[0].dest;
1923
+ const useKey = dest.apiKey && !this.rejectedKeys.has(dest.apiKey) ? dest.apiKey : void 0;
1924
+ const reportedDropped = this.droppedSinceLast;
1925
+ const meta = {
1926
+ droppedSinceLast: reportedDropped,
1927
+ queueDepth: this.queue.length,
1928
+ adapter: dest.adapter ?? "edge-core",
1929
+ version: SDK_VERSION
1930
+ };
1931
+ const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
1932
+ const response = await withBudget(
1933
+ sdkFetch(`${dest.apiBaseUrl}/verification-activity/edge-events`, {
1934
+ method: "POST",
1935
+ headers: {
1936
+ "Content-Type": "application/json",
1937
+ ...useKey && { Authorization: `Bearer ${useKey}` }
1938
+ },
1939
+ body: JSON.stringify({ events: batch.map((q) => q.item), meta }),
1940
+ ...controller && { signal: controller.signal }
1941
+ }),
1942
+ this.opts.requestTimeoutMs
1943
+ );
1944
+ if (!response) controller?.abort();
1945
+ const status = response?.status;
1946
+ for (const q of batch) q.inFlight = false;
1947
+ if (status !== void 0 && status >= 200 && status < 300) {
1948
+ this.droppedSinceLast = Math.max(0, this.droppedSinceLast - reportedDropped);
1949
+ this.deliveredTotal += batch.length;
1950
+ return true;
1951
+ }
1952
+ if (status === 401 && useKey) {
1953
+ this.rejectedKeys.add(useKey);
1954
+ this.requeue(batch, false);
1955
+ return true;
1956
+ }
1957
+ if (status === 429) {
1958
+ const retryAfter = Number(response?.headers.get("retry-after"));
1959
+ const waitMs = Number.isFinite(retryAfter) && retryAfter > 0 ? Math.min(retryAfter, 120) * 1e3 : 3e4;
1960
+ this.backoffUntil = this.opts.now() + waitMs;
1961
+ this.requeue(batch, false);
1962
+ return false;
1963
+ }
1964
+ if (status !== void 0 && status >= 400 && status < 500) {
1965
+ this.countDropped(batch.length);
1966
+ return true;
1967
+ }
1968
+ this.backoffUntil = this.opts.now() + this.opts.retryBackoffMs;
1969
+ this.requeue(batch, true);
1970
+ return false;
1971
+ }
1972
+ /** Put a failed batch back at the head of the queue (order preserved). */
1973
+ requeue(batch, countAttempt) {
1974
+ const keep = [];
1975
+ for (const q of batch) {
1976
+ if (countAttempt) q.attempts += 1;
1977
+ if (q.attempts >= this.opts.maxAttempts) this.countDropped(1);
1978
+ else keep.push(q);
1979
+ }
1980
+ this.queue = [...keep, ...this.queue];
1981
+ while (this.queue.length > this.opts.maxItems) this.dropOldest();
1982
+ }
1983
+ };
1984
+ var beaconBuffer = new BeaconBuffer();
1631
1985
  function sampled(rate, random = Math.random) {
1632
1986
  if (rate <= 0) return false;
1633
1987
  if (rate >= 1) return true;
@@ -1804,12 +2158,19 @@ function defaultOnDenied(result, _req, res) {
1804
2158
  });
1805
2159
  return;
1806
2160
  }
1807
- const statusCode = !result.identityVerified ? 401 : 403;
2161
+ if (isVerificationUnavailable(result)) {
2162
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
2163
+ res.setHeader(VERIFICATION_STATUS_HEADER, "unavailable");
2164
+ res.setHeader("Retry-After", String(unavailableRetryAfterSeconds(result)));
2165
+ res.status(503).json(buildVerificationUnavailableBody(result));
2166
+ return;
2167
+ }
2168
+ const { status: statusCode, code } = denyStatusFor(result, "INSUFFICIENT_ACCESS");
1808
2169
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
1809
2170
  res.status(statusCode).json({
1810
2171
  success: false,
1811
2172
  error: {
1812
- code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
2173
+ code,
1813
2174
  message: result.denialReasons?.[0] || "Access denied",
1814
2175
  guidance: result.guidance,
1815
2176
  // Round-10: aggregated per-dimension detail + correlation handle.
@@ -2057,6 +2418,21 @@ function createMiddleware(options) {
2057
2418
  result.stepUpOutcome = outcome;
2058
2419
  }
2059
2420
  }
2421
+ if (!result.policyAllowed && isVerificationUnavailable(result) && (!shouldEnforce || isAnonymousRead(req.method, credentials))) {
2422
+ res.setHeader(VERIFICATION_STATUS_HEADER, "unavailable");
2423
+ return next();
2424
+ }
2425
+ if (!shouldEnforce) {
2426
+ if (config.setPassThroughHeader) {
2427
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
2428
+ res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
2429
+ }
2430
+ if (shouldRecordDecisions && sessionId) {
2431
+ recordDecision(config, sessionId, "granted").catch(() => {
2432
+ });
2433
+ }
2434
+ return next();
2435
+ }
2060
2436
  if (!result.policyAllowed) {
2061
2437
  if (shouldRecordDecisions && sessionId) {
2062
2438
  recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
@@ -2076,17 +2452,6 @@ function createMiddleware(options) {
2076
2452
  onDenied(result, req, res);
2077
2453
  return;
2078
2454
  }
2079
- if (!shouldEnforce) {
2080
- if (config.setPassThroughHeader) {
2081
- res.setHeader("X-Astra-Gateway-Mode", "enforced");
2082
- res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
2083
- }
2084
- if (shouldRecordDecisions && sessionId) {
2085
- recordDecision(config, sessionId, "granted").catch(() => {
2086
- });
2087
- }
2088
- return next();
2089
- }
2090
2455
  if (routeConfig.minTrustScore && result.agent) {
2091
2456
  if (result.agent.trustScore < routeConfig.minTrustScore) {
2092
2457
  const trustFailure = {
@@ -2142,14 +2507,6 @@ function createMiddleware(options) {
2142
2507
  verifiedAt: /* @__PURE__ */ new Date(),
2143
2508
  correlationId
2144
2509
  };
2145
- const catchUrls = config.apiBaseUrl ? await getWellKnownUrls(config.apiBaseUrl).catch(() => void 0) : void 0;
2146
- if (catchUrls) {
2147
- result.guidance = {
2148
- message: `Middleware threw ${errorClass} \u2014 failing closed`,
2149
- registrationUrl: catchUrls.registrationUrl,
2150
- documentationUrl: catchUrls.documentationUrl
2151
- };
2152
- }
2153
2510
  dedupeFailures(result);
2154
2511
  return onDenied(result, req, res);
2155
2512
  }
@@ -2569,6 +2926,20 @@ function createMiddleware2(options) {
2569
2926
  }
2570
2927
  const approvalRequired = result.policyAllowed && requiresHumanApproval(result);
2571
2928
  if (approvalRequired) annotateApprovalRequired(result);
2929
+ if (!result.policyAllowed && isVerificationUnavailable(result)) {
2930
+ if (isAnonymousRead(request.method, credentials)) {
2931
+ const passThrough = NextResponse.next();
2932
+ passThrough.headers.set(VERIFICATION_STATUS_HEADER, "unavailable");
2933
+ return passThrough;
2934
+ }
2935
+ return NextResponse.json(buildVerificationUnavailableBody(result), {
2936
+ status: 503,
2937
+ headers: {
2938
+ "Retry-After": String(unavailableRetryAfterSeconds(result)),
2939
+ [VERIFICATION_STATUS_HEADER]: "unavailable"
2940
+ }
2941
+ });
2942
+ }
2572
2943
  if (!result.policyAllowed || approvalRequired) {
2573
2944
  if (result.misconfigured && pathname.startsWith("/api/")) {
2574
2945
  return NextResponse.json(
@@ -2586,13 +2957,12 @@ function createMiddleware2(options) {
2586
2957
  );
2587
2958
  }
2588
2959
  if (pathname.startsWith("/api/")) {
2960
+ const denyStatus = denyStatusFor(result, "POLICY_DENIED");
2589
2961
  return NextResponse.json(
2590
2962
  {
2591
2963
  success: false,
2592
2964
  error: {
2593
- // Round-18 G4: 401 → identity missing (re-auth); 403 → identity
2594
- // OK, policy denied (update PDLSS / step up).
2595
- code: !result.identityVerified ? "UNAUTHORIZED" : "POLICY_DENIED",
2965
+ code: denyStatus.code,
2596
2966
  message: result.denialReasons?.[0] || "Access denied",
2597
2967
  guidance: result.guidance,
2598
2968
  failures: result.failures,
@@ -2602,7 +2972,7 @@ function createMiddleware2(options) {
2602
2972
  }
2603
2973
  },
2604
2974
  {
2605
- status: !result.identityVerified ? 401 : 403,
2975
+ status: denyStatus.status,
2606
2976
  ...stepUpHoldOutcome && {
2607
2977
  headers: { "X-Astra-Step-Up": stepUpHoldOutcome }
2608
2978
  }
@@ -2729,6 +3099,12 @@ var VerificationGatewayClient = class {
2729
3099
  * fulfil against it only once the order is settled / pending_merchant. An
2730
3100
  * explicit `buyerEmail` (here or on the bridge handoff body) wins over the
2731
3101
  * account default.
3102
+ *
3103
+ * 5.12.0 approval binding: pass the bridge handoff body's `attemptId` (and
3104
+ * the same `checkoutSessionId`) so a step-up approval minted for this cart
3105
+ * is matched to — and only to — this confirm. A held cart's approval is
3106
+ * bound to its checkout session and exact value; a confirm for any other
3107
+ * cart is held for its own approval.
2732
3108
  */
2733
3109
  async confirmCheckout(options) {
2734
3110
  const credentials = {
@@ -2748,6 +3124,7 @@ var VerificationGatewayClient = class {
2748
3124
  commercePhase: "confirm",
2749
3125
  checkoutSessionId: options.checkoutSessionId,
2750
3126
  checkoutItems: options.checkoutItems,
3127
+ ...options.attemptId && { attemptId: options.attemptId },
2751
3128
  buyerEmail: options.buyerEmail,
2752
3129
  counterpartyUrl: options.counterpartyUrl,
2753
3130
  counterpartyType: options.counterpartyType
@@ -2779,11 +3156,11 @@ var VerificationGatewayClient = class {
2779
3156
  },
2780
3157
  body: JSON.stringify(options)
2781
3158
  });
2782
- const json = await res.json().catch(() => ({}));
2783
- if (!res.ok || !json.success || !json.data) {
2784
- throw new Error(`reportSettlement failed (${res.status}): ${json.error ?? "unknown error"}`);
3159
+ const json2 = await res.json().catch(() => ({}));
3160
+ if (!res.ok || !json2.success || !json2.data) {
3161
+ throw new Error(`reportSettlement failed (${res.status}): ${json2.error ?? "unknown error"}`);
2785
3162
  }
2786
- return json.data;
3163
+ return json2.data;
2787
3164
  }
2788
3165
  /**
2789
3166
  * Quick verification — checks credentials and policy in one call.
@@ -3612,8 +3989,8 @@ function extractPaymentToken(body) {
3612
3989
  const raw = coerceString3(paymentData.token);
3613
3990
  const provider = coerceString3(paymentData.provider);
3614
3991
  if (!raw) return { raw: void 0, type: null, provider };
3615
- const type = classifyPaymentToken(raw);
3616
- return { raw, type, provider };
3992
+ const type2 = classifyPaymentToken(raw);
3993
+ return { raw, type: type2, provider };
3617
3994
  }
3618
3995
  function classifyPaymentToken(token) {
3619
3996
  if (token.startsWith("spt_")) return "stripe-spt";
@@ -3840,7 +4217,7 @@ function verifyStripeWebhook(payload, signatureHeader, secret, options = {}) {
3840
4217
  return { ok: false, timestamp: parsed.timestamp, error: "signature mismatch" };
3841
4218
  }
3842
4219
  function parseStripeSignature(header) {
3843
- let timestamp = null;
4220
+ let timestamp2 = null;
3844
4221
  const v1Signatures = [];
3845
4222
  for (const part of header.split(",")) {
3846
4223
  const [rawKey, rawValue] = part.split("=");
@@ -3849,12 +4226,12 @@ function parseStripeSignature(header) {
3849
4226
  const value = rawValue.trim();
3850
4227
  if (key === "t") {
3851
4228
  const n = Number(value);
3852
- if (Number.isFinite(n)) timestamp = n;
4229
+ if (Number.isFinite(n)) timestamp2 = n;
3853
4230
  } else if (key === "v1") {
3854
4231
  v1Signatures.push(value);
3855
4232
  }
3856
4233
  }
3857
- return { timestamp, v1Signatures };
4234
+ return { timestamp: timestamp2, v1Signatures };
3858
4235
  }
3859
4236
  function hexToBuffer(hex) {
3860
4237
  if (!/^[0-9a-fA-F]+$/.test(hex) || hex.length % 2 !== 0) return null;
@@ -4061,10 +4438,10 @@ function extractAP2Mandate(sdJwtCompact) {
4061
4438
  payload,
4062
4439
  disclosures
4063
4440
  );
4064
- const type = coerceMandateType2(claims.type ?? claims.mandate_type ?? claims.mandateType);
4065
- if (!type) return null;
4066
- if (type === "intent_mandate") return buildIntent(claims);
4067
- if (type === "cart_mandate") return buildCart(claims);
4441
+ const type2 = coerceMandateType2(claims.type ?? claims.mandate_type ?? claims.mandateType);
4442
+ if (!type2) return null;
4443
+ if (type2 === "intent_mandate") return buildIntent(claims);
4444
+ if (type2 === "cart_mandate") return buildCart(claims);
4068
4445
  return buildPayment(claims);
4069
4446
  }
4070
4447
  function extractAP2Mandates(input) {
@@ -4673,8 +5050,8 @@ function extractX402FromRequest(request) {
4673
5050
  try {
4674
5051
  const decoded = safeBase64Decode(headerValue3);
4675
5052
  if (decoded) {
4676
- const json = JSON.parse(decoded);
4677
- const parsed = tryParsePayload(json);
5053
+ const json2 = JSON.parse(decoded);
5054
+ const parsed = tryParsePayload(json2);
4678
5055
  if (parsed) return buildPayloadContext(parsed, "header");
4679
5056
  }
4680
5057
  } catch {
@@ -4699,8 +5076,8 @@ function extractX402FromResponse(response) {
4699
5076
  try {
4700
5077
  const decoded = safeBase64Decode(headerValue3);
4701
5078
  if (decoded) {
4702
- const json = JSON.parse(decoded);
4703
- const parsed = tryParseRequired(json);
5079
+ const json2 = JSON.parse(decoded);
5080
+ const parsed = tryParseRequired(json2);
4704
5081
  if (parsed) return buildRequiredContext(parsed, "header");
4705
5082
  }
4706
5083
  } catch {
@@ -5551,8 +5928,37 @@ function dedupeFailures2(result) {
5551
5928
  result.denialReasons = [...new Set(result.denialReasons)];
5552
5929
  }
5553
5930
  }
5931
+ function isReadOnlyMcpMethod(parsed) {
5932
+ return parsed.method !== "tools/call";
5933
+ }
5554
5934
  function defaultMcpDenied(result, req, res) {
5555
5935
  const id = req.body?.id ?? null;
5936
+ if (isVerificationUnavailable(result)) {
5937
+ const retryAfterSeconds = unavailableRetryAfterSeconds(result);
5938
+ const body = buildVerificationUnavailableBody(result).error;
5939
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
5940
+ res.setHeader(VERIFICATION_STATUS_HEADER, "unavailable");
5941
+ res.setHeader("Retry-After", String(retryAfterSeconds));
5942
+ res.status(503).json({
5943
+ jsonrpc: "2.0",
5944
+ id,
5945
+ error: {
5946
+ // -32003 → verification temporarily unavailable (retryable)
5947
+ code: -32003,
5948
+ message: body.message,
5949
+ data: {
5950
+ code: body.code,
5951
+ recommendation: "error",
5952
+ retryable: true,
5953
+ retryAfterSeconds,
5954
+ guidance: body.guidance,
5955
+ failures: result.failures,
5956
+ correlationId: result.correlationId
5957
+ }
5958
+ }
5959
+ });
5960
+ return;
5961
+ }
5556
5962
  if (result.misconfigured) {
5557
5963
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
5558
5964
  res.status(503).json({
@@ -5571,7 +5977,7 @@ function defaultMcpDenied(result, req, res) {
5571
5977
  });
5572
5978
  return;
5573
5979
  }
5574
- const status = !result.identityVerified ? 401 : 403;
5980
+ const { status, code: denyCode } = denyStatusFor(result, "INSUFFICIENT_ACCESS");
5575
5981
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
5576
5982
  res.status(status).json({
5577
5983
  jsonrpc: "2.0",
@@ -5581,9 +5987,11 @@ function defaultMcpDenied(result, req, res) {
5581
5987
  // -32000 → unauthorized (no identity resolved)
5582
5988
  // -32001 → insufficient access (identity OK, policy denied)
5583
5989
  // -32002 → merchant verification misconfigured (handled above)
5990
+ // -32003 → verification temporarily unavailable (handled above)
5584
5991
  code: !result.identityVerified ? -32e3 : -32001,
5585
5992
  message: result.denialReasons?.[0] ?? "Access denied",
5586
5993
  data: {
5994
+ code: denyCode,
5587
5995
  guidance: result.guidance,
5588
5996
  // Round-10: aggregated per-dimension detail + correlation handle.
5589
5997
  failures: result.failures,
@@ -5711,6 +6119,9 @@ function createMcpMiddleware(options) {
5711
6119
  resolved_action: pdlss.action
5712
6120
  });
5713
6121
  }
6122
+ if (!pdlss.purpose && !shouldEnforce) {
6123
+ return next();
6124
+ }
5714
6125
  if (!pdlss.purpose) {
5715
6126
  const id = req.body?.id ?? null;
5716
6127
  res.status(400).json({
@@ -5730,6 +6141,9 @@ function createMcpMiddleware(options) {
5730
6141
  }
5731
6142
  const counterpartyUrl = config.counterpartyUrl || `${req.protocol}://${req.get("host")}${req.path}`;
5732
6143
  const shouldRecordDecisions = recordDecisions !== false;
6144
+ const forwardedFor = req.headers["x-forwarded-for"];
6145
+ const forwardedForStr = Array.isArray(forwardedFor) ? forwardedFor.join(", ") : forwardedFor;
6146
+ const sourceIp = req.ip ?? (forwardedForStr ? forwardedForStr.split(",")[0].trim() : void 0);
5733
6147
  const verificationRequest = {
5734
6148
  credentials,
5735
6149
  purpose: pdlss.purpose,
@@ -5744,9 +6158,10 @@ function createMcpMiddleware(options) {
5744
6158
  counterpartyType: config.counterpartyType || "mcp_server",
5745
6159
  enableRuntimeChallenge,
5746
6160
  callerMetadata: {
5747
- sourceIp: req.ip,
6161
+ sourceIp,
5748
6162
  userAgent: req.headers["user-agent"],
5749
6163
  host: req.headers.host,
6164
+ ...forwardedForStr && { forwardedFor: forwardedForStr },
5750
6165
  // Capture EVERY inbound header (parity with the express adapter —
5751
6166
  // MCP-only merchants have no edge to do it upstream) plus the
5752
6167
  // CDN-derived connection block. Local string work, secrets
@@ -5769,6 +6184,21 @@ function createMcpMiddleware(options) {
5769
6184
  result.stepUpOutcome = outcome;
5770
6185
  }
5771
6186
  }
6187
+ if (!result.policyAllowed && isVerificationUnavailable(result) && (!shouldEnforce || isReadOnlyMcpMethod(parsed) && !credentials.astraId && !credentials.jwt)) {
6188
+ res.setHeader(VERIFICATION_STATUS_HEADER, "unavailable");
6189
+ return next();
6190
+ }
6191
+ if (!shouldEnforce) {
6192
+ if (config.setPassThroughHeader) {
6193
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
6194
+ res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
6195
+ }
6196
+ if (shouldRecordDecisions && sessionId) {
6197
+ recordDecision(config, sessionId, "granted").catch(() => {
6198
+ });
6199
+ }
6200
+ return next();
6201
+ }
5772
6202
  if (!result.policyAllowed) {
5773
6203
  if (shouldRecordDecisions && sessionId) {
5774
6204
  recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
@@ -5788,17 +6218,6 @@ function createMcpMiddleware(options) {
5788
6218
  onDenied(result, req, res);
5789
6219
  return;
5790
6220
  }
5791
- if (!shouldEnforce) {
5792
- if (config.setPassThroughHeader) {
5793
- res.setHeader("X-Astra-Gateway-Mode", "enforced");
5794
- res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
5795
- }
5796
- if (shouldRecordDecisions && sessionId) {
5797
- recordDecision(config, sessionId, "granted").catch(() => {
5798
- });
5799
- }
5800
- return next();
5801
- }
5802
6221
  if (effectiveAstraId) {
5803
6222
  res.setHeader(
5804
6223
  MCP_VERIFIED_HOP_HEADER,
@@ -5839,14 +6258,6 @@ function createMcpMiddleware(options) {
5839
6258
  verifiedAt: /* @__PURE__ */ new Date(),
5840
6259
  correlationId
5841
6260
  };
5842
- const catchUrls = config.apiBaseUrl ? await getWellKnownUrls(config.apiBaseUrl).catch(() => void 0) : void 0;
5843
- if (catchUrls) {
5844
- result.guidance = {
5845
- message: `Middleware threw ${errorClass} \u2014 failing closed`,
5846
- registrationUrl: catchUrls.registrationUrl,
5847
- documentationUrl: catchUrls.documentationUrl
5848
- };
5849
- }
5850
6261
  dedupeFailures2(result);
5851
6262
  return onDenied(result, req, res);
5852
6263
  }
@@ -6582,6 +6993,3255 @@ function detectRuntime(userAgent) {
6582
6993
  }
6583
6994
  return void 0;
6584
6995
  }
6996
+
6997
+ // ../../node_modules/js-yaml/dist/js-yaml.mjs
6998
+ function getDefaultExportFromCjs(x) {
6999
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
7000
+ }
7001
+ var jsYaml = {};
7002
+ var loader = {};
7003
+ var common = {};
7004
+ var hasRequiredCommon;
7005
+ function requireCommon() {
7006
+ if (hasRequiredCommon) return common;
7007
+ hasRequiredCommon = 1;
7008
+ function isNothing(subject) {
7009
+ return typeof subject === "undefined" || subject === null;
7010
+ }
7011
+ function isObject(subject) {
7012
+ return typeof subject === "object" && subject !== null;
7013
+ }
7014
+ function toArray(sequence) {
7015
+ if (Array.isArray(sequence)) return sequence;
7016
+ else if (isNothing(sequence)) return [];
7017
+ return [sequence];
7018
+ }
7019
+ function extend(target, source) {
7020
+ if (source) {
7021
+ const sourceKeys = Object.keys(source);
7022
+ for (let index = 0, length = sourceKeys.length; index < length; index += 1) {
7023
+ const key = sourceKeys[index];
7024
+ target[key] = source[key];
7025
+ }
7026
+ }
7027
+ return target;
7028
+ }
7029
+ function repeat(string, count) {
7030
+ let result = "";
7031
+ for (let cycle = 0; cycle < count; cycle += 1) {
7032
+ result += string;
7033
+ }
7034
+ return result;
7035
+ }
7036
+ function isNegativeZero(number) {
7037
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
7038
+ }
7039
+ common.isNothing = isNothing;
7040
+ common.isObject = isObject;
7041
+ common.toArray = toArray;
7042
+ common.repeat = repeat;
7043
+ common.isNegativeZero = isNegativeZero;
7044
+ common.extend = extend;
7045
+ return common;
7046
+ }
7047
+ var exception;
7048
+ var hasRequiredException;
7049
+ function requireException() {
7050
+ if (hasRequiredException) return exception;
7051
+ hasRequiredException = 1;
7052
+ function formatError(exception2, compact) {
7053
+ let where = "";
7054
+ const message = exception2.reason || "(unknown reason)";
7055
+ if (!exception2.mark) return message;
7056
+ if (exception2.mark.name) {
7057
+ where += 'in "' + exception2.mark.name + '" ';
7058
+ }
7059
+ where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
7060
+ if (!compact && exception2.mark.snippet) {
7061
+ where += "\n\n" + exception2.mark.snippet;
7062
+ }
7063
+ return message + " " + where;
7064
+ }
7065
+ function YAMLException2(reason, mark) {
7066
+ Error.call(this);
7067
+ this.name = "YAMLException";
7068
+ this.reason = reason;
7069
+ this.mark = mark;
7070
+ this.message = formatError(this, false);
7071
+ if (Error.captureStackTrace) {
7072
+ Error.captureStackTrace(this, this.constructor);
7073
+ } else {
7074
+ this.stack = new Error().stack || "";
7075
+ }
7076
+ }
7077
+ YAMLException2.prototype = Object.create(Error.prototype);
7078
+ YAMLException2.prototype.constructor = YAMLException2;
7079
+ YAMLException2.prototype.toString = function toString(compact) {
7080
+ return this.name + ": " + formatError(this, compact);
7081
+ };
7082
+ exception = YAMLException2;
7083
+ return exception;
7084
+ }
7085
+ var snippet;
7086
+ var hasRequiredSnippet;
7087
+ function requireSnippet() {
7088
+ if (hasRequiredSnippet) return snippet;
7089
+ hasRequiredSnippet = 1;
7090
+ const common2 = requireCommon();
7091
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
7092
+ let head = "";
7093
+ let tail = "";
7094
+ const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
7095
+ if (position - lineStart > maxHalfLength) {
7096
+ head = " ... ";
7097
+ lineStart = position - maxHalfLength + head.length;
7098
+ }
7099
+ if (lineEnd - position > maxHalfLength) {
7100
+ tail = " ...";
7101
+ lineEnd = position + maxHalfLength - tail.length;
7102
+ }
7103
+ return {
7104
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
7105
+ pos: position - lineStart + head.length
7106
+ // relative position
7107
+ };
7108
+ }
7109
+ function padStart(string, max) {
7110
+ return common2.repeat(" ", max - string.length) + string;
7111
+ }
7112
+ function makeSnippet(mark, options) {
7113
+ options = Object.create(options || null);
7114
+ if (!mark.buffer) return null;
7115
+ if (!options.maxLength) options.maxLength = 79;
7116
+ if (typeof options.indent !== "number") options.indent = 1;
7117
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
7118
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
7119
+ const re = /\r?\n|\r|\0/g;
7120
+ const lineStarts = [0];
7121
+ const lineEnds = [];
7122
+ let match;
7123
+ let foundLineNo = -1;
7124
+ while (match = re.exec(mark.buffer)) {
7125
+ lineEnds.push(match.index);
7126
+ lineStarts.push(match.index + match[0].length);
7127
+ if (mark.position <= match.index && foundLineNo < 0) {
7128
+ foundLineNo = lineStarts.length - 2;
7129
+ }
7130
+ }
7131
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
7132
+ let result = "";
7133
+ const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
7134
+ const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
7135
+ for (let i = 1; i <= options.linesBefore; i++) {
7136
+ if (foundLineNo - i < 0) break;
7137
+ const line2 = getLine(
7138
+ mark.buffer,
7139
+ lineStarts[foundLineNo - i],
7140
+ lineEnds[foundLineNo - i],
7141
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
7142
+ maxLineLength
7143
+ );
7144
+ result = common2.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line2.str + "\n" + result;
7145
+ }
7146
+ const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
7147
+ result += common2.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
7148
+ result += common2.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
7149
+ for (let i = 1; i <= options.linesAfter; i++) {
7150
+ if (foundLineNo + i >= lineEnds.length) break;
7151
+ const line2 = getLine(
7152
+ mark.buffer,
7153
+ lineStarts[foundLineNo + i],
7154
+ lineEnds[foundLineNo + i],
7155
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
7156
+ maxLineLength
7157
+ );
7158
+ result += common2.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line2.str + "\n";
7159
+ }
7160
+ return result.replace(/\n$/, "");
7161
+ }
7162
+ snippet = makeSnippet;
7163
+ return snippet;
7164
+ }
7165
+ var type;
7166
+ var hasRequiredType;
7167
+ function requireType() {
7168
+ if (hasRequiredType) return type;
7169
+ hasRequiredType = 1;
7170
+ const YAMLException2 = requireException();
7171
+ const TYPE_CONSTRUCTOR_OPTIONS = [
7172
+ "kind",
7173
+ "multi",
7174
+ "resolve",
7175
+ "construct",
7176
+ "instanceOf",
7177
+ "predicate",
7178
+ "represent",
7179
+ "representName",
7180
+ "defaultStyle",
7181
+ "styleAliases"
7182
+ ];
7183
+ const YAML_NODE_KINDS = [
7184
+ "scalar",
7185
+ "sequence",
7186
+ "mapping"
7187
+ ];
7188
+ function compileStyleAliases(map2) {
7189
+ const result = {};
7190
+ if (map2 !== null) {
7191
+ Object.keys(map2).forEach(function(style) {
7192
+ map2[style].forEach(function(alias) {
7193
+ result[String(alias)] = style;
7194
+ });
7195
+ });
7196
+ }
7197
+ return result;
7198
+ }
7199
+ function Type2(tag, options) {
7200
+ options = options || {};
7201
+ Object.keys(options).forEach(function(name) {
7202
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
7203
+ throw new YAMLException2('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
7204
+ }
7205
+ });
7206
+ this.options = options;
7207
+ this.tag = tag;
7208
+ this.kind = options["kind"] || null;
7209
+ this.resolve = options["resolve"] || function() {
7210
+ return true;
7211
+ };
7212
+ this.construct = options["construct"] || function(data) {
7213
+ return data;
7214
+ };
7215
+ this.instanceOf = options["instanceOf"] || null;
7216
+ this.predicate = options["predicate"] || null;
7217
+ this.represent = options["represent"] || null;
7218
+ this.representName = options["representName"] || null;
7219
+ this.defaultStyle = options["defaultStyle"] || null;
7220
+ this.multi = options["multi"] || false;
7221
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
7222
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
7223
+ throw new YAMLException2('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
7224
+ }
7225
+ }
7226
+ type = Type2;
7227
+ return type;
7228
+ }
7229
+ var schema;
7230
+ var hasRequiredSchema;
7231
+ function requireSchema() {
7232
+ if (hasRequiredSchema) return schema;
7233
+ hasRequiredSchema = 1;
7234
+ const YAMLException2 = requireException();
7235
+ const Type2 = requireType();
7236
+ function compileList(schema2, name) {
7237
+ const result = [];
7238
+ schema2[name].forEach(function(currentType) {
7239
+ let newIndex = result.length;
7240
+ result.forEach(function(previousType, previousIndex) {
7241
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
7242
+ newIndex = previousIndex;
7243
+ }
7244
+ });
7245
+ result[newIndex] = currentType;
7246
+ });
7247
+ return result;
7248
+ }
7249
+ function compileMap() {
7250
+ const result = {
7251
+ scalar: {},
7252
+ sequence: {},
7253
+ mapping: {},
7254
+ fallback: {},
7255
+ multi: {
7256
+ scalar: [],
7257
+ sequence: [],
7258
+ mapping: [],
7259
+ fallback: []
7260
+ }
7261
+ };
7262
+ function collectType(type2) {
7263
+ if (type2.multi) {
7264
+ result.multi[type2.kind].push(type2);
7265
+ result.multi["fallback"].push(type2);
7266
+ } else {
7267
+ result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
7268
+ }
7269
+ }
7270
+ for (let index = 0, length = arguments.length; index < length; index += 1) {
7271
+ arguments[index].forEach(collectType);
7272
+ }
7273
+ return result;
7274
+ }
7275
+ function Schema2(definition) {
7276
+ return this.extend(definition);
7277
+ }
7278
+ Schema2.prototype.extend = function extend(definition) {
7279
+ let implicit = [];
7280
+ let explicit = [];
7281
+ if (definition instanceof Type2) {
7282
+ explicit.push(definition);
7283
+ } else if (Array.isArray(definition)) {
7284
+ explicit = explicit.concat(definition);
7285
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
7286
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
7287
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
7288
+ } else {
7289
+ throw new YAMLException2("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
7290
+ }
7291
+ implicit.forEach(function(type2) {
7292
+ if (!(type2 instanceof Type2)) {
7293
+ throw new YAMLException2("Specified list of YAML types (or a single Type object) contains a non-Type object.");
7294
+ }
7295
+ if (type2.loadKind && type2.loadKind !== "scalar") {
7296
+ throw new YAMLException2("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
7297
+ }
7298
+ if (type2.multi) {
7299
+ throw new YAMLException2("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
7300
+ }
7301
+ });
7302
+ explicit.forEach(function(type2) {
7303
+ if (!(type2 instanceof Type2)) {
7304
+ throw new YAMLException2("Specified list of YAML types (or a single Type object) contains a non-Type object.");
7305
+ }
7306
+ });
7307
+ const result = Object.create(Schema2.prototype);
7308
+ result.implicit = (this.implicit || []).concat(implicit);
7309
+ result.explicit = (this.explicit || []).concat(explicit);
7310
+ result.compiledImplicit = compileList(result, "implicit");
7311
+ result.compiledExplicit = compileList(result, "explicit");
7312
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
7313
+ return result;
7314
+ };
7315
+ schema = Schema2;
7316
+ return schema;
7317
+ }
7318
+ var str;
7319
+ var hasRequiredStr;
7320
+ function requireStr() {
7321
+ if (hasRequiredStr) return str;
7322
+ hasRequiredStr = 1;
7323
+ const Type2 = requireType();
7324
+ str = new Type2("tag:yaml.org,2002:str", {
7325
+ kind: "scalar",
7326
+ construct: function(data) {
7327
+ return data !== null ? data : "";
7328
+ }
7329
+ });
7330
+ return str;
7331
+ }
7332
+ var seq;
7333
+ var hasRequiredSeq;
7334
+ function requireSeq() {
7335
+ if (hasRequiredSeq) return seq;
7336
+ hasRequiredSeq = 1;
7337
+ const Type2 = requireType();
7338
+ seq = new Type2("tag:yaml.org,2002:seq", {
7339
+ kind: "sequence",
7340
+ construct: function(data) {
7341
+ return data !== null ? data : [];
7342
+ }
7343
+ });
7344
+ return seq;
7345
+ }
7346
+ var map;
7347
+ var hasRequiredMap;
7348
+ function requireMap() {
7349
+ if (hasRequiredMap) return map;
7350
+ hasRequiredMap = 1;
7351
+ const Type2 = requireType();
7352
+ map = new Type2("tag:yaml.org,2002:map", {
7353
+ kind: "mapping",
7354
+ construct: function(data) {
7355
+ return data !== null ? data : {};
7356
+ }
7357
+ });
7358
+ return map;
7359
+ }
7360
+ var failsafe;
7361
+ var hasRequiredFailsafe;
7362
+ function requireFailsafe() {
7363
+ if (hasRequiredFailsafe) return failsafe;
7364
+ hasRequiredFailsafe = 1;
7365
+ const Schema2 = requireSchema();
7366
+ failsafe = new Schema2({
7367
+ explicit: [
7368
+ requireStr(),
7369
+ requireSeq(),
7370
+ requireMap()
7371
+ ]
7372
+ });
7373
+ return failsafe;
7374
+ }
7375
+ var _null;
7376
+ var hasRequired_null;
7377
+ function require_null() {
7378
+ if (hasRequired_null) return _null;
7379
+ hasRequired_null = 1;
7380
+ const Type2 = requireType();
7381
+ function resolveYamlNull(data) {
7382
+ if (data === null) return true;
7383
+ const max = data.length;
7384
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
7385
+ }
7386
+ function constructYamlNull() {
7387
+ return null;
7388
+ }
7389
+ function isNull(object) {
7390
+ return object === null;
7391
+ }
7392
+ _null = new Type2("tag:yaml.org,2002:null", {
7393
+ kind: "scalar",
7394
+ resolve: resolveYamlNull,
7395
+ construct: constructYamlNull,
7396
+ predicate: isNull,
7397
+ represent: {
7398
+ canonical: function() {
7399
+ return "~";
7400
+ },
7401
+ lowercase: function() {
7402
+ return "null";
7403
+ },
7404
+ uppercase: function() {
7405
+ return "NULL";
7406
+ },
7407
+ camelcase: function() {
7408
+ return "Null";
7409
+ },
7410
+ empty: function() {
7411
+ return "";
7412
+ }
7413
+ },
7414
+ defaultStyle: "lowercase"
7415
+ });
7416
+ return _null;
7417
+ }
7418
+ var bool;
7419
+ var hasRequiredBool;
7420
+ function requireBool() {
7421
+ if (hasRequiredBool) return bool;
7422
+ hasRequiredBool = 1;
7423
+ const Type2 = requireType();
7424
+ function resolveYamlBoolean(data) {
7425
+ if (data === null) return false;
7426
+ const max = data.length;
7427
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
7428
+ }
7429
+ function constructYamlBoolean(data) {
7430
+ return data === "true" || data === "True" || data === "TRUE";
7431
+ }
7432
+ function isBoolean(object) {
7433
+ return Object.prototype.toString.call(object) === "[object Boolean]";
7434
+ }
7435
+ bool = new Type2("tag:yaml.org,2002:bool", {
7436
+ kind: "scalar",
7437
+ resolve: resolveYamlBoolean,
7438
+ construct: constructYamlBoolean,
7439
+ predicate: isBoolean,
7440
+ represent: {
7441
+ lowercase: function(object) {
7442
+ return object ? "true" : "false";
7443
+ },
7444
+ uppercase: function(object) {
7445
+ return object ? "TRUE" : "FALSE";
7446
+ },
7447
+ camelcase: function(object) {
7448
+ return object ? "True" : "False";
7449
+ }
7450
+ },
7451
+ defaultStyle: "lowercase"
7452
+ });
7453
+ return bool;
7454
+ }
7455
+ var int;
7456
+ var hasRequiredInt;
7457
+ function requireInt() {
7458
+ if (hasRequiredInt) return int;
7459
+ hasRequiredInt = 1;
7460
+ const common2 = requireCommon();
7461
+ const Type2 = requireType();
7462
+ function isHexCode(c) {
7463
+ return c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
7464
+ }
7465
+ function isOctCode(c) {
7466
+ return c >= 48 && c <= 55;
7467
+ }
7468
+ function isDecCode(c) {
7469
+ return c >= 48 && c <= 57;
7470
+ }
7471
+ function resolveYamlInteger(data) {
7472
+ if (data === null) return false;
7473
+ const max = data.length;
7474
+ let index = 0;
7475
+ let hasDigits = false;
7476
+ if (!max) return false;
7477
+ let ch = data[index];
7478
+ if (ch === "-" || ch === "+") {
7479
+ ch = data[++index];
7480
+ }
7481
+ if (ch === "0") {
7482
+ if (index + 1 === max) return true;
7483
+ ch = data[++index];
7484
+ if (ch === "b") {
7485
+ index++;
7486
+ for (; index < max; index++) {
7487
+ ch = data[index];
7488
+ if (ch !== "0" && ch !== "1") return false;
7489
+ hasDigits = true;
7490
+ }
7491
+ return hasDigits && isFinite(parseYamlInteger(data));
7492
+ }
7493
+ if (ch === "x") {
7494
+ index++;
7495
+ for (; index < max; index++) {
7496
+ if (!isHexCode(data.charCodeAt(index))) return false;
7497
+ hasDigits = true;
7498
+ }
7499
+ return hasDigits && isFinite(parseYamlInteger(data));
7500
+ }
7501
+ if (ch === "o") {
7502
+ index++;
7503
+ for (; index < max; index++) {
7504
+ if (!isOctCode(data.charCodeAt(index))) return false;
7505
+ hasDigits = true;
7506
+ }
7507
+ return hasDigits && isFinite(parseYamlInteger(data));
7508
+ }
7509
+ }
7510
+ for (; index < max; index++) {
7511
+ if (!isDecCode(data.charCodeAt(index))) {
7512
+ return false;
7513
+ }
7514
+ hasDigits = true;
7515
+ }
7516
+ if (!hasDigits) return false;
7517
+ return isFinite(parseYamlInteger(data));
7518
+ }
7519
+ function parseYamlInteger(data) {
7520
+ let value = data;
7521
+ let sign = 1;
7522
+ let ch = value[0];
7523
+ if (ch === "-" || ch === "+") {
7524
+ if (ch === "-") sign = -1;
7525
+ value = value.slice(1);
7526
+ ch = value[0];
7527
+ }
7528
+ if (value === "0") return 0;
7529
+ if (ch === "0") {
7530
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
7531
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
7532
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
7533
+ }
7534
+ return sign * parseInt(value, 10);
7535
+ }
7536
+ function constructYamlInteger(data) {
7537
+ return parseYamlInteger(data);
7538
+ }
7539
+ function isInteger(object) {
7540
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common2.isNegativeZero(object));
7541
+ }
7542
+ int = new Type2("tag:yaml.org,2002:int", {
7543
+ kind: "scalar",
7544
+ resolve: resolveYamlInteger,
7545
+ construct: constructYamlInteger,
7546
+ predicate: isInteger,
7547
+ represent: {
7548
+ binary: function(obj) {
7549
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
7550
+ },
7551
+ octal: function(obj) {
7552
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
7553
+ },
7554
+ decimal: function(obj) {
7555
+ return obj.toString(10);
7556
+ },
7557
+ hexadecimal: function(obj) {
7558
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
7559
+ }
7560
+ },
7561
+ defaultStyle: "decimal",
7562
+ styleAliases: {
7563
+ binary: [2, "bin"],
7564
+ octal: [8, "oct"],
7565
+ decimal: [10, "dec"],
7566
+ hexadecimal: [16, "hex"]
7567
+ }
7568
+ });
7569
+ return int;
7570
+ }
7571
+ var float;
7572
+ var hasRequiredFloat;
7573
+ function requireFloat() {
7574
+ if (hasRequiredFloat) return float;
7575
+ hasRequiredFloat = 1;
7576
+ const common2 = requireCommon();
7577
+ const Type2 = requireType();
7578
+ const YAML_FLOAT_PATTERN = new RegExp(
7579
+ // 2.5e4, 2.5 and integers
7580
+ "^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
7581
+ );
7582
+ const YAML_FLOAT_SPECIAL_PATTERN = new RegExp(
7583
+ "^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
7584
+ );
7585
+ function resolveYamlFloat(data) {
7586
+ if (data === null) return false;
7587
+ if (!YAML_FLOAT_PATTERN.test(data)) {
7588
+ return false;
7589
+ }
7590
+ if (isFinite(parseFloat(data, 10))) {
7591
+ return true;
7592
+ }
7593
+ return YAML_FLOAT_SPECIAL_PATTERN.test(data);
7594
+ }
7595
+ function constructYamlFloat(data) {
7596
+ let value = data.toLowerCase();
7597
+ const sign = value[0] === "-" ? -1 : 1;
7598
+ if ("+-".indexOf(value[0]) >= 0) {
7599
+ value = value.slice(1);
7600
+ }
7601
+ if (value === ".inf") {
7602
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
7603
+ } else if (value === ".nan") {
7604
+ return NaN;
7605
+ }
7606
+ return sign * parseFloat(value, 10);
7607
+ }
7608
+ const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
7609
+ function representYamlFloat(object, style) {
7610
+ if (isNaN(object)) {
7611
+ switch (style) {
7612
+ case "lowercase":
7613
+ return ".nan";
7614
+ case "uppercase":
7615
+ return ".NAN";
7616
+ case "camelcase":
7617
+ return ".NaN";
7618
+ }
7619
+ } else if (Number.POSITIVE_INFINITY === object) {
7620
+ switch (style) {
7621
+ case "lowercase":
7622
+ return ".inf";
7623
+ case "uppercase":
7624
+ return ".INF";
7625
+ case "camelcase":
7626
+ return ".Inf";
7627
+ }
7628
+ } else if (Number.NEGATIVE_INFINITY === object) {
7629
+ switch (style) {
7630
+ case "lowercase":
7631
+ return "-.inf";
7632
+ case "uppercase":
7633
+ return "-.INF";
7634
+ case "camelcase":
7635
+ return "-.Inf";
7636
+ }
7637
+ } else if (common2.isNegativeZero(object)) {
7638
+ return "-0.0";
7639
+ }
7640
+ const res = object.toString(10);
7641
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
7642
+ }
7643
+ function isFloat(object) {
7644
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common2.isNegativeZero(object));
7645
+ }
7646
+ float = new Type2("tag:yaml.org,2002:float", {
7647
+ kind: "scalar",
7648
+ resolve: resolveYamlFloat,
7649
+ construct: constructYamlFloat,
7650
+ predicate: isFloat,
7651
+ represent: representYamlFloat,
7652
+ defaultStyle: "lowercase"
7653
+ });
7654
+ return float;
7655
+ }
7656
+ var json;
7657
+ var hasRequiredJson;
7658
+ function requireJson() {
7659
+ if (hasRequiredJson) return json;
7660
+ hasRequiredJson = 1;
7661
+ json = requireFailsafe().extend({
7662
+ implicit: [
7663
+ require_null(),
7664
+ requireBool(),
7665
+ requireInt(),
7666
+ requireFloat()
7667
+ ]
7668
+ });
7669
+ return json;
7670
+ }
7671
+ var core;
7672
+ var hasRequiredCore;
7673
+ function requireCore() {
7674
+ if (hasRequiredCore) return core;
7675
+ hasRequiredCore = 1;
7676
+ core = requireJson();
7677
+ return core;
7678
+ }
7679
+ var timestamp;
7680
+ var hasRequiredTimestamp;
7681
+ function requireTimestamp() {
7682
+ if (hasRequiredTimestamp) return timestamp;
7683
+ hasRequiredTimestamp = 1;
7684
+ const Type2 = requireType();
7685
+ const YAML_DATE_REGEXP = new RegExp(
7686
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
7687
+ );
7688
+ const YAML_TIMESTAMP_REGEXP = new RegExp(
7689
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
7690
+ );
7691
+ function resolveYamlTimestamp(data) {
7692
+ if (data === null) return false;
7693
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
7694
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
7695
+ return false;
7696
+ }
7697
+ function constructYamlTimestamp(data) {
7698
+ let fraction = 0;
7699
+ let delta = null;
7700
+ let match = YAML_DATE_REGEXP.exec(data);
7701
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
7702
+ if (match === null) throw new Error("Date resolve error");
7703
+ const year = +match[1];
7704
+ const month = +match[2] - 1;
7705
+ const day = +match[3];
7706
+ if (!match[4]) {
7707
+ return new Date(Date.UTC(year, month, day));
7708
+ }
7709
+ const hour = +match[4];
7710
+ const minute = +match[5];
7711
+ const second = +match[6];
7712
+ if (match[7]) {
7713
+ fraction = match[7].slice(0, 3);
7714
+ while (fraction.length < 3) {
7715
+ fraction += "0";
7716
+ }
7717
+ fraction = +fraction;
7718
+ }
7719
+ if (match[9]) {
7720
+ const tzHour = +match[10];
7721
+ const tzMinute = +(match[11] || 0);
7722
+ delta = (tzHour * 60 + tzMinute) * 6e4;
7723
+ if (match[9] === "-") delta = -delta;
7724
+ }
7725
+ const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
7726
+ if (delta) date.setTime(date.getTime() - delta);
7727
+ return date;
7728
+ }
7729
+ function representYamlTimestamp(object) {
7730
+ return object.toISOString();
7731
+ }
7732
+ timestamp = new Type2("tag:yaml.org,2002:timestamp", {
7733
+ kind: "scalar",
7734
+ resolve: resolveYamlTimestamp,
7735
+ construct: constructYamlTimestamp,
7736
+ instanceOf: Date,
7737
+ represent: representYamlTimestamp
7738
+ });
7739
+ return timestamp;
7740
+ }
7741
+ var merge;
7742
+ var hasRequiredMerge;
7743
+ function requireMerge() {
7744
+ if (hasRequiredMerge) return merge;
7745
+ hasRequiredMerge = 1;
7746
+ const Type2 = requireType();
7747
+ function resolveYamlMerge(data) {
7748
+ return data === "<<" || data === null;
7749
+ }
7750
+ merge = new Type2("tag:yaml.org,2002:merge", {
7751
+ kind: "scalar",
7752
+ resolve: resolveYamlMerge
7753
+ });
7754
+ return merge;
7755
+ }
7756
+ var binary;
7757
+ var hasRequiredBinary;
7758
+ function requireBinary() {
7759
+ if (hasRequiredBinary) return binary;
7760
+ hasRequiredBinary = 1;
7761
+ const Type2 = requireType();
7762
+ const BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
7763
+ function resolveYamlBinary(data) {
7764
+ if (data === null) return false;
7765
+ let bitlen = 0;
7766
+ const max = data.length;
7767
+ const map2 = BASE64_MAP;
7768
+ for (let idx = 0; idx < max; idx++) {
7769
+ const code = map2.indexOf(data.charAt(idx));
7770
+ if (code > 64) continue;
7771
+ if (code < 0) return false;
7772
+ bitlen += 6;
7773
+ }
7774
+ return bitlen % 8 === 0;
7775
+ }
7776
+ function constructYamlBinary(data) {
7777
+ const input = data.replace(/[\r\n=]/g, "");
7778
+ const max = input.length;
7779
+ const map2 = BASE64_MAP;
7780
+ let bits = 0;
7781
+ const result = [];
7782
+ for (let idx = 0; idx < max; idx++) {
7783
+ if (idx % 4 === 0 && idx) {
7784
+ result.push(bits >> 16 & 255);
7785
+ result.push(bits >> 8 & 255);
7786
+ result.push(bits & 255);
7787
+ }
7788
+ bits = bits << 6 | map2.indexOf(input.charAt(idx));
7789
+ }
7790
+ const tailbits = max % 4 * 6;
7791
+ if (tailbits === 0) {
7792
+ result.push(bits >> 16 & 255);
7793
+ result.push(bits >> 8 & 255);
7794
+ result.push(bits & 255);
7795
+ } else if (tailbits === 18) {
7796
+ result.push(bits >> 10 & 255);
7797
+ result.push(bits >> 2 & 255);
7798
+ } else if (tailbits === 12) {
7799
+ result.push(bits >> 4 & 255);
7800
+ }
7801
+ return new Uint8Array(result);
7802
+ }
7803
+ function representYamlBinary(object) {
7804
+ let result = "";
7805
+ let bits = 0;
7806
+ const max = object.length;
7807
+ const map2 = BASE64_MAP;
7808
+ for (let idx = 0; idx < max; idx++) {
7809
+ if (idx % 3 === 0 && idx) {
7810
+ result += map2[bits >> 18 & 63];
7811
+ result += map2[bits >> 12 & 63];
7812
+ result += map2[bits >> 6 & 63];
7813
+ result += map2[bits & 63];
7814
+ }
7815
+ bits = (bits << 8) + object[idx];
7816
+ }
7817
+ const tail = max % 3;
7818
+ if (tail === 0) {
7819
+ result += map2[bits >> 18 & 63];
7820
+ result += map2[bits >> 12 & 63];
7821
+ result += map2[bits >> 6 & 63];
7822
+ result += map2[bits & 63];
7823
+ } else if (tail === 2) {
7824
+ result += map2[bits >> 10 & 63];
7825
+ result += map2[bits >> 4 & 63];
7826
+ result += map2[bits << 2 & 63];
7827
+ result += map2[64];
7828
+ } else if (tail === 1) {
7829
+ result += map2[bits >> 2 & 63];
7830
+ result += map2[bits << 4 & 63];
7831
+ result += map2[64];
7832
+ result += map2[64];
7833
+ }
7834
+ return result;
7835
+ }
7836
+ function isBinary(obj) {
7837
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
7838
+ }
7839
+ binary = new Type2("tag:yaml.org,2002:binary", {
7840
+ kind: "scalar",
7841
+ resolve: resolveYamlBinary,
7842
+ construct: constructYamlBinary,
7843
+ predicate: isBinary,
7844
+ represent: representYamlBinary
7845
+ });
7846
+ return binary;
7847
+ }
7848
+ var omap;
7849
+ var hasRequiredOmap;
7850
+ function requireOmap() {
7851
+ if (hasRequiredOmap) return omap;
7852
+ hasRequiredOmap = 1;
7853
+ const Type2 = requireType();
7854
+ const _hasOwnProperty = Object.prototype.hasOwnProperty;
7855
+ const _toString = Object.prototype.toString;
7856
+ function resolveYamlOmap(data) {
7857
+ if (data === null) return true;
7858
+ const objectKeys = {};
7859
+ const object = data;
7860
+ for (let index = 0, length = object.length; index < length; index += 1) {
7861
+ const pair = object[index];
7862
+ let pairHasKey = false;
7863
+ if (_toString.call(pair) !== "[object Object]") return false;
7864
+ let pairKey;
7865
+ for (pairKey in pair) {
7866
+ if (_hasOwnProperty.call(pair, pairKey)) {
7867
+ if (!pairHasKey) pairHasKey = true;
7868
+ else return false;
7869
+ }
7870
+ }
7871
+ if (!pairHasKey) return false;
7872
+ if (_hasOwnProperty.call(objectKeys, pairKey)) return false;
7873
+ Object.defineProperty(objectKeys, pairKey, { value: true });
7874
+ }
7875
+ return true;
7876
+ }
7877
+ function constructYamlOmap(data) {
7878
+ return data !== null ? data : [];
7879
+ }
7880
+ omap = new Type2("tag:yaml.org,2002:omap", {
7881
+ kind: "sequence",
7882
+ resolve: resolveYamlOmap,
7883
+ construct: constructYamlOmap
7884
+ });
7885
+ return omap;
7886
+ }
7887
+ var pairs;
7888
+ var hasRequiredPairs;
7889
+ function requirePairs() {
7890
+ if (hasRequiredPairs) return pairs;
7891
+ hasRequiredPairs = 1;
7892
+ const Type2 = requireType();
7893
+ const _toString = Object.prototype.toString;
7894
+ function resolveYamlPairs(data) {
7895
+ if (data === null) return true;
7896
+ const object = data;
7897
+ const result = new Array(object.length);
7898
+ for (let index = 0, length = object.length; index < length; index += 1) {
7899
+ const pair = object[index];
7900
+ if (_toString.call(pair) !== "[object Object]") return false;
7901
+ const keys = Object.keys(pair);
7902
+ if (keys.length !== 1) return false;
7903
+ result[index] = [keys[0], pair[keys[0]]];
7904
+ }
7905
+ return true;
7906
+ }
7907
+ function constructYamlPairs(data) {
7908
+ if (data === null) return [];
7909
+ const object = data;
7910
+ const result = new Array(object.length);
7911
+ for (let index = 0, length = object.length; index < length; index += 1) {
7912
+ const pair = object[index];
7913
+ const keys = Object.keys(pair);
7914
+ result[index] = [keys[0], pair[keys[0]]];
7915
+ }
7916
+ return result;
7917
+ }
7918
+ pairs = new Type2("tag:yaml.org,2002:pairs", {
7919
+ kind: "sequence",
7920
+ resolve: resolveYamlPairs,
7921
+ construct: constructYamlPairs
7922
+ });
7923
+ return pairs;
7924
+ }
7925
+ var set;
7926
+ var hasRequiredSet;
7927
+ function requireSet() {
7928
+ if (hasRequiredSet) return set;
7929
+ hasRequiredSet = 1;
7930
+ const Type2 = requireType();
7931
+ const _hasOwnProperty = Object.prototype.hasOwnProperty;
7932
+ function resolveYamlSet(data) {
7933
+ if (data === null) return true;
7934
+ const object = data;
7935
+ for (const key in object) {
7936
+ if (_hasOwnProperty.call(object, key)) {
7937
+ if (object[key] !== null) return false;
7938
+ }
7939
+ }
7940
+ return true;
7941
+ }
7942
+ function constructYamlSet(data) {
7943
+ return data !== null ? data : {};
7944
+ }
7945
+ set = new Type2("tag:yaml.org,2002:set", {
7946
+ kind: "mapping",
7947
+ resolve: resolveYamlSet,
7948
+ construct: constructYamlSet
7949
+ });
7950
+ return set;
7951
+ }
7952
+ var _default;
7953
+ var hasRequired_default;
7954
+ function require_default() {
7955
+ if (hasRequired_default) return _default;
7956
+ hasRequired_default = 1;
7957
+ _default = requireCore().extend({
7958
+ implicit: [
7959
+ requireTimestamp(),
7960
+ requireMerge()
7961
+ ],
7962
+ explicit: [
7963
+ requireBinary(),
7964
+ requireOmap(),
7965
+ requirePairs(),
7966
+ requireSet()
7967
+ ]
7968
+ });
7969
+ return _default;
7970
+ }
7971
+ var hasRequiredLoader;
7972
+ function requireLoader() {
7973
+ if (hasRequiredLoader) return loader;
7974
+ hasRequiredLoader = 1;
7975
+ const common2 = requireCommon();
7976
+ const YAMLException2 = requireException();
7977
+ const makeSnippet = requireSnippet();
7978
+ const DEFAULT_SCHEMA2 = require_default();
7979
+ const _hasOwnProperty = Object.prototype.hasOwnProperty;
7980
+ const CONTEXT_FLOW_IN = 1;
7981
+ const CONTEXT_FLOW_OUT = 2;
7982
+ const CONTEXT_BLOCK_IN = 3;
7983
+ const CONTEXT_BLOCK_OUT = 4;
7984
+ const CHOMPING_CLIP = 1;
7985
+ const CHOMPING_STRIP = 2;
7986
+ const CHOMPING_KEEP = 3;
7987
+ const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
7988
+ const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
7989
+ const PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
7990
+ const PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
7991
+ const PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;
7992
+ function _class(obj) {
7993
+ return Object.prototype.toString.call(obj);
7994
+ }
7995
+ function isEol(c) {
7996
+ return c === 10 || c === 13;
7997
+ }
7998
+ function isWhiteSpace(c) {
7999
+ return c === 9 || c === 32;
8000
+ }
8001
+ function isWsOrEol(c) {
8002
+ return c === 9 || c === 32 || c === 10 || c === 13;
8003
+ }
8004
+ function isFlowIndicator(c) {
8005
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
8006
+ }
8007
+ function fromHexCode(c) {
8008
+ if (c >= 48 && c <= 57) {
8009
+ return c - 48;
8010
+ }
8011
+ const lc = c | 32;
8012
+ if (lc >= 97 && lc <= 102) {
8013
+ return lc - 97 + 10;
8014
+ }
8015
+ return -1;
8016
+ }
8017
+ function escapedHexLen(c) {
8018
+ if (c === 120) {
8019
+ return 2;
8020
+ }
8021
+ if (c === 117) {
8022
+ return 4;
8023
+ }
8024
+ if (c === 85) {
8025
+ return 8;
8026
+ }
8027
+ return 0;
8028
+ }
8029
+ function fromDecimalCode(c) {
8030
+ if (c >= 48 && c <= 57) {
8031
+ return c - 48;
8032
+ }
8033
+ return -1;
8034
+ }
8035
+ function simpleEscapeSequence(c) {
8036
+ switch (c) {
8037
+ case 48:
8038
+ return "\0";
8039
+ case 97:
8040
+ return "\x07";
8041
+ case 98:
8042
+ return "\b";
8043
+ case 116:
8044
+ return " ";
8045
+ case 9:
8046
+ return " ";
8047
+ case 110:
8048
+ return "\n";
8049
+ case 118:
8050
+ return "\v";
8051
+ case 102:
8052
+ return "\f";
8053
+ case 114:
8054
+ return "\r";
8055
+ case 101:
8056
+ return "\x1B";
8057
+ case 32:
8058
+ return " ";
8059
+ case 34:
8060
+ return '"';
8061
+ case 47:
8062
+ return "/";
8063
+ case 92:
8064
+ return "\\";
8065
+ case 78:
8066
+ return "\x85";
8067
+ case 95:
8068
+ return "\xA0";
8069
+ case 76:
8070
+ return "\u2028";
8071
+ case 80:
8072
+ return "\u2029";
8073
+ default:
8074
+ return "";
8075
+ }
8076
+ }
8077
+ function charFromCodepoint(c) {
8078
+ if (c <= 65535) {
8079
+ return String.fromCharCode(c);
8080
+ }
8081
+ return String.fromCharCode(
8082
+ (c - 65536 >> 10) + 55296,
8083
+ (c - 65536 & 1023) + 56320
8084
+ );
8085
+ }
8086
+ function setProperty(object, key, value) {
8087
+ if (key === "__proto__") {
8088
+ Object.defineProperty(object, key, {
8089
+ configurable: true,
8090
+ enumerable: true,
8091
+ writable: true,
8092
+ value
8093
+ });
8094
+ } else {
8095
+ object[key] = value;
8096
+ }
8097
+ }
8098
+ const simpleEscapeCheck = new Array(256);
8099
+ const simpleEscapeMap = new Array(256);
8100
+ for (let i = 0; i < 256; i++) {
8101
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
8102
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
8103
+ }
8104
+ function State(input, options) {
8105
+ this.input = input;
8106
+ this.filename = options["filename"] || null;
8107
+ this.schema = options["schema"] || DEFAULT_SCHEMA2;
8108
+ this.onWarning = options["onWarning"] || null;
8109
+ this.legacy = options["legacy"] || false;
8110
+ this.json = options["json"] || false;
8111
+ this.listener = options["listener"] || null;
8112
+ this.maxDepth = typeof options["maxDepth"] === "number" ? options["maxDepth"] : 100;
8113
+ this.maxTotalMergeKeys = typeof options["maxTotalMergeKeys"] === "number" ? options["maxTotalMergeKeys"] : 1e4;
8114
+ this.implicitTypes = this.schema.compiledImplicit;
8115
+ this.typeMap = this.schema.compiledTypeMap;
8116
+ this.length = input.length;
8117
+ this.position = 0;
8118
+ this.line = 0;
8119
+ this.lineStart = 0;
8120
+ this.lineIndent = 0;
8121
+ this.depth = 0;
8122
+ this.totalMergeKeys = 0;
8123
+ this.firstTabInLine = -1;
8124
+ this.documents = [];
8125
+ this.anchorMapTransactions = [];
8126
+ }
8127
+ function generateError(state, message) {
8128
+ const mark = {
8129
+ name: state.filename,
8130
+ buffer: state.input.slice(0, -1),
8131
+ // omit trailing \0
8132
+ position: state.position,
8133
+ line: state.line,
8134
+ column: state.position - state.lineStart
8135
+ };
8136
+ mark.snippet = makeSnippet(mark);
8137
+ return new YAMLException2(message, mark);
8138
+ }
8139
+ function throwError(state, message) {
8140
+ throw generateError(state, message);
8141
+ }
8142
+ function throwWarning(state, message) {
8143
+ if (state.onWarning) {
8144
+ state.onWarning.call(null, generateError(state, message));
8145
+ }
8146
+ }
8147
+ function storeAnchor(state, name, value) {
8148
+ const transactions = state.anchorMapTransactions;
8149
+ if (transactions.length !== 0) {
8150
+ const transaction = transactions[transactions.length - 1];
8151
+ if (!_hasOwnProperty.call(transaction, name)) {
8152
+ transaction[name] = {
8153
+ existed: _hasOwnProperty.call(state.anchorMap, name),
8154
+ value: state.anchorMap[name]
8155
+ };
8156
+ }
8157
+ }
8158
+ state.anchorMap[name] = value;
8159
+ }
8160
+ function beginAnchorTransaction(state) {
8161
+ state.anchorMapTransactions.push(/* @__PURE__ */ Object.create(null));
8162
+ }
8163
+ function commitAnchorTransaction(state) {
8164
+ const transaction = state.anchorMapTransactions.pop();
8165
+ const transactions = state.anchorMapTransactions;
8166
+ if (transactions.length === 0) return;
8167
+ const parent = transactions[transactions.length - 1];
8168
+ const names = Object.keys(transaction);
8169
+ for (let index = 0, length = names.length; index < length; index += 1) {
8170
+ const name = names[index];
8171
+ if (!_hasOwnProperty.call(parent, name)) {
8172
+ parent[name] = transaction[name];
8173
+ }
8174
+ }
8175
+ }
8176
+ function rollbackAnchorTransaction(state) {
8177
+ const transaction = state.anchorMapTransactions.pop();
8178
+ const names = Object.keys(transaction);
8179
+ for (let index = names.length - 1; index >= 0; index -= 1) {
8180
+ const entry = transaction[names[index]];
8181
+ if (entry.existed) {
8182
+ state.anchorMap[names[index]] = entry.value;
8183
+ } else {
8184
+ delete state.anchorMap[names[index]];
8185
+ }
8186
+ }
8187
+ }
8188
+ function snapshotState(state) {
8189
+ return {
8190
+ position: state.position,
8191
+ line: state.line,
8192
+ lineStart: state.lineStart,
8193
+ lineIndent: state.lineIndent,
8194
+ firstTabInLine: state.firstTabInLine,
8195
+ tag: state.tag,
8196
+ anchor: state.anchor,
8197
+ kind: state.kind,
8198
+ result: state.result
8199
+ };
8200
+ }
8201
+ function restoreState(state, snapshot) {
8202
+ state.position = snapshot.position;
8203
+ state.line = snapshot.line;
8204
+ state.lineStart = snapshot.lineStart;
8205
+ state.lineIndent = snapshot.lineIndent;
8206
+ state.firstTabInLine = snapshot.firstTabInLine;
8207
+ state.tag = snapshot.tag;
8208
+ state.anchor = snapshot.anchor;
8209
+ state.kind = snapshot.kind;
8210
+ state.result = snapshot.result;
8211
+ }
8212
+ const directiveHandlers = {
8213
+ YAML: function handleYamlDirective(state, name, args) {
8214
+ if (state.version !== null) {
8215
+ throwError(state, "duplication of %YAML directive");
8216
+ }
8217
+ if (args.length !== 1) {
8218
+ throwError(state, "YAML directive accepts exactly one argument");
8219
+ }
8220
+ const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
8221
+ if (match === null) {
8222
+ throwError(state, "ill-formed argument of the YAML directive");
8223
+ }
8224
+ const major = parseInt(match[1], 10);
8225
+ const minor = parseInt(match[2], 10);
8226
+ if (major !== 1) {
8227
+ throwError(state, "unacceptable YAML version of the document");
8228
+ }
8229
+ state.version = args[0];
8230
+ state.checkLineBreaks = minor < 2;
8231
+ if (minor !== 1 && minor !== 2) {
8232
+ throwWarning(state, "unsupported YAML version of the document");
8233
+ }
8234
+ },
8235
+ TAG: function handleTagDirective(state, name, args) {
8236
+ let prefix;
8237
+ if (args.length !== 2) {
8238
+ throwError(state, "TAG directive accepts exactly two arguments");
8239
+ }
8240
+ const handle = args[0];
8241
+ prefix = args[1];
8242
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
8243
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
8244
+ }
8245
+ if (_hasOwnProperty.call(state.tagMap, handle)) {
8246
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
8247
+ }
8248
+ if (!PATTERN_TAG_URI.test(prefix)) {
8249
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
8250
+ }
8251
+ try {
8252
+ prefix = decodeURIComponent(prefix);
8253
+ } catch (err) {
8254
+ throwError(state, "tag prefix is malformed: " + prefix);
8255
+ }
8256
+ state.tagMap[handle] = prefix;
8257
+ }
8258
+ };
8259
+ function captureSegment(state, start, end, checkJson) {
8260
+ if (start < end) {
8261
+ const _result = state.input.slice(start, end);
8262
+ if (checkJson) {
8263
+ for (let _position = 0, _length = _result.length; _position < _length; _position += 1) {
8264
+ const _character = _result.charCodeAt(_position);
8265
+ if (!(_character === 9 || _character >= 32 && _character <= 1114111)) {
8266
+ throwError(state, "expected valid JSON character");
8267
+ }
8268
+ }
8269
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
8270
+ throwError(state, "the stream contains non-printable characters");
8271
+ }
8272
+ state.result += _result;
8273
+ }
8274
+ }
8275
+ function chargeMergeWork(state) {
8276
+ state.totalMergeKeys++;
8277
+ if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) {
8278
+ throwError(state, "merge keys exceeded maxTotalMergeKeys (" + state.maxTotalMergeKeys + ")");
8279
+ }
8280
+ }
8281
+ function mergeMappings(state, destination, source, overridableKeys) {
8282
+ if (!common2.isObject(source)) {
8283
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
8284
+ }
8285
+ chargeMergeWork(state);
8286
+ const sourceKeys = Object.keys(source);
8287
+ for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
8288
+ const key = sourceKeys[index];
8289
+ chargeMergeWork(state);
8290
+ if (!_hasOwnProperty.call(destination, key)) {
8291
+ setProperty(destination, key, source[key]);
8292
+ overridableKeys[key] = true;
8293
+ }
8294
+ }
8295
+ }
8296
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
8297
+ if (Array.isArray(keyNode)) {
8298
+ keyNode = Array.prototype.slice.call(keyNode);
8299
+ for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) {
8300
+ if (Array.isArray(keyNode[index])) {
8301
+ throwError(state, "nested arrays are not supported inside keys");
8302
+ }
8303
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
8304
+ keyNode[index] = "[object Object]";
8305
+ }
8306
+ }
8307
+ }
8308
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
8309
+ keyNode = "[object Object]";
8310
+ }
8311
+ keyNode = String(keyNode);
8312
+ if (_result === null) {
8313
+ _result = {};
8314
+ }
8315
+ if (keyTag === "tag:yaml.org,2002:merge") {
8316
+ if (Array.isArray(valueNode)) {
8317
+ if (valueNode.length > 100) {
8318
+ throwError(state, "abnormal merge sequence size");
8319
+ }
8320
+ for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
8321
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
8322
+ }
8323
+ } else {
8324
+ mergeMappings(state, _result, valueNode, overridableKeys);
8325
+ }
8326
+ } else {
8327
+ if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
8328
+ state.line = startLine || state.line;
8329
+ state.lineStart = startLineStart || state.lineStart;
8330
+ state.position = startPos || state.position;
8331
+ throwError(state, "duplicated mapping key");
8332
+ }
8333
+ setProperty(_result, keyNode, valueNode);
8334
+ delete overridableKeys[keyNode];
8335
+ }
8336
+ return _result;
8337
+ }
8338
+ function readLineBreak(state) {
8339
+ const ch = state.input.charCodeAt(state.position);
8340
+ if (ch === 10) {
8341
+ state.position++;
8342
+ } else if (ch === 13) {
8343
+ state.position++;
8344
+ if (state.input.charCodeAt(state.position) === 10) {
8345
+ state.position++;
8346
+ }
8347
+ } else {
8348
+ throwError(state, "a line break is expected");
8349
+ }
8350
+ state.line += 1;
8351
+ state.lineStart = state.position;
8352
+ state.firstTabInLine = -1;
8353
+ }
8354
+ function skipSeparationSpace(state, allowComments, checkIndent) {
8355
+ let lineBreaks = 0;
8356
+ let ch = state.input.charCodeAt(state.position);
8357
+ while (ch !== 0) {
8358
+ while (isWhiteSpace(ch)) {
8359
+ if (ch === 9 && state.firstTabInLine === -1) {
8360
+ state.firstTabInLine = state.position;
8361
+ }
8362
+ ch = state.input.charCodeAt(++state.position);
8363
+ }
8364
+ if (allowComments && ch === 35) {
8365
+ do {
8366
+ ch = state.input.charCodeAt(++state.position);
8367
+ } while (ch !== 10 && ch !== 13 && ch !== 0);
8368
+ }
8369
+ if (isEol(ch)) {
8370
+ readLineBreak(state);
8371
+ ch = state.input.charCodeAt(state.position);
8372
+ lineBreaks++;
8373
+ state.lineIndent = 0;
8374
+ while (ch === 32) {
8375
+ state.lineIndent++;
8376
+ ch = state.input.charCodeAt(++state.position);
8377
+ }
8378
+ } else {
8379
+ break;
8380
+ }
8381
+ }
8382
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
8383
+ throwWarning(state, "deficient indentation");
8384
+ }
8385
+ return lineBreaks;
8386
+ }
8387
+ function testDocumentSeparator(state) {
8388
+ let _position = state.position;
8389
+ let ch = state.input.charCodeAt(_position);
8390
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
8391
+ _position += 3;
8392
+ ch = state.input.charCodeAt(_position);
8393
+ if (ch === 0 || isWsOrEol(ch)) {
8394
+ return true;
8395
+ }
8396
+ }
8397
+ return false;
8398
+ }
8399
+ function writeFoldedLines(state, count) {
8400
+ if (count === 1) {
8401
+ state.result += " ";
8402
+ } else if (count > 1) {
8403
+ state.result += common2.repeat("\n", count - 1);
8404
+ }
8405
+ }
8406
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
8407
+ let captureStart;
8408
+ let captureEnd;
8409
+ let hasPendingContent;
8410
+ let _line;
8411
+ let _lineStart;
8412
+ let _lineIndent;
8413
+ const _kind = state.kind;
8414
+ const _result = state.result;
8415
+ let ch = state.input.charCodeAt(state.position);
8416
+ if (isWsOrEol(ch) || isFlowIndicator(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
8417
+ return false;
8418
+ }
8419
+ if (ch === 63 || ch === 45) {
8420
+ const following = state.input.charCodeAt(state.position + 1);
8421
+ if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) {
8422
+ return false;
8423
+ }
8424
+ }
8425
+ state.kind = "scalar";
8426
+ state.result = "";
8427
+ captureStart = captureEnd = state.position;
8428
+ hasPendingContent = false;
8429
+ while (ch !== 0) {
8430
+ if (ch === 58) {
8431
+ const following = state.input.charCodeAt(state.position + 1);
8432
+ if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) {
8433
+ break;
8434
+ }
8435
+ } else if (ch === 35) {
8436
+ const preceding = state.input.charCodeAt(state.position - 1);
8437
+ if (isWsOrEol(preceding)) {
8438
+ break;
8439
+ }
8440
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && isFlowIndicator(ch)) {
8441
+ break;
8442
+ } else if (isEol(ch)) {
8443
+ _line = state.line;
8444
+ _lineStart = state.lineStart;
8445
+ _lineIndent = state.lineIndent;
8446
+ skipSeparationSpace(state, false, -1);
8447
+ if (state.lineIndent >= nodeIndent) {
8448
+ hasPendingContent = true;
8449
+ ch = state.input.charCodeAt(state.position);
8450
+ continue;
8451
+ } else {
8452
+ state.position = captureEnd;
8453
+ state.line = _line;
8454
+ state.lineStart = _lineStart;
8455
+ state.lineIndent = _lineIndent;
8456
+ break;
8457
+ }
8458
+ }
8459
+ if (hasPendingContent) {
8460
+ captureSegment(state, captureStart, captureEnd, false);
8461
+ writeFoldedLines(state, state.line - _line);
8462
+ captureStart = captureEnd = state.position;
8463
+ hasPendingContent = false;
8464
+ }
8465
+ if (!isWhiteSpace(ch)) {
8466
+ captureEnd = state.position + 1;
8467
+ }
8468
+ ch = state.input.charCodeAt(++state.position);
8469
+ }
8470
+ captureSegment(state, captureStart, captureEnd, false);
8471
+ if (state.result) {
8472
+ return true;
8473
+ }
8474
+ state.kind = _kind;
8475
+ state.result = _result;
8476
+ return false;
8477
+ }
8478
+ function readSingleQuotedScalar(state, nodeIndent) {
8479
+ let captureStart;
8480
+ let captureEnd;
8481
+ let ch = state.input.charCodeAt(state.position);
8482
+ if (ch !== 39) {
8483
+ return false;
8484
+ }
8485
+ state.kind = "scalar";
8486
+ state.result = "";
8487
+ state.position++;
8488
+ captureStart = captureEnd = state.position;
8489
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
8490
+ if (ch === 39) {
8491
+ captureSegment(state, captureStart, state.position, true);
8492
+ ch = state.input.charCodeAt(++state.position);
8493
+ if (ch === 39) {
8494
+ captureStart = state.position;
8495
+ state.position++;
8496
+ captureEnd = state.position;
8497
+ } else {
8498
+ return true;
8499
+ }
8500
+ } else if (isEol(ch)) {
8501
+ captureSegment(state, captureStart, captureEnd, true);
8502
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
8503
+ captureStart = captureEnd = state.position;
8504
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
8505
+ throwError(state, "unexpected end of the document within a single quoted scalar");
8506
+ } else {
8507
+ state.position++;
8508
+ if (!isWhiteSpace(ch)) {
8509
+ captureEnd = state.position;
8510
+ }
8511
+ }
8512
+ }
8513
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
8514
+ }
8515
+ function readDoubleQuotedScalar(state, nodeIndent) {
8516
+ let captureStart;
8517
+ let captureEnd;
8518
+ let tmp;
8519
+ let ch = state.input.charCodeAt(state.position);
8520
+ if (ch !== 34) {
8521
+ return false;
8522
+ }
8523
+ state.kind = "scalar";
8524
+ state.result = "";
8525
+ state.position++;
8526
+ captureStart = captureEnd = state.position;
8527
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
8528
+ if (ch === 34) {
8529
+ captureSegment(state, captureStart, state.position, true);
8530
+ state.position++;
8531
+ return true;
8532
+ } else if (ch === 92) {
8533
+ captureSegment(state, captureStart, state.position, true);
8534
+ ch = state.input.charCodeAt(++state.position);
8535
+ if (isEol(ch)) {
8536
+ skipSeparationSpace(state, false, nodeIndent);
8537
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
8538
+ state.result += simpleEscapeMap[ch];
8539
+ state.position++;
8540
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
8541
+ let hexLength = tmp;
8542
+ let hexResult = 0;
8543
+ for (; hexLength > 0; hexLength--) {
8544
+ ch = state.input.charCodeAt(++state.position);
8545
+ if ((tmp = fromHexCode(ch)) >= 0) {
8546
+ hexResult = (hexResult << 4) + tmp;
8547
+ } else {
8548
+ throwError(state, "expected hexadecimal character");
8549
+ }
8550
+ }
8551
+ state.result += charFromCodepoint(hexResult);
8552
+ state.position++;
8553
+ } else {
8554
+ throwError(state, "unknown escape sequence");
8555
+ }
8556
+ captureStart = captureEnd = state.position;
8557
+ } else if (isEol(ch)) {
8558
+ captureSegment(state, captureStart, captureEnd, true);
8559
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
8560
+ captureStart = captureEnd = state.position;
8561
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
8562
+ throwError(state, "unexpected end of the document within a double quoted scalar");
8563
+ } else {
8564
+ state.position++;
8565
+ if (!isWhiteSpace(ch)) {
8566
+ captureEnd = state.position;
8567
+ }
8568
+ }
8569
+ }
8570
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
8571
+ }
8572
+ function readFlowCollection(state, nodeIndent) {
8573
+ let readNext = true;
8574
+ let _line;
8575
+ let _lineStart;
8576
+ let _pos;
8577
+ const _tag = state.tag;
8578
+ let _result;
8579
+ const _anchor = state.anchor;
8580
+ let terminator;
8581
+ let isPair;
8582
+ let isExplicitPair;
8583
+ let isMapping;
8584
+ const overridableKeys = /* @__PURE__ */ Object.create(null);
8585
+ let keyNode;
8586
+ let keyTag;
8587
+ let valueNode;
8588
+ let ch = state.input.charCodeAt(state.position);
8589
+ if (ch === 91) {
8590
+ terminator = 93;
8591
+ isMapping = false;
8592
+ _result = [];
8593
+ } else if (ch === 123) {
8594
+ terminator = 125;
8595
+ isMapping = true;
8596
+ _result = {};
8597
+ } else {
8598
+ return false;
8599
+ }
8600
+ if (state.anchor !== null) {
8601
+ storeAnchor(state, state.anchor, _result);
8602
+ }
8603
+ ch = state.input.charCodeAt(++state.position);
8604
+ while (ch !== 0) {
8605
+ skipSeparationSpace(state, true, nodeIndent);
8606
+ ch = state.input.charCodeAt(state.position);
8607
+ if (ch === terminator) {
8608
+ state.position++;
8609
+ state.tag = _tag;
8610
+ state.anchor = _anchor;
8611
+ state.kind = isMapping ? "mapping" : "sequence";
8612
+ state.result = _result;
8613
+ return true;
8614
+ } else if (!readNext) {
8615
+ throwError(state, "missed comma between flow collection entries");
8616
+ } else if (ch === 44) {
8617
+ throwError(state, "expected the node content, but found ','");
8618
+ }
8619
+ keyTag = keyNode = valueNode = null;
8620
+ isPair = isExplicitPair = false;
8621
+ if (ch === 63) {
8622
+ const following = state.input.charCodeAt(state.position + 1);
8623
+ if (isWsOrEol(following)) {
8624
+ isPair = isExplicitPair = true;
8625
+ state.position++;
8626
+ skipSeparationSpace(state, true, nodeIndent);
8627
+ }
8628
+ }
8629
+ _line = state.line;
8630
+ _lineStart = state.lineStart;
8631
+ _pos = state.position;
8632
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
8633
+ keyTag = state.tag;
8634
+ keyNode = state.result;
8635
+ skipSeparationSpace(state, true, nodeIndent);
8636
+ ch = state.input.charCodeAt(state.position);
8637
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
8638
+ isPair = true;
8639
+ ch = state.input.charCodeAt(++state.position);
8640
+ skipSeparationSpace(state, true, nodeIndent);
8641
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
8642
+ valueNode = state.result;
8643
+ }
8644
+ if (isMapping) {
8645
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
8646
+ } else if (isPair) {
8647
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
8648
+ } else {
8649
+ _result.push(keyNode);
8650
+ }
8651
+ skipSeparationSpace(state, true, nodeIndent);
8652
+ ch = state.input.charCodeAt(state.position);
8653
+ if (ch === 44) {
8654
+ readNext = true;
8655
+ ch = state.input.charCodeAt(++state.position);
8656
+ } else {
8657
+ readNext = false;
8658
+ }
8659
+ }
8660
+ throwError(state, "unexpected end of the stream within a flow collection");
8661
+ }
8662
+ function readBlockScalar(state, nodeIndent) {
8663
+ let folding;
8664
+ let chomping = CHOMPING_CLIP;
8665
+ let didReadContent = false;
8666
+ let detectedIndent = false;
8667
+ let textIndent = nodeIndent;
8668
+ let emptyLines = 0;
8669
+ let atMoreIndented = false;
8670
+ let tmp;
8671
+ let ch = state.input.charCodeAt(state.position);
8672
+ if (ch === 124) {
8673
+ folding = false;
8674
+ } else if (ch === 62) {
8675
+ folding = true;
8676
+ } else {
8677
+ return false;
8678
+ }
8679
+ state.kind = "scalar";
8680
+ state.result = "";
8681
+ while (ch !== 0) {
8682
+ ch = state.input.charCodeAt(++state.position);
8683
+ if (ch === 43 || ch === 45) {
8684
+ if (CHOMPING_CLIP === chomping) {
8685
+ chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
8686
+ } else {
8687
+ throwError(state, "repeat of a chomping mode identifier");
8688
+ }
8689
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
8690
+ if (tmp === 0) {
8691
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
8692
+ } else if (!detectedIndent) {
8693
+ textIndent = nodeIndent + tmp - 1;
8694
+ detectedIndent = true;
8695
+ } else {
8696
+ throwError(state, "repeat of an indentation width identifier");
8697
+ }
8698
+ } else {
8699
+ break;
8700
+ }
8701
+ }
8702
+ if (isWhiteSpace(ch)) {
8703
+ do {
8704
+ ch = state.input.charCodeAt(++state.position);
8705
+ } while (isWhiteSpace(ch));
8706
+ if (ch === 35) {
8707
+ do {
8708
+ ch = state.input.charCodeAt(++state.position);
8709
+ } while (!isEol(ch) && ch !== 0);
8710
+ }
8711
+ }
8712
+ while (ch !== 0) {
8713
+ readLineBreak(state);
8714
+ state.lineIndent = 0;
8715
+ ch = state.input.charCodeAt(state.position);
8716
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
8717
+ state.lineIndent++;
8718
+ ch = state.input.charCodeAt(++state.position);
8719
+ }
8720
+ if (!detectedIndent && state.lineIndent > textIndent) {
8721
+ textIndent = state.lineIndent;
8722
+ }
8723
+ if (isEol(ch)) {
8724
+ emptyLines++;
8725
+ continue;
8726
+ }
8727
+ if (!detectedIndent && textIndent === 0) {
8728
+ throwError(state, "missing indentation for block scalar");
8729
+ }
8730
+ if (state.lineIndent < textIndent) {
8731
+ if (chomping === CHOMPING_KEEP) {
8732
+ state.result += common2.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
8733
+ } else if (chomping === CHOMPING_CLIP) {
8734
+ if (didReadContent) {
8735
+ state.result += "\n";
8736
+ }
8737
+ }
8738
+ break;
8739
+ }
8740
+ if (folding) {
8741
+ if (isWhiteSpace(ch)) {
8742
+ atMoreIndented = true;
8743
+ state.result += common2.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
8744
+ } else if (atMoreIndented) {
8745
+ atMoreIndented = false;
8746
+ state.result += common2.repeat("\n", emptyLines + 1);
8747
+ } else if (emptyLines === 0) {
8748
+ if (didReadContent) {
8749
+ state.result += " ";
8750
+ }
8751
+ } else {
8752
+ state.result += common2.repeat("\n", emptyLines);
8753
+ }
8754
+ } else {
8755
+ state.result += common2.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
8756
+ }
8757
+ didReadContent = true;
8758
+ detectedIndent = true;
8759
+ emptyLines = 0;
8760
+ const captureStart = state.position;
8761
+ while (!isEol(ch) && ch !== 0) {
8762
+ ch = state.input.charCodeAt(++state.position);
8763
+ }
8764
+ captureSegment(state, captureStart, state.position, false);
8765
+ }
8766
+ return true;
8767
+ }
8768
+ function readBlockSequence(state, nodeIndent) {
8769
+ const _tag = state.tag;
8770
+ const _anchor = state.anchor;
8771
+ const _result = [];
8772
+ let detected = false;
8773
+ if (state.firstTabInLine !== -1) return false;
8774
+ if (state.anchor !== null) {
8775
+ storeAnchor(state, state.anchor, _result);
8776
+ }
8777
+ let ch = state.input.charCodeAt(state.position);
8778
+ while (ch !== 0) {
8779
+ if (state.firstTabInLine !== -1) {
8780
+ state.position = state.firstTabInLine;
8781
+ throwError(state, "tab characters must not be used in indentation");
8782
+ }
8783
+ if (ch !== 45) {
8784
+ break;
8785
+ }
8786
+ const following = state.input.charCodeAt(state.position + 1);
8787
+ if (!isWsOrEol(following)) {
8788
+ break;
8789
+ }
8790
+ detected = true;
8791
+ state.position++;
8792
+ if (skipSeparationSpace(state, true, -1)) {
8793
+ if (state.lineIndent <= nodeIndent) {
8794
+ _result.push(null);
8795
+ ch = state.input.charCodeAt(state.position);
8796
+ continue;
8797
+ }
8798
+ }
8799
+ const _line = state.line;
8800
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
8801
+ _result.push(state.result);
8802
+ skipSeparationSpace(state, true, -1);
8803
+ ch = state.input.charCodeAt(state.position);
8804
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
8805
+ throwError(state, "bad indentation of a sequence entry");
8806
+ } else if (state.lineIndent < nodeIndent) {
8807
+ break;
8808
+ }
8809
+ }
8810
+ if (detected) {
8811
+ state.tag = _tag;
8812
+ state.anchor = _anchor;
8813
+ state.kind = "sequence";
8814
+ state.result = _result;
8815
+ return true;
8816
+ }
8817
+ return false;
8818
+ }
8819
+ function readBlockMapping(state, nodeIndent, flowIndent) {
8820
+ let allowCompact;
8821
+ let _keyLine;
8822
+ let _keyLineStart;
8823
+ let _keyPos;
8824
+ const _tag = state.tag;
8825
+ const _anchor = state.anchor;
8826
+ const _result = {};
8827
+ const overridableKeys = /* @__PURE__ */ Object.create(null);
8828
+ let keyTag = null;
8829
+ let keyNode = null;
8830
+ let valueNode = null;
8831
+ let atExplicitKey = false;
8832
+ let detected = false;
8833
+ if (state.firstTabInLine !== -1) return false;
8834
+ if (state.anchor !== null) {
8835
+ storeAnchor(state, state.anchor, _result);
8836
+ }
8837
+ let ch = state.input.charCodeAt(state.position);
8838
+ while (ch !== 0) {
8839
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
8840
+ state.position = state.firstTabInLine;
8841
+ throwError(state, "tab characters must not be used in indentation");
8842
+ }
8843
+ const following = state.input.charCodeAt(state.position + 1);
8844
+ const _line = state.line;
8845
+ if ((ch === 63 || ch === 58) && isWsOrEol(following)) {
8846
+ if (ch === 63) {
8847
+ if (atExplicitKey) {
8848
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
8849
+ keyTag = keyNode = valueNode = null;
8850
+ }
8851
+ detected = true;
8852
+ atExplicitKey = true;
8853
+ allowCompact = true;
8854
+ } else if (atExplicitKey) {
8855
+ atExplicitKey = false;
8856
+ allowCompact = true;
8857
+ } else {
8858
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
8859
+ }
8860
+ state.position += 1;
8861
+ ch = following;
8862
+ } else {
8863
+ _keyLine = state.line;
8864
+ _keyLineStart = state.lineStart;
8865
+ _keyPos = state.position;
8866
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
8867
+ break;
8868
+ }
8869
+ if (state.line === _line) {
8870
+ ch = state.input.charCodeAt(state.position);
8871
+ while (isWhiteSpace(ch)) {
8872
+ ch = state.input.charCodeAt(++state.position);
8873
+ }
8874
+ if (ch === 58) {
8875
+ ch = state.input.charCodeAt(++state.position);
8876
+ if (!isWsOrEol(ch)) {
8877
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
8878
+ }
8879
+ if (atExplicitKey) {
8880
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
8881
+ keyTag = keyNode = valueNode = null;
8882
+ }
8883
+ detected = true;
8884
+ atExplicitKey = false;
8885
+ allowCompact = false;
8886
+ keyTag = state.tag;
8887
+ keyNode = state.result;
8888
+ } else if (detected) {
8889
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
8890
+ } else {
8891
+ state.tag = _tag;
8892
+ state.anchor = _anchor;
8893
+ return true;
8894
+ }
8895
+ } else if (detected) {
8896
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
8897
+ } else {
8898
+ state.tag = _tag;
8899
+ state.anchor = _anchor;
8900
+ return true;
8901
+ }
8902
+ }
8903
+ if (state.line === _line || state.lineIndent > nodeIndent) {
8904
+ if (atExplicitKey) {
8905
+ _keyLine = state.line;
8906
+ _keyLineStart = state.lineStart;
8907
+ _keyPos = state.position;
8908
+ }
8909
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
8910
+ if (atExplicitKey) {
8911
+ keyNode = state.result;
8912
+ } else {
8913
+ valueNode = state.result;
8914
+ }
8915
+ }
8916
+ if (!atExplicitKey) {
8917
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
8918
+ keyTag = keyNode = valueNode = null;
8919
+ }
8920
+ skipSeparationSpace(state, true, -1);
8921
+ ch = state.input.charCodeAt(state.position);
8922
+ }
8923
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
8924
+ throwError(state, "bad indentation of a mapping entry");
8925
+ } else if (state.lineIndent < nodeIndent) {
8926
+ break;
8927
+ }
8928
+ }
8929
+ if (atExplicitKey) {
8930
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
8931
+ }
8932
+ if (detected) {
8933
+ state.tag = _tag;
8934
+ state.anchor = _anchor;
8935
+ state.kind = "mapping";
8936
+ state.result = _result;
8937
+ }
8938
+ return detected;
8939
+ }
8940
+ function readTagProperty(state) {
8941
+ let isVerbatim = false;
8942
+ let isNamed = false;
8943
+ let tagHandle;
8944
+ let tagName;
8945
+ let ch = state.input.charCodeAt(state.position);
8946
+ if (ch !== 33) return false;
8947
+ if (state.tag !== null) {
8948
+ throwError(state, "duplication of a tag property");
8949
+ }
8950
+ ch = state.input.charCodeAt(++state.position);
8951
+ if (ch === 60) {
8952
+ isVerbatim = true;
8953
+ ch = state.input.charCodeAt(++state.position);
8954
+ } else if (ch === 33) {
8955
+ isNamed = true;
8956
+ tagHandle = "!!";
8957
+ ch = state.input.charCodeAt(++state.position);
8958
+ } else {
8959
+ tagHandle = "!";
8960
+ }
8961
+ let _position = state.position;
8962
+ if (isVerbatim) {
8963
+ do {
8964
+ ch = state.input.charCodeAt(++state.position);
8965
+ } while (ch !== 0 && ch !== 62);
8966
+ if (state.position < state.length) {
8967
+ tagName = state.input.slice(_position, state.position);
8968
+ ch = state.input.charCodeAt(++state.position);
8969
+ } else {
8970
+ throwError(state, "unexpected end of the stream within a verbatim tag");
8971
+ }
8972
+ } else {
8973
+ while (ch !== 0 && !isWsOrEol(ch)) {
8974
+ if (ch === 33) {
8975
+ if (!isNamed) {
8976
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
8977
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
8978
+ throwError(state, "named tag handle cannot contain such characters");
8979
+ }
8980
+ isNamed = true;
8981
+ _position = state.position + 1;
8982
+ } else {
8983
+ throwError(state, "tag suffix cannot contain exclamation marks");
8984
+ }
8985
+ }
8986
+ ch = state.input.charCodeAt(++state.position);
8987
+ }
8988
+ tagName = state.input.slice(_position, state.position);
8989
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
8990
+ throwError(state, "tag suffix cannot contain flow indicator characters");
8991
+ }
8992
+ }
8993
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
8994
+ throwError(state, "tag name cannot contain such characters: " + tagName);
8995
+ }
8996
+ try {
8997
+ tagName = decodeURIComponent(tagName);
8998
+ } catch (err) {
8999
+ throwError(state, "tag name is malformed: " + tagName);
9000
+ }
9001
+ if (isVerbatim) {
9002
+ state.tag = tagName;
9003
+ } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
9004
+ state.tag = state.tagMap[tagHandle] + tagName;
9005
+ } else if (tagHandle === "!") {
9006
+ state.tag = "!" + tagName;
9007
+ } else if (tagHandle === "!!") {
9008
+ state.tag = "tag:yaml.org,2002:" + tagName;
9009
+ } else {
9010
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
9011
+ }
9012
+ return true;
9013
+ }
9014
+ function readAnchorProperty(state) {
9015
+ let ch = state.input.charCodeAt(state.position);
9016
+ if (ch !== 38) return false;
9017
+ if (state.anchor !== null) {
9018
+ throwError(state, "duplication of an anchor property");
9019
+ }
9020
+ ch = state.input.charCodeAt(++state.position);
9021
+ const _position = state.position;
9022
+ while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) {
9023
+ ch = state.input.charCodeAt(++state.position);
9024
+ }
9025
+ if (state.position === _position) {
9026
+ throwError(state, "name of an anchor node must contain at least one character");
9027
+ }
9028
+ state.anchor = state.input.slice(_position, state.position);
9029
+ return true;
9030
+ }
9031
+ function readAlias(state) {
9032
+ let ch = state.input.charCodeAt(state.position);
9033
+ if (ch !== 42) return false;
9034
+ ch = state.input.charCodeAt(++state.position);
9035
+ const _position = state.position;
9036
+ while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) {
9037
+ ch = state.input.charCodeAt(++state.position);
9038
+ }
9039
+ if (state.position === _position) {
9040
+ throwError(state, "name of an alias node must contain at least one character");
9041
+ }
9042
+ const alias = state.input.slice(_position, state.position);
9043
+ if (!_hasOwnProperty.call(state.anchorMap, alias)) {
9044
+ throwError(state, 'unidentified alias "' + alias + '"');
9045
+ }
9046
+ state.result = state.anchorMap[alias];
9047
+ skipSeparationSpace(state, true, -1);
9048
+ return true;
9049
+ }
9050
+ function tryReadBlockMappingFromProperty(state, propertyStart, nodeIndent, flowIndent) {
9051
+ const fallbackState = snapshotState(state);
9052
+ beginAnchorTransaction(state);
9053
+ restoreState(state, propertyStart);
9054
+ state.tag = null;
9055
+ state.anchor = null;
9056
+ state.kind = null;
9057
+ state.result = null;
9058
+ if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === "mapping") {
9059
+ commitAnchorTransaction(state);
9060
+ return true;
9061
+ }
9062
+ rollbackAnchorTransaction(state);
9063
+ restoreState(state, fallbackState);
9064
+ return false;
9065
+ }
9066
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
9067
+ let allowBlockScalars;
9068
+ let allowBlockCollections;
9069
+ let indentStatus = 1;
9070
+ let atNewLine = false;
9071
+ let hasContent = false;
9072
+ let propertyStart = null;
9073
+ let type2;
9074
+ let flowIndent;
9075
+ let blockIndent;
9076
+ if (state.depth >= state.maxDepth) {
9077
+ throwError(state, "nesting exceeded maxDepth (" + state.maxDepth + ")");
9078
+ }
9079
+ state.depth += 1;
9080
+ if (state.listener !== null) {
9081
+ state.listener("open", state);
9082
+ }
9083
+ state.tag = null;
9084
+ state.anchor = null;
9085
+ state.kind = null;
9086
+ state.result = null;
9087
+ const allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
9088
+ if (allowToSeek) {
9089
+ if (skipSeparationSpace(state, true, -1)) {
9090
+ atNewLine = true;
9091
+ if (state.lineIndent > parentIndent) {
9092
+ indentStatus = 1;
9093
+ } else if (state.lineIndent === parentIndent) {
9094
+ indentStatus = 0;
9095
+ } else if (state.lineIndent < parentIndent) {
9096
+ indentStatus = -1;
9097
+ }
9098
+ }
9099
+ }
9100
+ if (indentStatus === 1) {
9101
+ while (true) {
9102
+ const ch = state.input.charCodeAt(state.position);
9103
+ const propertyState = snapshotState(state);
9104
+ if (atNewLine && (ch === 33 && state.tag !== null || ch === 38 && state.anchor !== null)) {
9105
+ break;
9106
+ }
9107
+ if (!readTagProperty(state) && !readAnchorProperty(state)) {
9108
+ break;
9109
+ }
9110
+ if (propertyStart === null) {
9111
+ propertyStart = propertyState;
9112
+ }
9113
+ if (skipSeparationSpace(state, true, -1)) {
9114
+ atNewLine = true;
9115
+ allowBlockCollections = allowBlockStyles;
9116
+ if (state.lineIndent > parentIndent) {
9117
+ indentStatus = 1;
9118
+ } else if (state.lineIndent === parentIndent) {
9119
+ indentStatus = 0;
9120
+ } else if (state.lineIndent < parentIndent) {
9121
+ indentStatus = -1;
9122
+ }
9123
+ } else {
9124
+ allowBlockCollections = false;
9125
+ }
9126
+ }
9127
+ }
9128
+ if (allowBlockCollections) {
9129
+ allowBlockCollections = atNewLine || allowCompact;
9130
+ }
9131
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
9132
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
9133
+ flowIndent = parentIndent;
9134
+ } else {
9135
+ flowIndent = parentIndent + 1;
9136
+ }
9137
+ blockIndent = state.position - state.lineStart;
9138
+ if (indentStatus === 1) {
9139
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
9140
+ hasContent = true;
9141
+ } else {
9142
+ const ch = state.input.charCodeAt(state.position);
9143
+ if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62 && tryReadBlockMappingFromProperty(
9144
+ state,
9145
+ propertyStart,
9146
+ propertyStart.position - propertyStart.lineStart,
9147
+ flowIndent
9148
+ )) {
9149
+ hasContent = true;
9150
+ } else if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
9151
+ hasContent = true;
9152
+ } else if (readAlias(state)) {
9153
+ hasContent = true;
9154
+ if (state.tag !== null || state.anchor !== null) {
9155
+ throwError(state, "alias node should not have any properties");
9156
+ }
9157
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
9158
+ hasContent = true;
9159
+ if (state.tag === null) {
9160
+ state.tag = "?";
9161
+ }
9162
+ }
9163
+ if (state.anchor !== null) {
9164
+ storeAnchor(state, state.anchor, state.result);
9165
+ }
9166
+ }
9167
+ } else if (indentStatus === 0) {
9168
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
9169
+ }
9170
+ }
9171
+ if (state.tag === null) {
9172
+ if (state.anchor !== null) {
9173
+ storeAnchor(state, state.anchor, state.result);
9174
+ }
9175
+ } else if (state.tag === "?") {
9176
+ if (state.result !== null && state.kind !== "scalar") {
9177
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
9178
+ }
9179
+ for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
9180
+ type2 = state.implicitTypes[typeIndex];
9181
+ if (type2.resolve(state.result)) {
9182
+ state.result = type2.construct(state.result);
9183
+ state.tag = type2.tag;
9184
+ if (state.anchor !== null) {
9185
+ storeAnchor(state, state.anchor, state.result);
9186
+ }
9187
+ break;
9188
+ }
9189
+ }
9190
+ } else if (state.tag !== "!") {
9191
+ if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
9192
+ type2 = state.typeMap[state.kind || "fallback"][state.tag];
9193
+ } else {
9194
+ type2 = null;
9195
+ const typeList = state.typeMap.multi[state.kind || "fallback"];
9196
+ for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
9197
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
9198
+ type2 = typeList[typeIndex];
9199
+ break;
9200
+ }
9201
+ }
9202
+ }
9203
+ if (!type2) {
9204
+ throwError(state, "unknown tag !<" + state.tag + ">");
9205
+ }
9206
+ if (state.result !== null && type2.kind !== state.kind) {
9207
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
9208
+ }
9209
+ if (!type2.resolve(state.result, state.tag)) {
9210
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
9211
+ } else {
9212
+ state.result = type2.construct(state.result, state.tag);
9213
+ if (state.anchor !== null) {
9214
+ storeAnchor(state, state.anchor, state.result);
9215
+ }
9216
+ }
9217
+ }
9218
+ if (state.listener !== null) {
9219
+ state.listener("close", state);
9220
+ }
9221
+ state.depth -= 1;
9222
+ return state.tag !== null || state.anchor !== null || hasContent;
9223
+ }
9224
+ function readDocument(state) {
9225
+ const documentStart = state.position;
9226
+ let hasDirectives = false;
9227
+ let ch;
9228
+ state.version = null;
9229
+ state.checkLineBreaks = state.legacy;
9230
+ state.tagMap = /* @__PURE__ */ Object.create(null);
9231
+ state.anchorMap = /* @__PURE__ */ Object.create(null);
9232
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
9233
+ skipSeparationSpace(state, true, -1);
9234
+ ch = state.input.charCodeAt(state.position);
9235
+ if (state.lineIndent > 0 || ch !== 37) {
9236
+ break;
9237
+ }
9238
+ hasDirectives = true;
9239
+ ch = state.input.charCodeAt(++state.position);
9240
+ let _position = state.position;
9241
+ while (ch !== 0 && !isWsOrEol(ch)) {
9242
+ ch = state.input.charCodeAt(++state.position);
9243
+ }
9244
+ const directiveName = state.input.slice(_position, state.position);
9245
+ const directiveArgs = [];
9246
+ if (directiveName.length < 1) {
9247
+ throwError(state, "directive name must not be less than one character in length");
9248
+ }
9249
+ while (ch !== 0) {
9250
+ while (isWhiteSpace(ch)) {
9251
+ ch = state.input.charCodeAt(++state.position);
9252
+ }
9253
+ if (ch === 35) {
9254
+ do {
9255
+ ch = state.input.charCodeAt(++state.position);
9256
+ } while (ch !== 0 && !isEol(ch));
9257
+ break;
9258
+ }
9259
+ if (isEol(ch)) break;
9260
+ _position = state.position;
9261
+ while (ch !== 0 && !isWsOrEol(ch)) {
9262
+ ch = state.input.charCodeAt(++state.position);
9263
+ }
9264
+ directiveArgs.push(state.input.slice(_position, state.position));
9265
+ }
9266
+ if (ch !== 0) readLineBreak(state);
9267
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
9268
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
9269
+ } else {
9270
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
9271
+ }
9272
+ }
9273
+ skipSeparationSpace(state, true, -1);
9274
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
9275
+ state.position += 3;
9276
+ skipSeparationSpace(state, true, -1);
9277
+ } else if (hasDirectives) {
9278
+ throwError(state, "directives end mark is expected");
9279
+ }
9280
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
9281
+ skipSeparationSpace(state, true, -1);
9282
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
9283
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
9284
+ }
9285
+ state.documents.push(state.result);
9286
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
9287
+ if (state.input.charCodeAt(state.position) === 46) {
9288
+ state.position += 3;
9289
+ skipSeparationSpace(state, true, -1);
9290
+ }
9291
+ return;
9292
+ }
9293
+ if (state.position < state.length - 1) {
9294
+ throwError(state, "end of the stream or a document separator is expected");
9295
+ }
9296
+ }
9297
+ function loadDocuments(input, options) {
9298
+ input = String(input);
9299
+ options = options || {};
9300
+ if (input.length !== 0) {
9301
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
9302
+ input += "\n";
9303
+ }
9304
+ if (input.charCodeAt(0) === 65279) {
9305
+ input = input.slice(1);
9306
+ }
9307
+ }
9308
+ const state = new State(input, options);
9309
+ const nullpos = input.indexOf("\0");
9310
+ if (nullpos !== -1) {
9311
+ state.position = nullpos;
9312
+ throwError(state, "null byte is not allowed in input");
9313
+ }
9314
+ state.input += "\0";
9315
+ while (state.input.charCodeAt(state.position) === 32) {
9316
+ state.lineIndent += 1;
9317
+ state.position += 1;
9318
+ }
9319
+ while (state.position < state.length - 1) {
9320
+ readDocument(state);
9321
+ }
9322
+ return state.documents;
9323
+ }
9324
+ function loadAll2(input, iterator, options) {
9325
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
9326
+ options = iterator;
9327
+ iterator = null;
9328
+ }
9329
+ const documents = loadDocuments(input, options);
9330
+ if (typeof iterator !== "function") {
9331
+ return documents;
9332
+ }
9333
+ for (let index = 0, length = documents.length; index < length; index += 1) {
9334
+ iterator(documents[index]);
9335
+ }
9336
+ }
9337
+ function load2(input, options) {
9338
+ const documents = loadDocuments(input, options);
9339
+ if (documents.length === 0) {
9340
+ return void 0;
9341
+ } else if (documents.length === 1) {
9342
+ return documents[0];
9343
+ }
9344
+ throw new YAMLException2("expected a single document in the stream, but found more");
9345
+ }
9346
+ loader.loadAll = loadAll2;
9347
+ loader.load = load2;
9348
+ return loader;
9349
+ }
9350
+ var dumper = {};
9351
+ var hasRequiredDumper;
9352
+ function requireDumper() {
9353
+ if (hasRequiredDumper) return dumper;
9354
+ hasRequiredDumper = 1;
9355
+ const common2 = requireCommon();
9356
+ const YAMLException2 = requireException();
9357
+ const DEFAULT_SCHEMA2 = require_default();
9358
+ const _toString = Object.prototype.toString;
9359
+ const _hasOwnProperty = Object.prototype.hasOwnProperty;
9360
+ const CHAR_BOM = 65279;
9361
+ const CHAR_TAB = 9;
9362
+ const CHAR_LINE_FEED = 10;
9363
+ const CHAR_CARRIAGE_RETURN = 13;
9364
+ const CHAR_SPACE = 32;
9365
+ const CHAR_EXCLAMATION = 33;
9366
+ const CHAR_DOUBLE_QUOTE = 34;
9367
+ const CHAR_SHARP = 35;
9368
+ const CHAR_PERCENT = 37;
9369
+ const CHAR_AMPERSAND = 38;
9370
+ const CHAR_SINGLE_QUOTE = 39;
9371
+ const CHAR_ASTERISK = 42;
9372
+ const CHAR_COMMA = 44;
9373
+ const CHAR_MINUS = 45;
9374
+ const CHAR_COLON = 58;
9375
+ const CHAR_EQUALS = 61;
9376
+ const CHAR_GREATER_THAN = 62;
9377
+ const CHAR_QUESTION = 63;
9378
+ const CHAR_COMMERCIAL_AT = 64;
9379
+ const CHAR_LEFT_SQUARE_BRACKET = 91;
9380
+ const CHAR_RIGHT_SQUARE_BRACKET = 93;
9381
+ const CHAR_GRAVE_ACCENT = 96;
9382
+ const CHAR_LEFT_CURLY_BRACKET = 123;
9383
+ const CHAR_VERTICAL_LINE = 124;
9384
+ const CHAR_RIGHT_CURLY_BRACKET = 125;
9385
+ const ESCAPE_SEQUENCES = {};
9386
+ ESCAPE_SEQUENCES[0] = "\\0";
9387
+ ESCAPE_SEQUENCES[7] = "\\a";
9388
+ ESCAPE_SEQUENCES[8] = "\\b";
9389
+ ESCAPE_SEQUENCES[9] = "\\t";
9390
+ ESCAPE_SEQUENCES[10] = "\\n";
9391
+ ESCAPE_SEQUENCES[11] = "\\v";
9392
+ ESCAPE_SEQUENCES[12] = "\\f";
9393
+ ESCAPE_SEQUENCES[13] = "\\r";
9394
+ ESCAPE_SEQUENCES[27] = "\\e";
9395
+ ESCAPE_SEQUENCES[34] = '\\"';
9396
+ ESCAPE_SEQUENCES[92] = "\\\\";
9397
+ ESCAPE_SEQUENCES[133] = "\\N";
9398
+ ESCAPE_SEQUENCES[160] = "\\_";
9399
+ ESCAPE_SEQUENCES[8232] = "\\L";
9400
+ ESCAPE_SEQUENCES[8233] = "\\P";
9401
+ const DEPRECATED_BOOLEANS_SYNTAX = [
9402
+ "y",
9403
+ "Y",
9404
+ "yes",
9405
+ "Yes",
9406
+ "YES",
9407
+ "on",
9408
+ "On",
9409
+ "ON",
9410
+ "n",
9411
+ "N",
9412
+ "no",
9413
+ "No",
9414
+ "NO",
9415
+ "off",
9416
+ "Off",
9417
+ "OFF"
9418
+ ];
9419
+ const DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
9420
+ function compileStyleMap(schema2, map2) {
9421
+ if (map2 === null) return {};
9422
+ const result = {};
9423
+ const keys = Object.keys(map2);
9424
+ for (let index = 0, length = keys.length; index < length; index += 1) {
9425
+ let tag = keys[index];
9426
+ let style = String(map2[tag]);
9427
+ if (tag.slice(0, 2) === "!!") {
9428
+ tag = "tag:yaml.org,2002:" + tag.slice(2);
9429
+ }
9430
+ const type2 = schema2.compiledTypeMap["fallback"][tag];
9431
+ if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
9432
+ style = type2.styleAliases[style];
9433
+ }
9434
+ result[tag] = style;
9435
+ }
9436
+ return result;
9437
+ }
9438
+ function encodeHex(character) {
9439
+ let handle;
9440
+ let length;
9441
+ const string = character.toString(16).toUpperCase();
9442
+ if (character <= 255) {
9443
+ handle = "x";
9444
+ length = 2;
9445
+ } else if (character <= 65535) {
9446
+ handle = "u";
9447
+ length = 4;
9448
+ } else if (character <= 4294967295) {
9449
+ handle = "U";
9450
+ length = 8;
9451
+ } else {
9452
+ throw new YAMLException2("code point within a string may not be greater than 0xFFFFFFFF");
9453
+ }
9454
+ return "\\" + handle + common2.repeat("0", length - string.length) + string;
9455
+ }
9456
+ const QUOTING_TYPE_SINGLE = 1;
9457
+ const QUOTING_TYPE_DOUBLE = 2;
9458
+ function State(options) {
9459
+ this.schema = options["schema"] || DEFAULT_SCHEMA2;
9460
+ this.indent = Math.max(1, options["indent"] || 2);
9461
+ this.noArrayIndent = options["noArrayIndent"] || false;
9462
+ this.skipInvalid = options["skipInvalid"] || false;
9463
+ this.flowLevel = common2.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
9464
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
9465
+ this.sortKeys = options["sortKeys"] || false;
9466
+ this.lineWidth = options["lineWidth"] || 80;
9467
+ this.noRefs = options["noRefs"] || false;
9468
+ this.noCompatMode = options["noCompatMode"] || false;
9469
+ this.condenseFlow = options["condenseFlow"] || false;
9470
+ this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
9471
+ this.forceQuotes = options["forceQuotes"] || false;
9472
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
9473
+ this.implicitTypes = this.schema.compiledImplicit;
9474
+ this.explicitTypes = this.schema.compiledExplicit;
9475
+ this.tag = null;
9476
+ this.result = "";
9477
+ this.duplicates = [];
9478
+ this.usedDuplicates = null;
9479
+ }
9480
+ function indentString(string, spaces) {
9481
+ const ind = common2.repeat(" ", spaces);
9482
+ let position = 0;
9483
+ let result = "";
9484
+ const length = string.length;
9485
+ while (position < length) {
9486
+ let line;
9487
+ const next = string.indexOf("\n", position);
9488
+ if (next === -1) {
9489
+ line = string.slice(position);
9490
+ position = length;
9491
+ } else {
9492
+ line = string.slice(position, next + 1);
9493
+ position = next + 1;
9494
+ }
9495
+ if (line.length && line !== "\n") result += ind;
9496
+ result += line;
9497
+ }
9498
+ return result;
9499
+ }
9500
+ function generateNextLine(state, level) {
9501
+ return "\n" + common2.repeat(" ", state.indent * level);
9502
+ }
9503
+ function testImplicitResolving(state, str2) {
9504
+ for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) {
9505
+ const type2 = state.implicitTypes[index];
9506
+ if (type2.resolve(str2)) {
9507
+ return true;
9508
+ }
9509
+ }
9510
+ return false;
9511
+ }
9512
+ function isWhitespace(c) {
9513
+ return c === CHAR_SPACE || c === CHAR_TAB;
9514
+ }
9515
+ function isPrintable(c) {
9516
+ return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
9517
+ }
9518
+ function isNsCharOrWhitespace(c) {
9519
+ return isPrintable(c) && c !== CHAR_BOM && // - b-char
9520
+ c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
9521
+ }
9522
+ function isPlainSafe(c, prev, inblock) {
9523
+ const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
9524
+ const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
9525
+ return (
9526
+ // ns-plain-safe
9527
+ (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && // - c-flow-indicator
9528
+ c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && // ns-plain-char
9529
+ c !== CHAR_SHARP && // false on '#'
9530
+ !(prev === CHAR_COLON && !cIsNsChar) || // false on ': '
9531
+ isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || // change to true on '[^ ]#'
9532
+ prev === CHAR_COLON && cIsNsChar
9533
+ );
9534
+ }
9535
+ function isPlainSafeFirst(c) {
9536
+ return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && // - s-white
9537
+ // - (c-indicator ::=
9538
+ // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
9539
+ c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
9540
+ c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && // | “%” | “@” | “`”)
9541
+ c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
9542
+ }
9543
+ function isPlainSafeLast(c) {
9544
+ return !isWhitespace(c) && c !== CHAR_COLON;
9545
+ }
9546
+ function codePointAt(string, pos) {
9547
+ const first = string.charCodeAt(pos);
9548
+ let second;
9549
+ if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
9550
+ second = string.charCodeAt(pos + 1);
9551
+ if (second >= 56320 && second <= 57343) {
9552
+ return (first - 55296) * 1024 + second - 56320 + 65536;
9553
+ }
9554
+ }
9555
+ return first;
9556
+ }
9557
+ function needIndentIndicator(string) {
9558
+ const leadingSpaceRe = /^\n* /;
9559
+ return leadingSpaceRe.test(string);
9560
+ }
9561
+ const STYLE_PLAIN = 1;
9562
+ const STYLE_SINGLE = 2;
9563
+ const STYLE_LITERAL = 3;
9564
+ const STYLE_FOLDED = 4;
9565
+ const STYLE_DOUBLE = 5;
9566
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
9567
+ let i;
9568
+ let char = 0;
9569
+ let prevChar = null;
9570
+ let hasLineBreak = false;
9571
+ let hasFoldableLine = false;
9572
+ const shouldTrackWidth = lineWidth !== -1;
9573
+ let previousLineBreak = -1;
9574
+ let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
9575
+ if (singleLineOnly || forceQuotes) {
9576
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
9577
+ char = codePointAt(string, i);
9578
+ if (!isPrintable(char)) {
9579
+ return STYLE_DOUBLE;
9580
+ }
9581
+ plain = plain && isPlainSafe(char, prevChar, inblock);
9582
+ prevChar = char;
9583
+ }
9584
+ } else {
9585
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
9586
+ char = codePointAt(string, i);
9587
+ if (char === CHAR_LINE_FEED) {
9588
+ hasLineBreak = true;
9589
+ if (shouldTrackWidth) {
9590
+ hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
9591
+ i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
9592
+ previousLineBreak = i;
9593
+ }
9594
+ } else if (!isPrintable(char)) {
9595
+ return STYLE_DOUBLE;
9596
+ }
9597
+ plain = plain && isPlainSafe(char, prevChar, inblock);
9598
+ prevChar = char;
9599
+ }
9600
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
9601
+ }
9602
+ if (!hasLineBreak && !hasFoldableLine) {
9603
+ if (plain && !forceQuotes && !testAmbiguousType(string)) {
9604
+ return STYLE_PLAIN;
9605
+ }
9606
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
9607
+ }
9608
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
9609
+ return STYLE_DOUBLE;
9610
+ }
9611
+ if (!forceQuotes) {
9612
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
9613
+ }
9614
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
9615
+ }
9616
+ function writeScalar(state, string, level, iskey, inblock) {
9617
+ state.dump = (function() {
9618
+ if (string.length === 0) {
9619
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
9620
+ }
9621
+ if (!state.noCompatMode) {
9622
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
9623
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
9624
+ }
9625
+ }
9626
+ const indent = state.indent * Math.max(1, level);
9627
+ const lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
9628
+ const singleLineOnly = iskey || // No block styles in flow mode.
9629
+ state.flowLevel > -1 && level >= state.flowLevel;
9630
+ function testAmbiguity(string2) {
9631
+ return testImplicitResolving(state, string2);
9632
+ }
9633
+ switch (chooseScalarStyle(
9634
+ string,
9635
+ singleLineOnly,
9636
+ state.indent,
9637
+ lineWidth,
9638
+ testAmbiguity,
9639
+ state.quotingType,
9640
+ state.forceQuotes && !iskey,
9641
+ inblock
9642
+ )) {
9643
+ case STYLE_PLAIN:
9644
+ return string;
9645
+ case STYLE_SINGLE:
9646
+ return "'" + string.replace(/'/g, "''") + "'";
9647
+ case STYLE_LITERAL:
9648
+ return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
9649
+ case STYLE_FOLDED:
9650
+ return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
9651
+ case STYLE_DOUBLE:
9652
+ return '"' + escapeString(string) + '"';
9653
+ default:
9654
+ throw new YAMLException2("impossible error: invalid scalar style");
9655
+ }
9656
+ })();
9657
+ }
9658
+ function blockHeader(string, indentPerLevel) {
9659
+ const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
9660
+ const clip = string[string.length - 1] === "\n";
9661
+ const keep = clip && (string[string.length - 2] === "\n" || string === "\n");
9662
+ const chomp = keep ? "+" : clip ? "" : "-";
9663
+ return indentIndicator + chomp + "\n";
9664
+ }
9665
+ function dropEndingNewline(string) {
9666
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
9667
+ }
9668
+ function foldString(string, width) {
9669
+ const lineRe = /(\n+)([^\n]*)/g;
9670
+ let result = (function() {
9671
+ let nextLF = string.indexOf("\n");
9672
+ nextLF = nextLF !== -1 ? nextLF : string.length;
9673
+ lineRe.lastIndex = nextLF;
9674
+ return foldLine(string.slice(0, nextLF), width);
9675
+ })();
9676
+ let prevMoreIndented = string[0] === "\n" || string[0] === " ";
9677
+ let moreIndented;
9678
+ let match;
9679
+ while (match = lineRe.exec(string)) {
9680
+ const prefix = match[1];
9681
+ const line = match[2];
9682
+ moreIndented = line[0] === " ";
9683
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
9684
+ prevMoreIndented = moreIndented;
9685
+ }
9686
+ return result;
9687
+ }
9688
+ function foldLine(line, width) {
9689
+ if (line === "" || line[0] === " ") return line;
9690
+ const breakRe = / [^ ]/g;
9691
+ let match;
9692
+ let start = 0;
9693
+ let end;
9694
+ let curr = 0;
9695
+ let next = 0;
9696
+ let result = "";
9697
+ while (match = breakRe.exec(line)) {
9698
+ next = match.index;
9699
+ if (next - start > width) {
9700
+ end = curr > start ? curr : next;
9701
+ result += "\n" + line.slice(start, end);
9702
+ start = end + 1;
9703
+ }
9704
+ curr = next;
9705
+ }
9706
+ result += "\n";
9707
+ if (line.length - start > width && curr > start) {
9708
+ result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
9709
+ } else {
9710
+ result += line.slice(start);
9711
+ }
9712
+ return result.slice(1);
9713
+ }
9714
+ function escapeString(string) {
9715
+ let result = "";
9716
+ let char = 0;
9717
+ for (let i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
9718
+ char = codePointAt(string, i);
9719
+ const escapeSeq = ESCAPE_SEQUENCES[char];
9720
+ if (!escapeSeq && isPrintable(char)) {
9721
+ result += string[i];
9722
+ if (char >= 65536) result += string[i + 1];
9723
+ } else {
9724
+ result += escapeSeq || encodeHex(char);
9725
+ }
9726
+ }
9727
+ return result;
9728
+ }
9729
+ function writeFlowSequence(state, level, object) {
9730
+ let _result = "";
9731
+ const _tag = state.tag;
9732
+ for (let index = 0, length = object.length; index < length; index += 1) {
9733
+ let value = object[index];
9734
+ if (state.replacer) {
9735
+ value = state.replacer.call(object, String(index), value);
9736
+ }
9737
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
9738
+ if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
9739
+ _result += state.dump;
9740
+ }
9741
+ }
9742
+ state.tag = _tag;
9743
+ state.dump = "[" + _result + "]";
9744
+ }
9745
+ function writeBlockSequence(state, level, object, compact) {
9746
+ let _result = "";
9747
+ const _tag = state.tag;
9748
+ for (let index = 0, length = object.length; index < length; index += 1) {
9749
+ let value = object[index];
9750
+ if (state.replacer) {
9751
+ value = state.replacer.call(object, String(index), value);
9752
+ }
9753
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
9754
+ if (!compact || _result !== "") {
9755
+ _result += generateNextLine(state, level);
9756
+ }
9757
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
9758
+ _result += "-";
9759
+ } else {
9760
+ _result += "- ";
9761
+ }
9762
+ _result += state.dump;
9763
+ }
9764
+ }
9765
+ state.tag = _tag;
9766
+ state.dump = _result || "[]";
9767
+ }
9768
+ function writeFlowMapping(state, level, object) {
9769
+ let _result = "";
9770
+ const _tag = state.tag;
9771
+ const objectKeyList = Object.keys(object);
9772
+ for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
9773
+ let pairBuffer = "";
9774
+ if (_result !== "") pairBuffer += ", ";
9775
+ if (state.condenseFlow) pairBuffer += '"';
9776
+ const objectKey = objectKeyList[index];
9777
+ let objectValue = object[objectKey];
9778
+ if (state.replacer) {
9779
+ objectValue = state.replacer.call(object, objectKey, objectValue);
9780
+ }
9781
+ if (!writeNode(state, level, objectKey, false, false)) {
9782
+ continue;
9783
+ }
9784
+ if (state.dump.length > 1024) pairBuffer += "? ";
9785
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
9786
+ if (!writeNode(state, level, objectValue, false, false)) {
9787
+ continue;
9788
+ }
9789
+ pairBuffer += state.dump;
9790
+ _result += pairBuffer;
9791
+ }
9792
+ state.tag = _tag;
9793
+ state.dump = "{" + _result + "}";
9794
+ }
9795
+ function writeBlockMapping(state, level, object, compact) {
9796
+ let _result = "";
9797
+ const _tag = state.tag;
9798
+ const objectKeyList = Object.keys(object);
9799
+ if (state.sortKeys === true) {
9800
+ objectKeyList.sort();
9801
+ } else if (typeof state.sortKeys === "function") {
9802
+ objectKeyList.sort(state.sortKeys);
9803
+ } else if (state.sortKeys) {
9804
+ throw new YAMLException2("sortKeys must be a boolean or a function");
9805
+ }
9806
+ for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
9807
+ let pairBuffer = "";
9808
+ if (!compact || _result !== "") {
9809
+ pairBuffer += generateNextLine(state, level);
9810
+ }
9811
+ const objectKey = objectKeyList[index];
9812
+ let objectValue = object[objectKey];
9813
+ if (state.replacer) {
9814
+ objectValue = state.replacer.call(object, objectKey, objectValue);
9815
+ }
9816
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
9817
+ continue;
9818
+ }
9819
+ const explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
9820
+ if (explicitPair) {
9821
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
9822
+ pairBuffer += "?";
9823
+ } else {
9824
+ pairBuffer += "? ";
9825
+ }
9826
+ }
9827
+ pairBuffer += state.dump;
9828
+ if (explicitPair) {
9829
+ pairBuffer += generateNextLine(state, level);
9830
+ }
9831
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
9832
+ continue;
9833
+ }
9834
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
9835
+ pairBuffer += ":";
9836
+ } else {
9837
+ pairBuffer += ": ";
9838
+ }
9839
+ pairBuffer += state.dump;
9840
+ _result += pairBuffer;
9841
+ }
9842
+ state.tag = _tag;
9843
+ state.dump = _result || "{}";
9844
+ }
9845
+ function detectType(state, object, explicit) {
9846
+ const typeList = explicit ? state.explicitTypes : state.implicitTypes;
9847
+ for (let index = 0, length = typeList.length; index < length; index += 1) {
9848
+ const type2 = typeList[index];
9849
+ if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
9850
+ if (explicit) {
9851
+ if (type2.multi && type2.representName) {
9852
+ state.tag = type2.representName(object);
9853
+ } else {
9854
+ state.tag = type2.tag;
9855
+ }
9856
+ } else {
9857
+ state.tag = "?";
9858
+ }
9859
+ if (type2.represent) {
9860
+ const style = state.styleMap[type2.tag] || type2.defaultStyle;
9861
+ let _result;
9862
+ if (_toString.call(type2.represent) === "[object Function]") {
9863
+ _result = type2.represent(object, style);
9864
+ } else if (_hasOwnProperty.call(type2.represent, style)) {
9865
+ _result = type2.represent[style](object, style);
9866
+ } else {
9867
+ throw new YAMLException2("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
9868
+ }
9869
+ state.dump = _result;
9870
+ }
9871
+ return true;
9872
+ }
9873
+ }
9874
+ return false;
9875
+ }
9876
+ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
9877
+ state.tag = null;
9878
+ state.dump = object;
9879
+ if (!detectType(state, object, false)) {
9880
+ detectType(state, object, true);
9881
+ }
9882
+ const type2 = _toString.call(state.dump);
9883
+ const inblock = block;
9884
+ if (block) {
9885
+ block = state.flowLevel < 0 || state.flowLevel > level;
9886
+ }
9887
+ const objectOrArray = type2 === "[object Object]" || type2 === "[object Array]";
9888
+ let duplicateIndex;
9889
+ let duplicate;
9890
+ if (objectOrArray) {
9891
+ duplicateIndex = state.duplicates.indexOf(object);
9892
+ duplicate = duplicateIndex !== -1;
9893
+ }
9894
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
9895
+ compact = false;
9896
+ }
9897
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
9898
+ state.dump = "*ref_" + duplicateIndex;
9899
+ } else {
9900
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
9901
+ state.usedDuplicates[duplicateIndex] = true;
9902
+ }
9903
+ if (type2 === "[object Object]") {
9904
+ if (block && Object.keys(state.dump).length !== 0) {
9905
+ writeBlockMapping(state, level, state.dump, compact);
9906
+ if (duplicate) {
9907
+ state.dump = "&ref_" + duplicateIndex + state.dump;
9908
+ }
9909
+ } else {
9910
+ writeFlowMapping(state, level, state.dump);
9911
+ if (duplicate) {
9912
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
9913
+ }
9914
+ }
9915
+ } else if (type2 === "[object Array]") {
9916
+ if (block && state.dump.length !== 0) {
9917
+ if (state.noArrayIndent && !isblockseq && level > 0) {
9918
+ writeBlockSequence(state, level - 1, state.dump, compact);
9919
+ } else {
9920
+ writeBlockSequence(state, level, state.dump, compact);
9921
+ }
9922
+ if (duplicate) {
9923
+ state.dump = "&ref_" + duplicateIndex + state.dump;
9924
+ }
9925
+ } else {
9926
+ writeFlowSequence(state, level, state.dump);
9927
+ if (duplicate) {
9928
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
9929
+ }
9930
+ }
9931
+ } else if (type2 === "[object String]") {
9932
+ if (state.tag !== "?") {
9933
+ writeScalar(state, state.dump, level, iskey, inblock);
9934
+ }
9935
+ } else if (type2 === "[object Undefined]") {
9936
+ return false;
9937
+ } else {
9938
+ if (state.skipInvalid) return false;
9939
+ throw new YAMLException2("unacceptable kind of an object to dump " + type2);
9940
+ }
9941
+ if (state.tag !== null && state.tag !== "?") {
9942
+ let tagStr = encodeURI(
9943
+ state.tag[0] === "!" ? state.tag.slice(1) : state.tag
9944
+ ).replace(/!/g, "%21");
9945
+ if (state.tag[0] === "!") {
9946
+ tagStr = "!" + tagStr;
9947
+ } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
9948
+ tagStr = "!!" + tagStr.slice(18);
9949
+ } else {
9950
+ tagStr = "!<" + tagStr + ">";
9951
+ }
9952
+ state.dump = tagStr + " " + state.dump;
9953
+ }
9954
+ }
9955
+ return true;
9956
+ }
9957
+ function getDuplicateReferences(object, state) {
9958
+ const objects = [];
9959
+ const duplicatesIndexes = [];
9960
+ inspectNode(object, objects, duplicatesIndexes);
9961
+ const length = duplicatesIndexes.length;
9962
+ for (let index = 0; index < length; index += 1) {
9963
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
9964
+ }
9965
+ state.usedDuplicates = new Array(length);
9966
+ }
9967
+ function inspectNode(object, objects, duplicatesIndexes) {
9968
+ if (object !== null && typeof object === "object") {
9969
+ const index = objects.indexOf(object);
9970
+ if (index !== -1) {
9971
+ if (duplicatesIndexes.indexOf(index) === -1) {
9972
+ duplicatesIndexes.push(index);
9973
+ }
9974
+ } else {
9975
+ objects.push(object);
9976
+ if (Array.isArray(object)) {
9977
+ for (let i = 0, length = object.length; i < length; i += 1) {
9978
+ inspectNode(object[i], objects, duplicatesIndexes);
9979
+ }
9980
+ } else {
9981
+ const objectKeyList = Object.keys(object);
9982
+ for (let i = 0, length = objectKeyList.length; i < length; i += 1) {
9983
+ inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes);
9984
+ }
9985
+ }
9986
+ }
9987
+ }
9988
+ }
9989
+ function dump2(input, options) {
9990
+ options = options || {};
9991
+ const state = new State(options);
9992
+ if (!state.noRefs) getDuplicateReferences(input, state);
9993
+ let value = input;
9994
+ if (state.replacer) {
9995
+ value = state.replacer.call({ "": value }, "", value);
9996
+ }
9997
+ if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
9998
+ return "";
9999
+ }
10000
+ dumper.dump = dump2;
10001
+ return dumper;
10002
+ }
10003
+ var hasRequiredJsYaml;
10004
+ function requireJsYaml() {
10005
+ if (hasRequiredJsYaml) return jsYaml;
10006
+ hasRequiredJsYaml = 1;
10007
+ const loader2 = requireLoader();
10008
+ const dumper2 = requireDumper();
10009
+ function renamed(from, to) {
10010
+ return function() {
10011
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
10012
+ };
10013
+ }
10014
+ jsYaml.Type = requireType();
10015
+ jsYaml.Schema = requireSchema();
10016
+ jsYaml.FAILSAFE_SCHEMA = requireFailsafe();
10017
+ jsYaml.JSON_SCHEMA = requireJson();
10018
+ jsYaml.CORE_SCHEMA = requireCore();
10019
+ jsYaml.DEFAULT_SCHEMA = require_default();
10020
+ jsYaml.load = loader2.load;
10021
+ jsYaml.loadAll = loader2.loadAll;
10022
+ jsYaml.dump = dumper2.dump;
10023
+ jsYaml.YAMLException = requireException();
10024
+ jsYaml.types = {
10025
+ binary: requireBinary(),
10026
+ float: requireFloat(),
10027
+ map: requireMap(),
10028
+ null: require_null(),
10029
+ pairs: requirePairs(),
10030
+ set: requireSet(),
10031
+ timestamp: requireTimestamp(),
10032
+ bool: requireBool(),
10033
+ int: requireInt(),
10034
+ merge: requireMerge(),
10035
+ omap: requireOmap(),
10036
+ seq: requireSeq(),
10037
+ str: requireStr()
10038
+ };
10039
+ jsYaml.safeLoad = renamed("safeLoad", "load");
10040
+ jsYaml.safeLoadAll = renamed("safeLoadAll", "loadAll");
10041
+ jsYaml.safeDump = renamed("safeDump", "dump");
10042
+ return jsYaml;
10043
+ }
10044
+ var jsYamlExports = requireJsYaml();
10045
+ var yaml = /* @__PURE__ */ getDefaultExportFromCjs(jsYamlExports);
10046
+ var {
10047
+ Type,
10048
+ Schema,
10049
+ FAILSAFE_SCHEMA,
10050
+ JSON_SCHEMA,
10051
+ CORE_SCHEMA,
10052
+ DEFAULT_SCHEMA,
10053
+ load,
10054
+ loadAll,
10055
+ dump,
10056
+ YAMLException,
10057
+ types,
10058
+ safeLoad,
10059
+ safeLoadAll,
10060
+ safeDump
10061
+ } = yaml;
10062
+
10063
+ // src/local-evaluator/schema.ts
10064
+ function validatePolicy(policy) {
10065
+ const errors = [];
10066
+ if (!policy || typeof policy !== "object") {
10067
+ return { valid: false, errors: [{ path: "", message: "Policy must be an object" }] };
10068
+ }
10069
+ const p = policy;
10070
+ if (typeof p.version !== "string") {
10071
+ errors.push({ path: "version", message: "version is required and must be a string" });
10072
+ }
10073
+ if (typeof p.name !== "string") {
10074
+ errors.push({ path: "name", message: "name is required and must be a string" });
10075
+ }
10076
+ if (!Array.isArray(p.purposes)) {
10077
+ errors.push({ path: "purposes", message: "purposes is required and must be an array" });
10078
+ } else {
10079
+ p.purposes.forEach((purpose, i) => {
10080
+ errors.push(...validatePurpose(purpose, `purposes[${i}]`));
10081
+ });
10082
+ }
10083
+ if (p.scope !== void 0) {
10084
+ errors.push(...validateScope(p.scope, "scope"));
10085
+ }
10086
+ if (p.limits !== void 0) {
10087
+ errors.push(...validateLimits(p.limits, "limits"));
10088
+ }
10089
+ if (p.riskThresholds !== void 0) {
10090
+ errors.push(...validateRiskThresholds(p.riskThresholds, "riskThresholds"));
10091
+ }
10092
+ return { valid: errors.length === 0, errors };
10093
+ }
10094
+ function validatePurpose(purpose, path) {
10095
+ const errors = [];
10096
+ if (!purpose || typeof purpose !== "object") {
10097
+ return [{ path, message: "purpose must be an object" }];
10098
+ }
10099
+ const p = purpose;
10100
+ if (typeof p.id !== "string" || !p.id) {
10101
+ errors.push({ path: `${path}.id`, message: "id is required and must be a non-empty string" });
10102
+ }
10103
+ if (typeof p.allowed !== "boolean") {
10104
+ errors.push({ path: `${path}.allowed`, message: "allowed is required and must be a boolean" });
10105
+ }
10106
+ if (p.targets !== void 0 && !isStringArray(p.targets)) {
10107
+ errors.push({ path: `${path}.targets`, message: "targets must be an array of strings" });
10108
+ }
10109
+ if (p.blockedPatterns !== void 0 && !isStringArray(p.blockedPatterns)) {
10110
+ errors.push({
10111
+ path: `${path}.blockedPatterns`,
10112
+ message: "blockedPatterns must be an array of strings"
10113
+ });
10114
+ }
10115
+ if (p.requiresApproval !== void 0 && typeof p.requiresApproval !== "boolean") {
10116
+ errors.push({
10117
+ path: `${path}.requiresApproval`,
10118
+ message: "requiresApproval must be a boolean"
10119
+ });
10120
+ }
10121
+ return errors;
10122
+ }
10123
+ function validateScope(scope, path) {
10124
+ const errors = [];
10125
+ if (typeof scope !== "object" || scope === null) {
10126
+ return [{ path, message: "scope must be an object" }];
10127
+ }
10128
+ const s = scope;
10129
+ for (const field of ["allowedDomains", "blockedDomains", "blockedResources"]) {
10130
+ if (s[field] !== void 0 && !isStringArray(s[field])) {
10131
+ errors.push({ path: `${path}.${field}`, message: `${field} must be an array of strings` });
10132
+ }
10133
+ }
10134
+ return errors;
10135
+ }
10136
+ function validateLimits(limits, path) {
10137
+ const errors = [];
10138
+ if (typeof limits !== "object" || limits === null) {
10139
+ return [{ path, message: "limits must be an object" }];
10140
+ }
10141
+ const l = limits;
10142
+ if (l.autonomousThreshold !== void 0 && typeof l.autonomousThreshold !== "number") {
10143
+ errors.push({
10144
+ path: `${path}.autonomousThreshold`,
10145
+ message: "autonomousThreshold must be a number"
10146
+ });
10147
+ }
10148
+ if (l.maxTransactionAmount !== void 0 && typeof l.maxTransactionAmount !== "number") {
10149
+ errors.push({
10150
+ path: `${path}.maxTransactionAmount`,
10151
+ message: "maxTransactionAmount must be a number"
10152
+ });
10153
+ }
10154
+ if (typeof l.autonomousThreshold === "number" && typeof l.maxTransactionAmount === "number" && l.autonomousThreshold > l.maxTransactionAmount) {
10155
+ errors.push({
10156
+ path: `${path}.autonomousThreshold`,
10157
+ message: "autonomousThreshold (Autonomous Limit) must be <= maxTransactionAmount (Hard Limit)"
10158
+ });
10159
+ }
10160
+ if (l.maxRequestsPerHour !== void 0 && typeof l.maxRequestsPerHour !== "number") {
10161
+ errors.push({
10162
+ path: `${path}.maxRequestsPerHour`,
10163
+ message: "maxRequestsPerHour must be a number"
10164
+ });
10165
+ }
10166
+ if (l.currency !== void 0 && typeof l.currency !== "string") {
10167
+ errors.push({ path: `${path}.currency`, message: "currency must be a string" });
10168
+ }
10169
+ return errors;
10170
+ }
10171
+ function validateRiskThresholds(thresholds, path) {
10172
+ const errors = [];
10173
+ if (typeof thresholds !== "object" || thresholds === null) {
10174
+ return [{ path, message: "riskThresholds must be an object" }];
10175
+ }
10176
+ const t = thresholds;
10177
+ for (const range of ["autoAllow", "requireApproval", "autoBlock"]) {
10178
+ if (!t[range] || typeof t[range] !== "object") {
10179
+ errors.push({
10180
+ path: `${path}.${range}`,
10181
+ message: `${range} is required and must be an object with min and max`
10182
+ });
10183
+ continue;
10184
+ }
10185
+ const r = t[range];
10186
+ if (typeof r.min !== "number" || typeof r.max !== "number") {
10187
+ errors.push({ path: `${path}.${range}`, message: `${range} must have numeric min and max` });
10188
+ } else if (r.min > r.max) {
10189
+ errors.push({ path: `${path}.${range}`, message: `${range}.min must be <= ${range}.max` });
10190
+ }
10191
+ }
10192
+ if (isValidThresholdShape(t)) {
10193
+ const thresholdObj = t;
10194
+ if (thresholdObj.autoAllow.max + 1 !== thresholdObj.requireApproval.min) {
10195
+ errors.push({
10196
+ path: `${path}`,
10197
+ message: `Gap between autoAllow.max (${thresholdObj.autoAllow.max}) and requireApproval.min (${thresholdObj.requireApproval.min}). Ranges must be contiguous.`
10198
+ });
10199
+ }
10200
+ if (thresholdObj.requireApproval.max + 1 !== thresholdObj.autoBlock.min) {
10201
+ errors.push({
10202
+ path: `${path}`,
10203
+ message: `Gap between requireApproval.max (${thresholdObj.requireApproval.max}) and autoBlock.min (${thresholdObj.autoBlock.min}). Ranges must be contiguous.`
10204
+ });
10205
+ }
10206
+ }
10207
+ return errors;
10208
+ }
10209
+ function isStringArray(val) {
10210
+ return Array.isArray(val) && val.every((v) => typeof v === "string");
10211
+ }
10212
+ function isValidThresholdShape(t) {
10213
+ for (const key of ["autoAllow", "requireApproval", "autoBlock"]) {
10214
+ const r = t[key];
10215
+ if (!r || typeof r !== "object") return false;
10216
+ const range = r;
10217
+ if (typeof range.min !== "number" || typeof range.max !== "number") return false;
10218
+ }
10219
+ return true;
10220
+ }
10221
+
10222
+ // src/local-evaluator/pdlss-parser.ts
10223
+ function parseYaml(yamlContent) {
10224
+ let parsed;
10225
+ try {
10226
+ parsed = load(yamlContent);
10227
+ } catch (err) {
10228
+ const message = err instanceof Error ? err.message : "Invalid YAML";
10229
+ return {
10230
+ policy: null,
10231
+ validation: { valid: false, errors: [{ path: "", message: `YAML parse error: ${message}` }] },
10232
+ rawYaml: yamlContent
10233
+ };
10234
+ }
10235
+ const validation = validatePolicy(parsed);
10236
+ if (!validation.valid) {
10237
+ return { policy: null, validation, rawYaml: yamlContent };
10238
+ }
10239
+ return {
10240
+ policy: parsed,
10241
+ validation,
10242
+ rawYaml: yamlContent
10243
+ };
10244
+ }
6585
10245
  export {
6586
10246
  AgentClient,
6587
10247
  AstraSync,
@@ -6604,6 +10264,7 @@ export {
6604
10264
  RegistrationTimeoutError,
6605
10265
  SDK_USER_AGENT,
6606
10266
  TRUST_LEVEL_RANGES,
10267
+ VERIFICATION_STATUS_HEADER,
6607
10268
  SDK_VERSION as VERSION,
6608
10269
  _resetEdgeConfigCache,
6609
10270
  agent_exports as agent,
@@ -6611,9 +10272,11 @@ export {
6611
10272
  awaitStepUpApproval,
6612
10273
  buildGuidance,
6613
10274
  buildSdkObservedMetadata,
10275
+ buildVerificationUnavailableBody,
6614
10276
  clearCache,
6615
10277
  createMcpMiddleware,
6616
10278
  degradeToObserve,
10279
+ denyStatusFor,
6617
10280
  deriveConnectionFromHeaders,
6618
10281
  detectPlatformFingerprint,
6619
10282
  detectRuntime,
@@ -6630,11 +10293,14 @@ export {
6630
10293
  getWellKnownUrls,
6631
10294
  hasCredentials,
6632
10295
  isEdgeConfig,
10296
+ isRejectedIdentityClaim,
10297
+ isVerificationUnavailable,
6633
10298
  isVerifiedHopValidFor,
6634
10299
  matchEdgePathRule,
6635
10300
  matchPlatformSignature,
6636
10301
  nextjs_exports as nextjs,
6637
10302
  normalizeDeclaredSource,
10303
+ parseYaml as parseLocalPolicyYaml,
6638
10304
  parseVerifiedHop,
6639
10305
  pollStepUpStatus,
6640
10306
  prefetchWellKnown,
@@ -6648,6 +10314,8 @@ export {
6648
10314
  serializeVerifiedHop,
6649
10315
  setMcpMeta,
6650
10316
  transport_exports as transport,
10317
+ unavailableRetryAfterSeconds,
10318
+ validatePolicy as validateLocalPolicy,
6651
10319
  verify
6652
10320
  };
6653
10321
  //# sourceMappingURL=index.mjs.map