import{R}from"./SmartConsole.13554642.js";import{d as S,b as d,c as v,w as o,f as l,u as e,c4 as _,H as B,G as E,r as G,b0 as p,cb as y,ad as O,d2 as b,ez as k,bu as A,cG as T,eu as C,eA as P}from"./registerWidgets.e46eca28.js";import{A as m,a as F}from"./Title.6ee361e2.js";import{F as U}from"./Form.6fcc3ee8.js";import{A as Q}from"./index.3579f3be.js";import{D as x,A as V}from"./index.5eb2b06c.js";import{A as $}from"./index.00020abd.js";import{A as w}from"./index.aba1cab9.js";import{A as j}from"./index.43b1476f.js";(function(){try{var f=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},u=new Error().stack;u&&(f._sentryDebugIds=f._sentryDebugIds||{},f._sentryDebugIds[u]="34a1d1a6-c911-482f-8b2a-5dc626f9715a",f._sentryDebugIdIdentifier="sentry-dbid-34a1d1a6-c911-482f-8b2a-5dc626f9715a")}catch{}})();const te=S({__name:"HookSettings",props:{hook:{}},setup(f){return(u,c)=>(d(),v(e(U),{layout:"vertical"},{default:o(()=>[l(e(m),{label:"Name",required:""},{default:o(()=>[l(e(_),{value:u.hook.title,"onUpdate:value":c[0]||(c[0]=g=>u.hook.title=g)},null,8,["value"])]),_:1}),l(R,{runtime:u.hook},null,8,["runtime"])]),_:1}))}}),J={key:1},ae=S({__name:"HookTester",props:{hook:{},logService:{}},setup(f){const u=f,c=[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"}],g=B(()=>{var s;if((s=t.response)!=null&&s.status)return t.response.status>=500?"red":t.response.status>=400?"orange":t.response.status>=200?"green":"blue"}),t=E({queryParams:[],headers:[{key:"Content-Type",value:"application/json"}],method:"POST",body:JSON.stringify({firstName:"John",lastName:"Doe",age:25,address:{streetAddress:"21 2nd Ave",city:"New York",state:"NY",postalCode:"10021"}},null,4)}),h=G(!1),D=async()=>{h.value=!0;try{const s=await u.hook.test({method:t.method,query:t.queryParams.reduce((n,{name:a,value:r})=>(a&&r&&(n[a]=r),n),{}),body:t.body,headers:t.headers.reduce((n,{key:a,value:r})=>(a&&r&&(n[a]=r),n),{})});t.response=s,s.stderr&&u.logService.log({type:"stderr",log:s.stderr}),s.stdout&&u.logService.log({type:"stdout",log:s.stdout})}finally{h.value=!1}},H=()=>{t.queryParams.push({name:"",value:""})},N=s=>{t.queryParams=t.queryParams.filter((n,a)=>a!==s)},I=()=>{t.headers.push({key:"",value:""})},q=s=>{t.headers=t.headers.filter((n,a)=>a!==s)};return(s,n)=>(d(),v(e(U),{layout:"vertical"},{default:o(()=>[l(e($),{align:"middle",justify:"space-between"},{default:o(()=>[l(e(F),{level:3},{default:o(()=>[p("Request configuration")]),_:1}),l(e(y),{loading:h.value,onClick:D},{default:o(()=>[p(" Run ")]),_:1},8,["loading"])]),_:1}),l(e(m),{label:"Method"},{default:o(()=>[l(e(O),{value:t.method,options:c,onSelect:n[0]||(n[0]=a=>t.method=a)},null,8,["value"])]),_:1}),(d(!0),b(A,null,k(t.queryParams,(a,r)=>(d(),v(e(m),{key:r,label:r===0?"Query Params":void 0},{default:o(()=>[l(e(w),null,{default:o(()=>[l(e(_),{value:a.name,"onUpdate:value":i=>a.name=i,type:"text",placeholder:"name"},null,8,["value","onUpdate:value"]),l(e(_),{value:a.value,"onUpdate:value":i=>a.value=i,type:"text",placeholder:"value"},null,8,["value","onUpdate:value"]),l(e(y),{danger:"",onClick:i=>N(r)},{default:o(()=>[p("remove")]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1032,["label"]))),128)),l(e(m),null,{default:o(()=>[l(e(y),{type:"dashed",style:{width:"100%"},onClick:H},{default:o(()=>[p("Add Query Param")]),_:1})]),_:1}),(d(!0),b(A,null,k(t.headers,(a,r)=>(d(),v(e(m),{key:r,label:r===0?"Headers":void 0},{default:o(()=>[l(e(w),null,{default:o(()=>[l(e(_),{value:a.key,"onUpdate:value":i=>a.key=i,type:"text",placeholder:"name"},null,8,["value","onUpdate:value"]),l(e(_),{value:a.value,"onUpdate:value":i=>a.value=i,type:"text",placeholder:"value"},null,8,["value","onUpdate:value"]),l(e(y),{danger:"",onClick:i=>q(r)},{default:o(()=>[p("remove")]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1032,["label"]))),128)),l(e(m),null,{default:o(()=>[l(e(y),{type:"dashed",style:{width:"100%"},onClick:I},{default:o(()=>[p("Add Header")]),_:1})]),_:1}),t.method!=="GET"?(d(),v(e(m),{key:0,label:"Body"},{default:o(()=>[l(e(T),{value:t.body,"onUpdate:value":n[1]||(n[1]=a=>t.body=a)},null,8,["value"])]),_:1})):C("",!0),l(e(j),{orientation:"left"},{default:o(()=>[p("Response")]),_:1}),t.response?(d(),b("div",J,[l(e(Q),{color:g.value},{default:o(()=>[p(P(t.response.status),1)]),_:1},8,["color"]),l(e(V),null,{default:o(()=>[(d(!0),b(A,null,k(t.response.headers,(a,r)=>(d(),v(e(x),{key:r,label:r},{default:o(()=>[p(P(a),1)]),_:2},1032,["label"]))),128))]),_:1}),l(e(T),{value:t.response.body},null,8,["value"])])):C("",!0)]),_:1}))}});export{ae as _,te as a};
//# sourceMappingURL=HookTester.vue_vue_type_script_setup_true_lang.b64d484b.js.map
