const e=e=>{let t=e.match(/[{[]/);if(!t)throw Error(`No JSON start character ({ or [) found.`);let n=t.index,r=e[n],i=r===`{`?`}`:`]`,a=0;for(let t=n;t<e.length;t++){let o=e[t];if(o===r)a++;else if(o===i&&(a--,a===0)){let r=e.slice(n,t+1);try{return JSON.parse(r)}catch(e){throw Error(`Failed to parse JSON: ${e.message}`)}}}throw Error(`Reached end of input without closing JSON bracket.`)};export{e as extractJson};
//# sourceMappingURL=extractJSON.mjs.map