"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../index.js"),u=require("../utils/request.js"),t=require("../utils/utils.js"),T=(l,a,b)=>new Promise(function(r,V){const{api:s}=l.source;try{if(s){let{isHeaders:D,isBody:h,headers:c,contentType:S,url:e,postParam:i}=s;const y=t.DataSourceUtils.getEnvironments(),p=t.DataSourceUtils.getVariableData(),n=q=>{q.then(U=>{if(U.status===200){const{filter:P,mapping:g,isUserdata:m}=l.source;E.SHJDatasourceV2.processData(P,U.data,g,a,l.source.dynamicMapping,b,m).then(f=>{f&&r(f)}).catch(()=>r(t.DataSourceUtils.noneData(a)));return}r(t.DataSourceUtils.noneData(a))}).catch(()=>{r(t.DataSourceUtils.noneData(a))})},o=t.DataSourceUtils.replaceEnvVariables(e,y);e=t.DataSourceUtils.replaceURLVariables(e,p),h&&(i=t.DataSourceUtils.replaceObjectVariables(i,p)),D&&(c=t.DataSourceUtils.replaceObjectVariables(c,p)),s.type==="GET"&&n(u.httpRequest.get(o+e,{headers:c})),s.type==="POST"&&n(u.httpRequest.post(o+e,i,{headers:c},S)),s.type==="PUT"&&n(u.httpRequest.put(o+e,i,{headers:c},S)),s.type==="DELETE"&&n(u.httpRequest.delete(o+e,{headers:c}))}else r(t.DataSourceUtils.noneData(a))}catch{r(t.DataSourceUtils.noneData(a))}});exports.parseAPIPort=T;
