/* Socket Lib - Built with esbuild */
var f=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var h=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},w=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of l(n))!m.call(e,r)&&r!==t&&f(e,r,{get:()=>n[r],enumerable:!(s=p(n,r))||s.enumerable});return e};var g=e=>w(f({},"__esModule",{value:!0}),e);var k={};h(k,{createJsonParser:()=>O,parseJsonWithResult:()=>J,parseNdjson:()=>P,safeJsonParse:()=>u,streamNdjson:()=>S,tryJsonParse:()=>T});module.exports=g(k);const{hasOwn:y}=Object;function u(e,n,t={}){const{allowPrototype:s=!1,maxSize:r=10*1024*1024}=t;if(Buffer.byteLength(e,"utf8")>r)throw new Error(`JSON string exceeds maximum size limit${r!==10*1024*1024?` of ${r} bytes`:""}`);let o;try{o=JSON.parse(e)}catch(i){throw new Error(`Failed to parse JSON: ${i}`)}if(!s&&typeof o=="object"&&o!==null&&!Array.isArray(o)){const i=["__proto__","constructor","prototype"];for(const c of i)if(y(o,c))throw new Error("JSON contains potentially malicious prototype pollution keys")}if(n){const i=n.safeParse(o);if(!i.success){const c=i.error.issues.map(d=>`${d.path.join(".")}: ${d.message}`).join(", ");throw new Error(`Validation failed: ${c}`)}return i.data}return o}function T(e,n,t){try{return u(e,n,t)}catch{return}}function J(e,n,t){try{return{success:!0,data:u(e,n,t)}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Unknown error"}}}function O(e,n){return(t,s)=>u(t,e,{...n,...s})}function P(e,n,t){const s=[],r=e.split(/\r?\n/);for(let a=0;a<r.length;a++){const o=r[a]?.trim();if(!(!o||o===""))try{const i=u(o,n,t);s.push(i)}catch(i){const c=i instanceof Error?i.message:String(i);throw new Error(`Failed to parse NDJSON at line ${a+1}: ${c}`)}}return s}function*S(e,n,t){const s=e.split(/\r?\n/);for(let r=0;r<s.length;r++){const a=s[r]?.trim();if(!(!a||a===""))try{yield u(a,n,t)}catch(o){const i=o instanceof Error?o.message:String(o);throw new Error(`Failed to parse NDJSON at line ${r+1}: ${i}`)}}}0&&(module.exports={createJsonParser,parseJsonWithResult,parseNdjson,safeJsonParse,streamNdjson,tryJsonParse});
//# sourceMappingURL=json-parser.js.map
