/* Socket Lib - Built with esbuild */
var u=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var O=(e,o)=>{for(var c in o)u(e,c,{get:o[c],enumerable:!0})},j=(e,o,c,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of w(o))!y.call(e,a)&&a!==c&&u(e,a,{get:()=>o[a],enumerable:!(n=b(o,a))||n.enumerable});return e};var E=e=>j(u({},"__esModule",{value:!0}),e);var D={};O(D,{getCodeCoverage:()=>x});module.exports=E(D);var m=require("node:fs"),_=require("../fs"),i=require("../objects"),C=require("../spawn");let v;function M(){return v===void 0&&(v=require("node:path")),v}async function x(e){const c={__proto__:null,coveragePath:M().join(process.cwd(),"coverage/coverage-final.json"),generateIfMissing:!1,...e},{coveragePath:n,generateIfMissing:a}=c;if(!n)throw new Error("Coverage path is required");if(!await m.promises.access(n).then(()=>!0).catch(()=>!1))if(a)await(0,C.spawn)("vitest",["run","--coverage"],{cwd:process.cwd(),stdio:"inherit"});else throw new Error(`Coverage file not found at "${n}". Run tests with coverage first.`);const p=await(0,_.readJson)(n);if(!(0,i.isObjectObject)(p))throw new Error(`Invalid coverage data format in "${n}"`);const t={__proto__:null,branches:{__proto__:null,covered:0,total:0},functions:{__proto__:null,covered:0,total:0},lines:{__proto__:null,covered:0,total:0},statements:{__proto__:null,covered:0,total:0}},h=p;for(const d of Object.values(h)){if(!(0,i.isObjectObject)(d))continue;const r=d;if(r.s&&(0,i.isObjectObject)(r.s)){const f=Object.values(r.s);for(const s of f)typeof s=="number"&&(t.statements.total+=1,s>0&&(t.statements.covered+=1))}if(r.b&&(0,i.isObjectObject)(r.b)){const f=Object.values(r.b);for(const s of f)if(Array.isArray(s))for(const g of s)typeof g=="number"&&(t.branches.total+=1,g>0&&(t.branches.covered+=1))}if(r.f&&(0,i.isObjectObject)(r.f)){const f=Object.values(r.f);for(const s of f)typeof s=="number"&&(t.functions.total+=1,s>0&&(t.functions.covered+=1))}t.lines.covered=t.statements.covered,t.lines.total=t.statements.total}return{branches:l(t.branches),functions:l(t.functions),lines:l(t.lines),statements:l(t.statements)}}function l(e){const o=e.total===0?"0.00":(e.covered/e.total*100).toFixed(2);return{covered:e.covered,percent:o,total:e.total}}0&&(module.exports={getCodeCoverage});
//# sourceMappingURL=code.js.map
