"use strict";(self.webpackChunkdami=self.webpackChunkdami||[]).push([[5401],{85401:(t,a,e)=>{e.r(a),e.d(a,{default:()=>u,webhook:()=>d});var r=e(31528),n=e.n(r),o=e(31263);const s={text:"text/plain",json:"application/json","form-data":"multipart/form-data",form:"application/x-www-form-urlencoded"},i=["GET","DELETE"];async function l({url:t,contentType:a,headers:e,timeout:r,body:n,method:l}){const c=new AbortController,d=setTimeout((()=>{c.abort()}),r);try{const r=(t=>{const a={};return t?(t.forEach((t=>{t.name&&t.value&&(a[t.name]=t.value)})),a):a})(e),u={method:l||"POST",headers:{"Content-Type":s[a||"json"],...r},signal:c.signal};i.includes(l||"POST")||(0,o.cb)(n)||(u.body=((t,a)=>{if("text/plain"===a)return t;const e=(0,o.Rx)(t,new Error("invalid-body"));if(e instanceof Error)throw e;if("application/x-www-form-urlencoded"===a)return new URLSearchParams(e);if("multipart/form-data"===a){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new Error("The body must be 2D Array");const t=new FormData;return e.forEach((a=>{t.append(...a)})),t}return JSON.stringify(e)})(n,u.headers["Content-Type"]));const h=await fetch(t,u);return clearTimeout(d),h}catch(t){throw clearTimeout(d),t}}var c=e(43210);async function d({data:t,id:a},{refData:e}){const r=this.getBlockConnections(a),s=this.getBlockConnections(a,"fallback");try{if((0,o.cb)(t.url))throw new Error("url-empty");if(!t.url.startsWith("http")){const a=new Error("invalid-active-tab");throw a.data={url:t.url},a}const a=[];for(const{value:r,name:n}of t.headers){const t=await(0,c.Z)(r,e).value;a.push({name:n,value:t})}const i=await l({...t,headers:a});if(!i.ok){if(s&&s.length>0)return{data:"",nextBlockId:s};throw new Error(`(${i.status}) ${i.statusText}`)}if(!t.assignVariable&&!t.saveData)return{data:"",nextBlockId:r};let d="";if("json"===t.responseType){const a=await i.json();d=n().get(a,t.dataPath)}else if("base64"===t.responseType){const t=await i.blob(),a=await function(t){return new Promise((a=>{const e=new FileReader;e.onload=()=>{a(e.result)},e.readAsDataURL(t)}))}(t);d=a}else d=await i.text();return t.assignVariable&&this.setVariable(t.variableName,d),t.saveData&&("$assignColumns"===t.dataColumn&&Array.isArray(d)?this.addDataToColumn(d):this.addDataToColumn(t.dataColumn,d)),{nextBlockId:r,data:d}}catch(t){if(s&&"Failed to fetch"===t.message)return{data:"",nextBlockId:s};throw t.nextBlockId=r,t}}const u=d}}]);