"use strict";function createDetailedError(e,r,o){return{code:e,message:r,hint:o?.hint,suggested_action:o?.suggested_action,field:o?.field,docs:o?.docs,severity:o?.severity}}function formatErrorForUser(e){const r=[e.message];return e.field&&r.push("Field: "+e.field),e.hint&&r.push("Hint: "+e.hint),e.docs&&r.push("Docs: "+e.docs),r.join("\n")}function formatErrorForLog(e){const r=["["+e.code+"] "+e.message];return e.field&&r.push("field="+e.field),e.hint&&r.push('hint="'+e.hint+'"'),e.docs&&r.push("docs="+e.docs),r.join(" | ")}function isACIError(e){if("object"!=typeof e||null===e)return!1;const r=e;return!("string"!=typeof r.code||"string"!=typeof r.message||void 0!==r.hint&&"string"!=typeof r.hint||void 0!==r.field&&"string"!=typeof r.field||void 0!==r.docs&&"string"!=typeof r.docs)}function toACIError(e){return isACIError(e)?e:e instanceof Error?{code:"INTERNAL_ERROR",message:e.message,hint:"An unexpected error occurred"}:{code:"UNKNOWN_ERROR",message:String(e),hint:"An unexpected error occurred"}}function formatErrorStructured(e){const r=["Error: "+e.message,"Code: "+e.code];e.severity&&r.push("Severity: "+e.severity),e.field&&r.push("Field: "+e.field),e.hint&&r.push("Hint: "+e.hint),e.suggested_action&&r.push("Action: "+e.suggested_action),e.docs&&r.push("Docs: "+e.docs);const o=r.join("\n"),t=["error",e.code,e.message];if(e.severity&&t.push("severity="+e.severity),e.field&&t.push("field="+e.field),e.hint){const r=e.hint.replace(/"/g,'\\"');t.push('hint="'+r+'"')}if(e.suggested_action){const r=e.suggested_action.replace(/"/g,'\\"');t.push('action="'+r+'"')}e.docs&&t.push("docs="+e.docs);const s=t.join(" | "),i={code:e.code,message:e.message};e.severity&&(i.severity=e.severity),e.field&&(i.field=e.field),e.hint&&(i.hint=e.hint),e.suggested_action&&(i.suggested_action=e.suggested_action),e.docs&&(i.docs=e.docs);const n=JSON.stringify(i),d=["**Error:** "+e.message,"**Code:** `"+e.code+"`"];e.severity&&d.push("**Severity:** "+e.severity),e.field&&d.push("**Field:** `"+e.field+"`"),e.hint&&d.push("**Hint:** "+e.hint),e.suggested_action&&d.push("**Action:** "+e.suggested_action),e.docs&&d.push("**Docs:** ["+e.docs+"]("+e.docs+")");const c=d.join("\n\n");return{...e,formats:{multiline:o,singleline:s,json:n,markdown:c}}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.ERROR_DETAILS=void 0,exports.createDetailedError=createDetailedError,exports.formatErrorForUser=formatErrorForUser,exports.formatErrorForLog=formatErrorForLog,exports.isACIError=isACIError,exports.toACIError=toACIError,exports.formatErrorStructured=formatErrorStructured,exports.ERROR_DETAILS={};