var e=require("axios"),t=require("copy-anything");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(e);function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t=500&&n<600?500:n,a=r(e.response);return{status:i,message:t[i],rateLimit:a.rateLimit}}return{status:500,message:t[500]}},c=function(e,t,n,c){return new Promise(function(u,l){s(n,e,t,null,"cleaner").then(function(){i.default.get(e+"/"+c+"/clean",{params:a({api_key:t},n),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(r(e))}).catch(function(e){l(o(e))})}).catch(function(e){l(e)})})},u=function(e,n,a,c,u){return new Promise(function(l,p){s(c,e,a,null,"enrichment").then(function(){var s=c.sandbox&&"person"===u?n+"/"+u+"/enrich":e+"/"+u+"/enrich",d=t.copy(c),h=new URLSearchParams;delete d.sandbox,Object.entries(d).forEach(function(e){var t=e[0],n=e[1];"profile"===t?Array.isArray(n)?h.append(t,JSON.stringify(n)):h.append(t,n):"object"==typeof n?Array.isArray(n)?n.forEach(function(e){h.append(t,e)}):h.append(t,JSON.stringify(n)):h.append(t,n)}),h.append("api_key",a),i.default.get(s,{params:h,headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(r(e))}).catch(function(e){p(o(e))})}).catch(function(e){p(e)})})},l=function(e,t,n,a,c,u){return new Promise(function(l,p){s(c,e,n,null,"search").then(function(){var s,d=c.pretty,h=c.sandbox,f=((s={titlecase:c.titlecase||!1,dataset:c.dataset||"all",scroll_token:c.scroll_token||null,size:c.size||10})["sql"===a?"sql":"query"]=c.searchQuery,s.pretty=d||!1,s);i.default.post(h&&"person"===u?t+"/person/search":e+"/"+u+"/search",f,{headers:{"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":n,"User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(r(e))}).catch(function(e){p(o(e))})}).catch(function(e){p(e)})})};module.exports=function(e){var n=this,p=e.apiKey,d=e.basePath,h=e.sandboxBasePath,f=e.version;this.apiKey=void 0,this.basePath=void 0,this.sandboxBasePath=void 0,this.person=void 0,this.company=void 0,this.school=void 0,this.location=void 0,this.autocomplete=void 0,this.skill=void 0,this.jobTitle=void 0,this.ip=void 0,this.apiKey=p,this.basePath=d||"https://api.peopledatalabs.com/"+(f||"v5"),this.sandboxBasePath=h||"https://sandbox.api.peopledatalabs.com/"+(f||"v5"),this.person={enrichment:function(e){return u(n.basePath,n.sandboxBasePath,n.apiKey,e,"person")},enrichmentPreview:function(e){return function(e,n,a,c){return new Promise(function(u,l){s(c,e,a,null,"enrichment").then(function(){var s=c.sandbox?n+"/person/enrich/preview":e+"/person/enrich/preview",p=t.copy(c),d=new URLSearchParams;delete p.sandbox,Object.entries(p).forEach(function(e){var t=e[0],n=e[1];"profile"===t?Array.isArray(n)?d.append(t,JSON.stringify(n)):d.append(t,n):"object"==typeof n?Array.isArray(n)?n.forEach(function(e){d.append(t,e)}):d.append(t,JSON.stringify(n)):d.append(t,n)}),d.append("api_key",a),i.default.get(s,{params:d,headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(r(e))}).catch(function(e){l(o(e))})}).catch(function(e){l(e)})})}(n.basePath,n.sandboxBasePath,n.apiKey,e)},search:{elastic:function(e){return l(n.basePath,n.sandboxBasePath,n.apiKey,"elastic",e,"person")},sql:function(e){return l(n.basePath,n.sandboxBasePath,n.apiKey,"sql",e,"person")}},bulk:{enrichment:function(e){return function(e,t,n){var a={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":t,"User-Agent":"PDL-JS-SDK"};return new Promise(function(c,u){s(n,e,t,"Records","bulk").then(function(){i.default.post(e+"/person/bulk",n,{headers:a}).then(function(e){c(r(e))}).catch(function(e){u(o(e))})}).catch(function(e){u(e)})})}(n.basePath,n.apiKey,e)},retrieve:function(e){return function(e,t,n){var c={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":t,"User-Agent":"PDL-JS-SDK"};return new Promise(function(u,l){s(n,e,t,"Records","bulk").then(function(){var t,s,p=a({},t=n,null==(s=t.filter_updated)?{filter_updated:void 0}:{filter_updated:(Array.isArray(s)?s:[s]).join(",")});i.default.post(e+"/person/retrieve/bulk",p,{headers:c}).then(function(e){u(r(e))}).catch(function(e){l(o(e))})}).catch(function(e){l(e)})})}(n.basePath,n.apiKey,e)}},identify:function(e){return function(e,n,a,c){return new Promise(function(u,l){s(c,e,a,null,"identify").then(function(){var s=c.sandbox?n+"/person/identify":e+"/person/identify",p=t.copy(c),d=new URLSearchParams;delete p.sandbox,Object.entries(p).forEach(function(e){var t=e[0],n=e[1];"profile"===t?Array.isArray(n)?d.append(t,JSON.stringify(n)):d.append(t,n):"object"==typeof n?Array.isArray(n)?n.forEach(function(e){d.append(t,e)}):d.append(t,JSON.stringify(n)):d.append(t,n)}),d.append("api_key",a),i.default.get(s,{params:d,headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(r(e))}).catch(function(e){l(o(e))})}).catch(function(e){l(e)})})}(n.basePath,n.sandboxBasePath,n.apiKey,e)},retrieve:function(e){return function(e,t,n){return new Promise(function(c,u){s(n,e,t,"ID","retrieve").then(function(){var s=function(e){var t=e.filter_updated;return a({},e,null==t?{filter_updated:void 0}:{filter_updated:(Array.isArray(t)?t:[t]).join(",")})}(n);i.default.get(e+"/person/retrieve/"+n.id,{params:a({api_key:t},s),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(r(e))}).catch(function(e){u(o(e))})}).catch(function(e){u(e)})})}(n.basePath,n.apiKey,e)}},this.company={enrichment:function(e){return u(n.basePath,n.sandboxBasePath,n.apiKey,e,"company")},search:{elastic:function(e){return l(n.basePath,n.sandboxBasePath,n.apiKey,"elastic",e,"company")},sql:function(e){return l(n.basePath,n.sandboxBasePath,n.apiKey,"sql",e,"company")}},bulk:{enrichment:function(e){return function(e,t,n){var a={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":t,"User-Agent":"PDL-JS-SDK"};return new Promise(function(c,u){s(n,e,t,"Records","bulk").then(function(){i.default.post(e+"/company/enrich/bulk",n,{headers:a}).then(function(e){c(r(e))}).catch(function(e){u(o(e))})}).catch(function(e){u(e)})})}(n.basePath,n.apiKey,e)}},cleaner:function(e){return c(n.basePath,n.apiKey,e,"company")}},this.school={cleaner:function(e){return c(n.basePath,n.apiKey,e,"school")}},this.location={cleaner:function(e){return c(n.basePath,n.apiKey,e,"location")}},this.autocomplete=function(e){return function(e,t,n){return new Promise(function(c,u){s(n,e,t,null,"autocomplete").then(function(){i.default.get(e+"/autocomplete",{params:a({api_key:t},{field:n.field,text:n.text||"",size:n.size||10,pretty:n.pretty||!1,titlecase:n.titlecase||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(r(e))}).catch(function(e){u(o(e))})}).catch(function(e){u(e)})})}(n.basePath,n.apiKey,e)},this.jobTitle=function(e){return function(e,t,n){return new Promise(function(c,u){s(n,e,t,null,"jobTitle").then(function(){i.default.get(e+"/job_title/enrich",{params:a({api_key:t},{job_title:n.jobTitle,pretty:n.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(r(e))}).catch(function(e){u(o(e))})}).catch(function(e){u(e)})})}(n.basePath,n.apiKey,e)},this.skill=function(e){return function(e,t,n){return new Promise(function(c,u){s(n,e,t,null,"skill").then(function(){i.default.get(e+"/skill/enrich",{params:a({api_key:t},{skill:n.skill,pretty:n.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(r(e))}).catch(function(e){u(o(e))})}).catch(function(e){u(e)})})}(n.basePath,n.apiKey,e)},this.ip=function(e){return function(e,t,n){return new Promise(function(c,u){s(n,e,t,null,"ip").then(function(){i.default.get(e+"/ip/enrich",{params:a({api_key:t},n),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(r(e))}).catch(function(e){u(o(e))})}).catch(function(e){u(e)})})}(n.basePath,n.apiKey,e)}}; //# sourceMappingURL=index.cjs.map