var h=function(){h=Object.assign||function(s){for(var o,n=1,a=arguments.length;n<a;n++){o=arguments[n];for(var r in o)if(Object.prototype.hasOwnProperty.call(o,r))s[r]=o[r]}return s};return h.apply(this,arguments)};var y=function(s,o,n,a){function r(e){return e instanceof n?e:new n(function(u){u(e)})}return new(n||(n=Promise))(function(e,u){function c(i){try{t(a.next(i))}catch(f){u(f)}}function l(i){try{t(a["throw"](i))}catch(f){u(f)}}function t(i){i.done?e(i.value):r(i.value).then(c,l)}t((a=a.apply(s,o||[])).next())})};var b=function(s,o){var n={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=c(0),u["throw"]=c(1),u["return"]=c(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(t){return function(i){return l([t,i])}}function l(t){if(a)throw new TypeError("Generator is already executing.");while(u&&(u=0,t[0]&&(n=0)),n)try{if(a=1,r&&(e=t[0]&2?r["return"]:t[0]?r["throw"]||((e=r["return"])&&e.call(r),0):r.next)&&!(e=e.call(r,t[1])).done)return e;if(r=0,e)t=[t[0]&2,e.value];switch(t[0]){case 0:case 1:e=t;break;case 4:n.label++;return{value:t[1],done:false};case 5:n.label++;r=t[1];t=[0];continue;case 7:t=n.ops.pop();n.trys.pop();continue;default:if(!(e=n.trys,e=e.length>0&&e[e.length-1])&&(t[0]===6||t[0]===2)){n=0;continue}if(t[0]===3&&(!e||t[1]>e[0]&&t[1]<e[3])){n.label=t[1];break}if(t[0]===6&&n.label<e[1]){n.label=e[1];e=t;break}if(e&&n.label<e[2]){n.label=e[2];n.ops.push(t);break}if(e[2])n.ops.pop();n.trys.pop();continue}t=o.call(s,n)}catch(i){t=[6,i];r=0}finally{a=e=0}if(t[0]&5)throw t[1];return{value:t[0]?t[1]:void 0,done:true}}};import{FaasError as d}from"./error";import{wrapCallback as v}from"./utils";export var createCallFunction=function(s){var o=s.httpclient;var n=function(a){return y(void 0,void 0,void 0,function(){var r,e,u,c,l,t,i;return b(this,function(f){switch(f.label){case 0:if(!a.name){throw d.INVALID_PARAM_ERR("name","\u7F3A\u5931")}r=h(h({},a.headers),{"x-to-function-name":a.name,"x-alipay-cloud-mode":"function"});if(a.async){r["x-function-invoke-type"]="async"}e="POST";u="/functions/invokeFunction";return[4,o.request({method:e,path:u,data:a.data,headers:r,responseDataType:a.resultDataType,timeout:a.timeout})];case 1:c=f.sent();if(c.status!==200){l=-1;t="";i=c.data;if(i){l=i.errCode,t=i.errMsg;if(i.errDetail){t+="\uFF0C\u8BE6\u60C5\uFF1A".concat(i.errDetail)}}throw d.SERVER_ERR(l,t,c.requestID,c.status)}return[2,{requestID:c.requestID,result:c.data,headers:c.headers}]}})})};return v(n)};