"use strict";function d(i){i.forEach((t,c)=>{if(typeof t!="string")throw new Error(`[HPP] Please pass only strings into the array. Removed the entry <' + ${c} + '>`)})}function A(i={}){let{whitelist:t="*",checkQuery:c=!0,checkBody:p=!0,checkBodyOnlyForContentType:l="*",queryWhitelist:u=[],bodyWhitelist:h=[]}=i;if(!t)throw new Error("Please pass either a string or an string array to options.whitelist");Array.isArray(t)&&d(t),d(u),d(h);function f(r,n,a){let o=r==="query"?n[r]:n.request.body,y=n.state[`${r}Polluted`];if(!y){let e={};n.state[`${r}Polluted`]=e,y=e}if(Array.isArray(a)){a.forEach(e=>{let s=o[e];Array.isArray(s)&&(y[e]=s,o[e]=s[s.length-1])});for(const e in o)if(Object.prototype.hasOwnProperty.call(o,e)){const s=o[e];a.includes(e)||(y[e]||(y[e]=s),delete o[e])}}}return async function(r,n){if(t==="*"&&!u[0]&&!h[0])return await n();if(t=Array.isArray(t)?t:[],c&&Object.keys(r.query)[0]&&f("query",r,t.concat(u)),p&&r.request.body&&Object.keys(r.request.body)[0]){let a=t.concat(h);(l==="*"||Array.isArray(l)&&l.includes(r.header["content-type"]))&&f("body",r,a)}await n()}}module.exports=A;