import{fetch as h,ProxyAgent as y}from"undici";import{URL as f}from"node:url";var u="2.22.0";function n(t){let e=process.env[t]||process.env[t.toUpperCase()];return e?new y(e):!1}var i=n("http_proxy_license_server")||n("http_proxy"),c=n("https_proxy_license_server")||n("https_proxy"),l={...i?{"http:":i}:{},...c?{"https:":c}:{}},x=((process.env.no_proxy||process.env.NO_PROXY)??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),g=t=>{let{host:e,protocol:r}=t;return!(r==="http:"&&!i||r==="https:"&&!c||x.some(s=>e.endsWith(s)))};async function d(t,e,r={}){let s=new f(t),p;g(s)&&(p=l[s.protocol]);try{let o=await h(t,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json","User-Agent":`License-SDK/${u} (Node.js ${process.version}; ${process.platform}) ${r.productIdentifier??""}`},signal:AbortSignal.timeout(r.timeoutInMs??3e4),...p?{dispatcher:p}:{}});return{status:o.status,data:await o.json()}}catch(o){let a=new Error("Connection Error: "+o.message);throw a.cause=o,a}}var S={postRequest:d};export{S as default,d as postRequest};
//# sourceMappingURL=httpRequest.mjs.map