// Metro module 6462 (f6463). import { isError } from "./isInstanceOf_6375"; import { truncate } from "./Module6377"; import { defineIntegration } from "./setupIntegration_6424"; let flattenIssuePath, formatIssueMessage, applyZodErrorsToEvent; const flattenIssue = function flattenIssue(a0) { return { ...a0, path: "path" in a0 ? Array.isArray(a0.path) ? a0.path.join(".") : void 0 : void 0, keys: "keys" in a0 ? JSON.stringify(a0.keys) : void 0, unionErrors: "unionErrors" in a0 ? JSON.stringify(a0.unionErrors) : void 0 }; }; flattenIssuePath = function flattenIssuePath(path) { return path.map((item) => typeof item !== "number" ? item : "").join("."); }; formatIssueMessage = function formatIssueMessage(originalException) { const set = new Set(); for (const issue of originalException.issues) { const r31 = flattenIssuePath(issue.path); if (r31.length > 0) { set.add(r31); } } const r40 = Array.from(set); if (r40.length === 0) { const r58 = originalException.issues.length > 0; let r60 = "variable"; if (r58) { const r62 = originalException.issues[0]; r60 = r62 !== void 0 && "expected" in r62 && typeof r62.expected === "string" ? r62.expected : "variable"; } return `Failed to validate ${r60}`; } return `Failed to validate keys: ${truncate(r40.join(", "), 100)}`; }; applyZodErrorsToEvent = function applyZodErrorsToEvent(limit, r0 = false, r2) { let r46; if (r2.exception && r2.exception.values) { const r4 = arguments[3]; if (r4 && r4.originalException && (function originalExceptionIsZodError(a0) { return isError(a0) && a0.name === "ZodError" && Array.isArray(a0.issues); })(r4.originalException) && r4.originalException.issues.length !== 0) { try { const issues = r4.originalException.issues; const issues2 = (r0 ? issues : issues.slice(0, limit)).map(flattenIssue); if (r0) { if (!Array.isArray(r4.attachments)) { r4.attachments = []; } r4.attachments.push({ filename: "zod_issues.json", data: JSON.stringify({ issues: issues2 }) }); } r46 = { ...r2, exception: { ...r2.exception, values: [{ ...r2.exception.values[0], value: formatIssueMessage(r4.originalException) }, ...r2.exception.values.slice(1)] }, extra: { ...r2.extra, "zoderror.issues": issues2.slice(0, limit) } }; } catch (r76) { return { ...r2, extra: { ...r2.extra, "zoderrors sentry integration parse error": { message: "an exception was thrown while processing ZodError within applyZodErrorsToEvent()", error: r76 instanceof Error ? `${r76.name}: ${r76.message} ${r76.stack}` : "unknown" } } }; } return r46; } } return r2; }; const r19 = defineIntegration(function(r3 = {}) { let c15757_0 = r3; const limit = r3.limit !== void 0 ? r3.limit : 10; return { name: "ZodErrors", processEvent: (a0, a1) => applyZodErrorsToEvent(limit, c15757_0.saveZodIssuesAsAttachment, a0, a1) }; }); export { applyZodErrorsToEvent }; export { flattenIssue }; export { flattenIssuePath }; export { formatIssueMessage }; export { r19 as zodErrorsIntegration };