const d=/^(?:(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/,s=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,c=["x-client-ip","cf-connecting-ip","do-connecting-ip","true-client-ip","x-real-ip","x-cluster-client-ip","x-appengine-user-ip"];function f(t){if(t.headers){const n=p(t.headers.get("x-forwarded-for"));if(i(n))return n;for(const e of c)if(i(t.headers.get(e)))return t.headers.get(e)}}function p(t){if(!t)return;const n=t.split(",").map(e=>{const r=e.trim();if(r.includes(":")){const o=r.split(":");if(o.length===2)return o[0]}return r});for(let e=0;e<n.length;e++)if(i(n[e]))return n[e]}function i(t){return t?d.test(t)||s.test(t):!1}export{c as POSSIBLE_HEADERS_WITH_IP,f as getClientIp,i as isValidIp};
