apitestcenter 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/THIRD-PARTY-NOTICES-UI.txt +1 -1
  2. package/dist/THIRD-PARTY-NOTICES.txt +105 -1
  3. package/dist/cli.mjs +5213 -227
  4. package/dist/ui/404/index.html +1 -1
  5. package/dist/ui/404.html +1 -1
  6. package/dist/ui/__next.__PAGE__.txt +15 -14
  7. package/dist/ui/__next._full.txt +13 -12
  8. package/dist/ui/__next._tree.txt +2 -2
  9. package/dist/ui/_next/static/chunks/01tk3yrimgagm.js +2 -0
  10. package/dist/ui/_next/static/chunks/{3ad2zh-p8_xhv.js → 0gfm4dc7bjzy1.js} +3 -3
  11. package/dist/ui/_next/static/chunks/{2idsynwg5lkk7.js → 115l_disvbdxa.js} +1 -1
  12. package/dist/ui/_next/static/chunks/{13xdai3-mkg7c.js → 199g-q88qtg_i.js} +549 -134
  13. package/dist/ui/_next/static/chunks/1ax1v4312l2w9.js +1 -0
  14. package/dist/ui/_next/static/chunks/1ffsp9e_ihf8c.js +19 -0
  15. package/dist/ui/_next/static/chunks/239j59-_u852y.css +3 -0
  16. package/dist/ui/_next/static/chunks/2xiq0vxqp_rsu.js +1 -0
  17. package/dist/ui/_next/static/chunks/{02myfb0nlri-z.js → 3jywp_61ylz0z.js} +1 -1
  18. package/dist/ui/_next/static/media/icon.1oy4kb0w-k_2v.png +0 -0
  19. package/dist/ui/_not-found/__next._full.txt +12 -11
  20. package/dist/ui/_not-found/__next._not-found.__PAGE__.txt +17 -16
  21. package/dist/ui/_not-found/__next._tree.txt +2 -2
  22. package/dist/ui/_not-found/index.html +1 -1
  23. package/dist/ui/_not-found/index.txt +12 -11
  24. package/dist/ui/compare/__next._full.txt +13 -12
  25. package/dist/ui/compare/__next._tree.txt +2 -2
  26. package/dist/ui/compare/__next.compare.__PAGE__.txt +18 -17
  27. package/dist/ui/compare/index.html +1 -1
  28. package/dist/ui/compare/index.txt +13 -12
  29. package/dist/ui/history/__next._full.txt +14 -13
  30. package/dist/ui/history/__next._tree.txt +2 -2
  31. package/dist/ui/history/__next.history.__PAGE__.txt +19 -18
  32. package/dist/ui/history/index.html +1 -1
  33. package/dist/ui/history/index.txt +14 -13
  34. package/dist/ui/icon.png +0 -0
  35. package/dist/ui/index.html +1 -1
  36. package/dist/ui/index.txt +13 -12
  37. package/dist/ui/preview/__next._full.txt +14 -13
  38. package/dist/ui/preview/__next._tree.txt +2 -2
  39. package/dist/ui/preview/__next.preview.__PAGE__.txt +19 -18
  40. package/dist/ui/preview/index.html +1 -1
  41. package/dist/ui/preview/index.txt +14 -13
  42. package/dist/ui/suite/__next._full.txt +13 -12
  43. package/dist/ui/suite/__next._tree.txt +2 -2
  44. package/dist/ui/suite/__next.suite.__PAGE__.txt +18 -17
  45. package/dist/ui/suite/index.html +1 -1
  46. package/dist/ui/suite/index.txt +13 -12
  47. package/dist/ui/tests/__next._full.txt +12 -11
  48. package/dist/ui/tests/__next._tree.txt +2 -2
  49. package/dist/ui/tests/__next.tests.__PAGE__.txt +17 -16
  50. package/dist/ui/tests/index.html +1 -1
  51. package/dist/ui/tests/index.txt +12 -11
  52. package/package.json +1 -1
  53. package/dist/ui/_next/static/chunks/2i7s5kuurlkr6.css +0 -3
  54. package/dist/ui/_next/static/chunks/2nxnxp6p-40kg.js +0 -1
  55. package/dist/ui/_next/static/chunks/2od90u8fd_sla.js +0 -18
  56. package/dist/ui/_next/static/chunks/36lx6-56-udwb.js +0 -2
  57. package/dist/ui/_next/static/chunks/3qxq1d9u_kohv.js +0 -1
  58. /package/dist/ui/_next/static/{C6zMFzDkVqF8IXny_v7JK → XGxojrJs_nD9y7xtRMI1q}/_buildManifest.js +0 -0
  59. /package/dist/ui/_next/static/{C6zMFzDkVqF8IXny_v7JK → XGxojrJs_nD9y7xtRMI1q}/_clientMiddlewareManifest.js +0 -0
  60. /package/dist/ui/_next/static/{C6zMFzDkVqF8IXny_v7JK → XGxojrJs_nD9y7xtRMI1q}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63343,44794,36620,73436,60566,e=>{"use strict";var t=e.i(61666);e.i(24856);var s=e.i(59100),a=e.i(71189),n=e.i(87283),r=e.i(83067),l=e.i(22543),i=e.i(31753),o=e.i(28867);e.i(42674);var d=e.i(5305);let c={smoke:"2 users for 30s. Proves the endpoint works under a little concurrency.",average:"10 users for 5m. Typical day-to-day traffic.",stress:"Ramp to 20 users, hold 1m, ramp down. Looks for the breaking point.",spike:"5 users, a sudden jump to 50, then back to 5. Does it survive the burst and recover?",soak:"10 users for 30m. Finds memory leaks and slow degradation that short tests miss.",custom:"Your own numbers."};function u({label:e,value:s,min:a,max:n,onChange:r,hint:i}){return(0,t.jsxs)("label",{className:"block",children:[(0,t.jsxs)("span",{className:"mb-1 flex items-center gap-1 text-xs text-mute",children:[e,i?(0,t.jsx)(l.Hint,{label:`About ${e}`,text:i}):null]}),(0,t.jsx)("input",{type:"number",min:a,max:n,value:s,onChange:e=>r(m(e.target.value,a,n)),className:"input font-mono"})]})}function h({stages:e,unit:s,rate:r,onChange:l}){let i=(t,s)=>l(e.map((e,a)=>a===t?{...e,...s}:e));return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs text-mute",children:"Each stage moves linearly to its target over its duration. Hold steady by repeating the same target."}),(0,t.jsxs)("div",{className:"overflow-hidden rounded-md border border-line",children:[(0,t.jsxs)("div",{className:"grid grid-cols-[2.5rem_minmax(0,1fr)_minmax(0,1fr)_2rem] bg-panel-2 text-xs text-mute",children:[(0,t.jsx)("span",{className:"px-2 py-1.5",children:"#"}),(0,t.jsx)("span",{className:"border-l border-line px-2 py-1.5",children:"Duration"}),(0,t.jsxs)("span",{className:"border-l border-line px-2 py-1.5",children:["Target (",s,")"]}),(0,t.jsx)("span",{})]}),e.map((s,a)=>{let o=(0,d.durationError)(s.duration,!1);return(0,t.jsxs)("div",{className:"grid grid-cols-[2.5rem_minmax(0,1fr)_minmax(0,1fr)_2rem] border-t border-line",children:[(0,t.jsx)("span",{className:"px-2 py-1.5 font-mono text-xs text-mute",children:a+1}),(0,t.jsx)("input",{"aria-label":`Stage ${a+1} duration`,"aria-invalid":!!o||void 0,title:o,value:s.duration,onChange:e=>i(a,{duration:e.target.value}),className:`min-w-0 border-l border-line bg-transparent px-2 py-1.5 font-mono text-[13px] outline-none focus:bg-panel-2 ${o?"text-bad":"text-ink"}`}),(0,t.jsx)("input",{"aria-label":`Stage ${a+1} target`,type:"number",min:0,max:r?1e5:500,value:s.target,onChange:e=>i(a,{target:m(e.target.value,0,r?1e5:500)}),className:"min-w-0 border-l border-line bg-transparent px-2 py-1.5 font-mono text-[13px] text-ink outline-none focus:bg-panel-2"}),(0,t.jsx)("button",{type:"button","aria-label":`Remove stage ${a+1}`,disabled:e.length<=1,onClick:()=>l(e.filter((e,t)=>t!==a)),className:"grid place-items-center text-mute hover:text-bad disabled:opacity-30",children:(0,t.jsx)(n.X,{size:13})})]},a)})]}),(0,t.jsxs)("button",{type:"button",disabled:e.length>=20,onClick:()=>l([...e,{duration:"30s",target:e[e.length-1]?.target??1}]),className:"inline-flex items-center gap-1 text-xs text-accent hover:underline disabled:opacity-40",children:[(0,t.jsx)(a.Plus,{size:12,"aria-hidden":!0})," Add stage"]})]})}function m(e,t,s){let a=Math.round(Number(e));return Number.isFinite(a)?Math.min(s,Math.max(t,a)):t}function p(e){let t="rate"===e.mode;if(e.stages&&e.stages.length){let t=[[0,0]],a=0;for(let n of e.stages)a+=(0,s.durationToMs)(n.duration),t.push([a,n.target]);return{points:t,totalMs:a,peak:Math.max(0,...e.stages.map(e=>e.target))}}let a=t?e.rps??20:e.vus,n=(0,s.durationToMs)(e.rampUp),r=(0,s.durationToMs)(e.duration),l=(0,s.durationToMs)(e.rampDown);return{points:[[0,n>0?0:a],[n,a],[n+r,a],[n+r+l,l>0?0:a]],totalMs:n+r+l,peak:a}}function x(e){let{totalMs:t,peak:s}=p(e),a="rate"===e.mode?"req/s":1===s?"VU":"VUs";return`${e.stages?.length?"peak ":""}${s.toLocaleString()} ${a} \xb7 ${f(t)}`}function f(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60);return s<60?t%60?`${s}m ${t%60}s`:`${s}m`:`${Math.floor(s/60)}h ${s%60}m`}function b({load:e}){let{points:s,totalMs:a,peak:n}=p(e),r=s.map(([e,t])=>`${e/Math.max(a,1)*300},${56-t/Math.max(n,1)*50}`).join(" "),l=`0,56 ${r} 300,56`;return(0,t.jsxs)("figure",{className:"rounded-md border border-line bg-panel-2 px-3 py-2",children:[(0,t.jsxs)("figcaption",{className:"mb-1 flex justify-between text-xs text-mute",children:[(0,t.jsx)("span",{children:"Planned load"}),(0,t.jsx)("span",{className:"font-mono text-ink",children:x(e)})]}),(0,t.jsxs)("svg",{viewBox:"0 0 300 56",preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":`Load profile: ${x(e)}`,children:[(0,t.jsx)("polygon",{points:l,fill:"var(--series-1)",fillOpacity:.15}),(0,t.jsx)("polyline",{points:r,fill:"none",stroke:"var(--series-1)",strokeWidth:2,vectorEffect:"non-scaling-stroke"})]}),(0,t.jsxs)("div",{className:"mt-1 flex justify-between font-mono text-[11px] text-mute",children:[(0,t.jsx)("span",{children:"0s"}),(0,t.jsx)("span",{children:"rate"===e.mode?"requests per second":"simulated users"}),(0,t.jsx)("span",{children:f(a)})]})]})}e.s(["LoadEditor",0,function({load:e,onChange:a}){let[n,m]=(0,r.useState)(!1),p=t=>a({...e,...t,preset:"custom"}),x="rate"===e.mode,f=!!(e.stages&&e.stages.length);return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Segmented,{label:"Load preset",value:e.preset,onChange:t=>a((0,d.applyPreset)(e,t)),options:[{value:"smoke",label:"Smoke"},{value:"average",label:"Average"},{value:"stress",label:"Stress"},{value:"spike",label:"Spike"},{value:"soak",label:"Soak"},{value:"custom",label:"Custom"}]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-mute",children:c[e.preset]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{className:"mb-1 flex items-center gap-1 text-xs text-mute",children:["Drive load by",(0,t.jsx)(l.Hint,{label:"About users vs rate",text:"Simulated users (VUs): N clients each send, wait for the answer, and send again — a slow API gets fewer requests. Requests per second: k6 holds the rate whatever the API does — the honest way to test capacity."})]}),(0,t.jsx)(o.Segmented,{label:"Drive load by",value:e.mode??"users",onChange:e=>p({mode:e}),options:[{value:"users",label:"Simulated users"},{value:"rate",label:"Requests per second"}]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"mb-1 block text-xs text-mute",children:"Shape"}),(0,t.jsx)(o.Segmented,{label:"Load shape",value:f?"stages":"simple",onChange:function(t){if("simple"===t)return p({stages:null});let a=x?e.rps??20:e.vus,n=[];(0,s.durationToMs)(e.rampUp)>0&&n.push({duration:e.rampUp,target:a}),n.push({duration:e.duration,target:a}),(0,s.durationToMs)(e.rampDown)>0&&n.push({duration:e.rampDown,target:0}),p({stages:n})},options:[{value:"simple",label:"Ramp · hold · down"},{value:"stages",label:"Step by step"}]})]})]}),f?(0,t.jsx)(h,{stages:e.stages,unit:x?"req/s":"VUs",rate:x,onChange:e=>p({stages:e})}):(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[x?(0,t.jsx)(u,{label:"Requests / second",value:e.rps??20,min:1,max:1e5,onChange:e=>p({rps:e})}):(0,t.jsx)(u,{label:"Simulated users",hint:"Concurrent clients running from this computer. 50+ will load both the API and this machine.",value:e.vus,min:1,max:500,onChange:e=>p({vus:e})}),(0,t.jsx)(i.LabeledInput,{label:"Hold for",mono:!0,value:e.duration,error:(0,d.durationError)(e.duration,!1),onChange:e=>p({duration:e})}),(0,t.jsx)(i.LabeledInput,{label:"Ramp up",mono:!0,value:e.rampUp,error:(0,d.durationError)(e.rampUp),onChange:e=>p({rampUp:e})}),(0,t.jsx)(i.LabeledInput,{label:"Ramp down",mono:!0,value:e.rampDown,error:(0,d.durationError)(e.rampDown),onChange:e=>p({rampDown:e})})]}),x?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:(0,t.jsx)(u,{label:"Max simulated users",hint:"k6 starts more VUs when responses slow down, up to this ceiling. If it runs out, requests are dropped and the report says how many.",value:e.maxVus??100,min:1,max:2e3,onChange:e=>p({maxVus:e})})}):null,(0,t.jsx)(b,{load:e}),(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>m(e=>!e),"aria-expanded":n,children:n?"Hide pacing options":"Pacing options"}),n?(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[x?(0,t.jsx)("p",{className:"text-xs text-mute sm:col-span-2",children:"Think time does not apply when holding a request rate — k6 paces the requests itself."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u,{label:"Think time (ms)",value:e.thinkTimeMs,min:0,max:6e5,onChange:e=>p({thinkTimeMs:e})}),(0,t.jsx)(u,{label:"Random extra (ms)",value:e.thinkJitterMs,min:0,max:6e5,onChange:e=>p({thinkJitterMs:e})})]}),(0,t.jsx)(i.LabeledInput,{label:"Graceful stop",mono:!0,value:e.gracefulStop,error:(0,d.durationError)(e.gracefulStop),onChange:e=>p({gracefulStop:e}),hint:"Time in-flight requests get to finish."})]}):null]})},"profileSummary",0,x],63343);var v=e.i(1675),g=e.i(458),j=e.i(80707);let y=null,w=null,N=new Set;function k(){return w??=fetch("/engine/local-servers",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>(e&&(y=e.servers),y)).catch(()=>y).finally(()=>{w=null,N.forEach(e=>e())}),N.forEach(e=>e()),w}var C=e.i(6278);let $=/^\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/,S=/^(https?):\/\/(localhost|127\.0\.0\.1)(?::(\d{1,5}))?(?=[/?#]|$)/i,q="\0none",E="\0local-other",R="apitestcenter-local-ports",T={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad",HEAD:"text-mute",OPTIONS:"text-mute"};function M(){try{let e=JSON.parse(localStorage.getItem(R)??"[]");return(Array.isArray(e)?e.filter(e=>Number.isInteger(e)&&e>0&&e<65536):[]).slice(0,5)}catch{return[]}}function L(e){try{localStorage.setItem(R,JSON.stringify([e,...M().filter(t=>t!==e)].slice(0,5)))}catch{}}let P=(0,r.forwardRef)(function({draft:e,onChange:s,onImported:a,actions:l},i){let{vars:o,environments:c,activeEnv:u}=(0,C.useWorkspace)(),[h,m]=(0,r.useState)([]),[p,x]=(0,r.useState)(null),[f,b]=(0,r.useState)(!1),R=(0,r.useRef)(null);(0,r.useEffect)(()=>m(M()),[]),(0,r.useEffect)(()=>{p&&R.current?.focus()},[p]);let P=e.url,A=$.exec(P)?.[1],D=Object.entries(o).filter(([e,t])=>/^https?:\/\//i.test(t.trim())&&("practiceApi"!==e||A===e)),z=(()=>{if(f)return null;let e=$.exec(P);if(e&&D.some(([t])=>t===e[1]))return{prefix:e[0],text:`{{${e[1]}}}`,value:e[1]};let t=S.exec(P);if(t){let e=t[1].toLowerCase(),s=t[3]??("https"===e?"443":"80");return{prefix:t[0],text:`${t[2]}${t[3]?`:${t[3]}`:""}`,value:`local:${e}:${s}`}}return null})(),H=P.startsWith("/"),O=H||""===P||null!=z,U=function(e){let[,t]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=()=>t(e=>e+1);return N.add(e),()=>void N.delete(e)},[]),(0,r.useEffect)(()=>{e&&null==y&&!w&&k()},[e]);let s=(0,r.useCallback)(()=>void k(),[]);return{servers:y??[],checked:null!=y,checking:null!=w,refresh:s}}(O),F=z?P.slice(z.prefix.length):P,I=e=>{let t=""===F||F.startsWith("/")||F.startsWith("?")?F:`/${F}`;return`${e}${t||(e.startsWith("{{")?"":"/")}`},B=U.servers,W=[...B.map(e=>({value:`local:${e.scheme}:${e.port}`,label:`localhost:${e.port}`,hint:[e.name,e.scheme,e.selfSigned?"self-signed":""].filter(Boolean).join(" · "),text:`localhost ${e.port} ${e.name??""}`,className:"font-mono",group:"local",inline:!0})),...h.filter(e=>!B.some(t=>t.port===e)).map(e=>({value:`local:http:${e}`,label:`localhost:${e}`,hint:U.checked?"used before · not running now":"used before",text:`localhost ${e}`,className:"font-mono text-mute",group:"local",inline:!0}))];z?.value.startsWith("local:")&&!W.some(e=>e.value===z.value)&&W.unshift({value:z.value,label:z.text,hint:"in this request",text:z.text,className:"font-mono",group:"local",inline:!0});let V=null!=z&&!z.value.startsWith("local:"),_=[...D.length?[{id:"env",label:u?.name??"Variables",text:u?.name??"variables",defaultOpen:V||null==z,action:c.length>1?{label:"switch",title:"Choose another environment",onClick:()=>setTimeout(()=>document.querySelector('button[role="combobox"][aria-label="Environment"]')?.click(),0)}:void 0}]:[],{id:"local",label:"Localhost",text:"localhost",hint:U.checking&&!U.checked?"checking…":`${B.length||"none"} running${U.checking?" · checking…":""}`,defaultOpen:!D.length&&null==z,action:{label:(0,t.jsx)(g.RefreshCw,{size:12,"aria-hidden":!0,className:U.checking?"animate-spin":""}),title:"Check again for running servers",onClick:U.refresh,keepOpen:!0}}],J=z?"text-accent":H?"text-warn":"text-mute";return(0,t.jsxs)("div",{className:"flex flex-wrap items-stretch gap-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-[1_1_28rem] overflow-hidden rounded-lg border border-line bg-panel-2 focus-within:border-accent",children:[(0,t.jsx)(j.Select,{label:"Method",value:e.method,onChange:t=>s({...e,method:t}),options:d.METHODS.map(e=>({value:e,label:e,className:`font-mono font-medium ${T[e]}`})),minWidth:140,className:`shrink-0 border-r border-line px-3 font-mono text-sm font-medium outline-none focus-visible:bg-panel ${T[e.method]}`}),p?(0,t.jsxs)("form",{className:"flex shrink-0 items-center gap-1 border-r border-line px-2 font-mono text-xs",onSubmit:t=>{t.preventDefault(),(()=>{if(!p)return;let t=Number(p.port);!Number.isInteger(t)||t<1||t>65535||(L(t),m(M()),s((0,d.withUrl)(e,I(`${p.scheme}://localhost:${t}`))),x(null))})()},onKeyDown:e=>"Escape"===e.key&&x(null),children:[(0,t.jsx)("button",{type:"button",title:"Switch between http and https",onClick:()=>x({...p,scheme:"http"===p.scheme?"https":"http"}),className:"rounded px-1 text-accent hover:bg-panel",children:p.scheme}),(0,t.jsx)("span",{className:"text-mute",children:"://localhost:"}),(0,t.jsx)("input",{ref:R,value:p.port,onChange:e=>x({...p,port:e.target.value.replace(/\D/g,"").slice(0,5)}),inputMode:"numeric",placeholder:"8080","aria-label":"Port",className:"w-14 rounded border border-line bg-panel px-1.5 py-0.5 text-ink outline-none focus:border-accent"}),(0,t.jsx)("button",{type:"submit","aria-label":"Use this port",className:"rounded p-0.5 text-accent hover:bg-panel",children:(0,t.jsx)(v.Check,{size:14})}),(0,t.jsx)("button",{type:"button","aria-label":"Cancel",onClick:()=>x(null),className:"rounded p-0.5 text-mute hover:text-ink",children:(0,t.jsx)(n.X,{size:14})})]}):O?(0,t.jsx)(j.Select,{label:"Base URL",value:z?.value??q,onChange:t=>{if(t===E)return x({scheme:"http",port:""});if(t===q)return s((0,d.withUrl)(e,F));if(t.startsWith("local:")){let[,a,n]=t.split(":"),r=Number(n);return L(r),m(M()),s((0,d.withUrl)(e,I(`${a}://localhost:${r}`)))}s((0,d.withUrl)(e,I(`{{${t}}}`)))},onOpen:U.refresh,minWidth:320,buttonContent:z?.text??"Base URL",groups:_,options:[...D.map(([e,t])=>({value:e,label:`{{${e}}}`,hint:t,text:e,className:"font-mono text-accent",group:"env"})),...W,{value:E,label:"Another port…",text:"another port",group:"local"},{value:q,label:"No base URL — type the whole address",text:"no"}],className:`shrink-0 border-r border-line px-2.5 font-mono text-xs outline-none focus-visible:bg-panel ${J}`}):null,(0,t.jsx)("label",{className:"sr-only",htmlFor:"request-url",children:"Request URL"}),(0,t.jsx)("input",{ref:i,id:"request-url",value:F,spellCheck:!1,autoComplete:"off",onChange:t=>{let a=t.target.value,n=/^(https?:\/\/|\{\{)/i.test(a.trim())||""===F&&""!==a&&!/^[/?#]/.test(a);/^https?:\/\//i.test(a.trim())&&b(!0),s((0,d.withUrl)(e,z&&!n?`${z.prefix}${a}`:a))},onBlur:()=>b(!1),onPaste:t=>{let n=(0,d.withPaste)(e,t.clipboardData.getData("text"));n&&(t.preventDefault(),s(n.draft),n.note&&a?.(n.note))},placeholder:z?"/path — after the base URL":"Paste a URL or a curl command, or type a /path",className:"min-w-0 flex-1 bg-transparent px-3 py-2.5 font-mono text-sm text-ink outline-none placeholder:text-mute"})]}),(0,t.jsx)("div",{className:"flex shrink-0 gap-2",children:l})]})});e.s(["RequestBar",0,P],44794);var A=e.i(95486),D=e.i(99522);let z=(0,D.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var H=e.i(89932),O=e.i(75117),U=e.i(88293);let F=(0,D.default)("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);var I=e.i(13318),B=e.i(56396),W=e.i(15060);let V="<hidden>";function _(e){let t=new Set(e.secretHeaders.map(e=>e.toLowerCase())),s=e.headers.map(([e,s])=>[e,t.has(e.toLowerCase())?function(e,t){if("authorization"===e.toLowerCase()||"proxy-authorization"===e.toLowerCase()){let e=/^(\w+)\s+/.exec(t);if(e)return`${e[1]} ${V}`}return V}(e,s):s]),a=e.url;if(e.secretQuery.length)try{let t=new URL(e.url);for(let s of e.secretQuery)t.searchParams.has(s)&&t.searchParams.set(s,V);a=t.toString().replace(/%3Chidden%3E/g,V)}catch{}return{...e,url:a,headers:s}}let J=[{id:"curl",label:"curl"},{id:"powershell",label:"PowerShell"},{id:"javascript",label:"JavaScript"},{id:"python",label:"Python"},{id:"csharp",label:"C#"},{id:"java",label:"Java"},{id:"go",label:"Go"},{id:"k6",label:"k6 load test"}],K=new Set(["host","content-length","connection","accept-encoding"]),G=e=>JSON.stringify(e),X=e=>`'${e.replace(/'/g,"'\\''")}'`,Z=e=>`'${e.replace(/'/g,"''")}'`,Q=e=>`@"${e.replace(/"/g,'""')}"`,Y=(0,D.default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Eye",0,Y],36620);let ee=(0,D.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);e.s(["EyeOff",0,ee],73436);var et=e.i(42967);let es="apitestcenter-code-target";function ea({sent:e}){let s=(0,B.useToast)(),[a,n]=(0,r.useState)(!1),[l,i]=(0,r.useState)("curl");(0,r.useEffect)(()=>i(function(){try{let e=localStorage.getItem(es);if(J.some(t=>t.id===e))return e}catch{}return"curl"}()),[]);let o=(0,r.useMemo)(()=>a?e:_(e),[e,a]),d=(0,r.useMemo)(()=>(function(e,t){let s=t.headers.filter(([e,t])=>!K.has(e.toLowerCase())&&!("user-agent"===e.toLowerCase()&&t.startsWith("ApiTestCenter/"))),a=t.body,n=t.method.toUpperCase(),r=[];switch(e){case"curl":for(let[e,l]of(r.push(`curl${"GET"===n&&void 0===a?"":` -X ${n}`} ${X(t.url)}`),s))r.push(` -H ${X(`${e}: ${l}`)}`);return void 0!==a&&r.push(` --data-raw ${X(a)}`),t.insecure&&r.push(" -k"),r.join(" \\\n");case"powershell":{let e=s.find(([e])=>"content-type"===e.toLowerCase())?.[1],l=s.filter(([e])=>"content-type"!==e.toLowerCase());if(l.length){for(let[e,t]of(r.push("$headers = @{"),l))r.push(` ${Z(e)} = ${Z(t)}`);r.push("}")}let i=[`-Uri ${Z(t.url)}`,`-Method ${n}`];return l.length&&i.push("-Headers $headers"),e&&i.push(`-ContentType ${Z(e)}`),void 0!==a&&i.push(/^[\x20-\x7e\r\n\t]*$/.test(a)?`-Body ${Z(a)}`:`-Body ([System.Text.Encoding]::UTF8.GetBytes(${Z(a)}))`),t.insecure&&i.push("-SkipCertificateCheck"),r.push(`$response = Invoke-WebRequest ${i.join(" ")}`,"$response.StatusCode","$response.Content"),r.join("\n")}case"javascript":if(r.push(`const response = await fetch(${G(t.url)}, {`,` method: ${G(n)},`),s.length){for(let[e,t]of(r.push(" headers: {"),s))r.push(` ${G(e)}: ${G(t)},`);r.push(" },")}return void 0!==a&&r.push(` body: ${G(a)},`),r.push("});","console.log(response.status);","console.log(await response.text());"),t.insecure&&r.unshift("// The certificate check was skipped in the app; in Node.js run with NODE_TLS_REJECT_UNAUTHORIZED=0 for a test server only."),r.join("\n");case"python":{if(r.push("import requests","",`url = ${G(t.url)}`),s.length){for(let[e,t]of(r.push("headers = {"),s))r.push(` ${G(e)}: ${G(t)},`);r.push("}")}void 0!==a&&r.push(`payload = ${G(a)}`);let e=[G(n),"url"];return s.length&&e.push("headers=headers"),void 0!==a&&e.push('data=payload.encode("utf-8")'),t.insecure&&e.push("verify=False"),r.push("",`response = requests.request(${e.join(", ")})`,"print(response.status_code)","print(response.text)"),r.join("\n")}case"csharp":{let e=s.find(([e])=>"content-type"===e.toLowerCase())?.[1],l=s.filter(([e])=>"content-type"!==e.toLowerCase());for(let[e,s]of(r.push("using System.Net.Http.Headers;",""),r.push(t.insecure?"using var client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator });":"using var client = new HttpClient();"),r.push(`var request = new HttpRequestMessage(new HttpMethod(${Q(n)}), ${Q(t.url)});`),l))r.push(`request.Headers.TryAddWithoutValidation(${Q(e)}, ${Q(s)});`);return void 0!==a&&(r.push(`request.Content = new StringContent(${Q(a)});`),e&&r.push(`request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(${Q(e)});`)),r.push("var response = await client.SendAsync(request);","Console.WriteLine((int)response.StatusCode);","Console.WriteLine(await response.Content.ReadAsStringAsync());"),r.join("\n")}case"java":for(let[e,a]of(r.push("import java.net.URI;","import java.net.http.HttpClient;","import java.net.http.HttpRequest;","import java.net.http.HttpResponse;",""),t.insecure&&r.push("// The certificate check was skipped in the app; Java's HttpClient needs an SSLContext that trusts the test server."),r.push("HttpClient client = HttpClient.newHttpClient();","HttpRequest request = HttpRequest.newBuilder()",` .uri(URI.create(${G(t.url)}))`),s))r.push(` .header(${G(e)}, ${G(a)})`);return r.push(` .method(${G(n)}, ${void 0!==a?`HttpRequest.BodyPublishers.ofString(${G(a)})`:"HttpRequest.BodyPublishers.noBody()"})`," .build();"),r.push("HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());","System.out.println(response.statusCode());","System.out.println(response.body());"),r.join("\n");case"go":{let e=['"fmt"','"io"','"net/http"',...void 0!==a?['"strings"']:[],...t.insecure?['"crypto/tls"']:[]].sort();for(let[l,i]of(r.push("package main","","import (",...e.map(e=>` ${e}`),")","","func main() {"),r.push(` req, err := http.NewRequest(${G(n)}, ${G(t.url)}, ${void 0!==a?`strings.NewReader(${G(a)})`:"nil"})`),r.push(" if err != nil {"," panic(err)"," }"),s))r.push(` req.Header.Set(${G(l)}, ${G(i)})`);return r.push(t.insecure?" client := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}":" client := http.DefaultClient"," res, err := client.Do(req)"," if err != nil {"," panic(err)"," }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(res.StatusCode)"," fmt.Println(string(data))","}"),r.join("\n")}case"k6":if(r.push('import http from "k6/http";','import { check, sleep } from "k6";',""),r.push(`export const options = { vus: 5, duration: "30s"${t.insecure?", insecureSkipTLSVerify: true":""} };`,""),r.push("export default function () {"),r.push(` const res = http.request(${G(n)}, ${G(t.url)}, ${void 0!==a?G(a):"null"}, {`),s.length){for(let[e,t]of(r.push(" headers: {"),s))r.push(` ${G(e)}: ${G(t)},`);r.push(" },")}return r.push(" });",' check(res, { "status is 2xx": (r) => r.status >= 200 && r.status < 300 });'," sleep(1);","}"),r.join("\n")}})(l,o),[l,o]),c=(0,r.useMemo)(()=>JSON.stringify(_(e))!==JSON.stringify(e),[e]),u=(e,t)=>{navigator.clipboard.writeText(e),s(`${t} copied`,"success")};return(0,t.jsxs)("div",{className:"space-y-4 overflow-auto",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("p",{className:"min-w-0 flex-1 font-mono text-[13px] break-all text-ink",children:[(0,t.jsx)("span",{className:"mr-2 font-medium text-accent",children:o.method}),o.url]}),c?(0,t.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),"aria-pressed":a,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-line px-2 py-1 text-xs text-mute hover:text-ink",children:[a?(0,t.jsx)(ee,{size:12,"aria-hidden":!0}):(0,t.jsx)(Y,{size:12,"aria-hidden":!0}),a?"Hide secrets":"Show secrets"]}):null]}),e.authNote||e.redirects?.length?(0,t.jsxs)("div",{className:"space-y-1 text-xs text-mute",children:[e.authNote?(0,t.jsxs)("p",{className:"flex items-start gap-1.5",children:[(0,t.jsx)(et.Info,{size:12,className:"mt-0.5 shrink-0","aria-hidden":!0}),e.authNote,"."]}):null,e.redirects?.length?(0,t.jsxs)("div",{children:["Then followed ",1===e.redirects.length?"a redirect":`${e.redirects.length} redirects`,":",(0,t.jsx)("ul",{className:"mt-0.5 space-y-0.5 font-mono",children:e.redirects.map((e,s)=>(0,t.jsxs)("li",{className:"break-all",children:["→ ",e]},s))})]}):null]}):null,(0,t.jsxs)("section",{"aria-label":"Headers sent",children:[(0,t.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"text-xs font-medium text-mute",children:"Headers"}),(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 text-xs text-mute hover:text-ink",onClick:()=>u(o.headers.map(([e,t])=>`${e}: ${t}`).join("\n"),"Headers"),children:[(0,t.jsx)(H.Copy,{size:12})," Copy"]})]}),(0,t.jsx)("div",{className:"overflow-auto rounded-md border border-line",children:(0,t.jsx)("table",{className:"w-full text-left text-[13px]",children:(0,t.jsx)("tbody",{children:o.headers.map(([e,s],a)=>(0,t.jsxs)("tr",{className:"border-t border-line first:border-t-0",children:[(0,t.jsx)("th",{scope:"row",className:"w-2/5 bg-panel-2 px-3 py-1.5 align-top font-mono font-normal text-mute",children:e}),(0,t.jsx)("td",{className:`px-3 py-1.5 font-mono break-all ${s.includes(V)?"text-mute italic":"text-ink"}`,children:s})]},a))})})})]}),(0,t.jsxs)("section",{"aria-label":"Body sent",children:[(0,t.jsx)("h3",{className:"mb-1.5 text-xs font-medium text-mute",children:"Body"}),void 0===e.body?(0,t.jsx)("p",{className:"text-xs text-mute",children:"No body."}):(0,t.jsxs)("pre",{className:"max-h-64 overflow-auto rounded-md border border-line bg-panel-2 p-3 font-mono text-[13px] leading-5 break-words whitespace-pre-wrap text-ink",children:[o.body,e.bodyTruncated?(0,t.jsxs)("span",{className:"text-warn",children:["\n","… first 64 KB shown"]}):null]})]}),(0,t.jsxs)("section",{"aria-label":"Code",children:[(0,t.jsxs)("div",{className:"mb-1.5 flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-xs font-medium text-mute",children:"Code"}),(0,t.jsx)(j.Select,{label:"Language",value:l,onChange:e=>{i(e);try{localStorage.setItem(es,e)}catch{}},options:J.map(e=>({value:e.id,label:e.label})),minWidth:180,className:"rounded-md border border-line bg-panel-2 px-2 py-1 text-xs text-ink outline-none focus-visible:border-accent"}),(0,t.jsxs)("button",{type:"button",className:"ml-auto inline-flex items-center gap-1 text-xs text-mute hover:text-ink",onClick:()=>u(d,"Code"),children:[(0,t.jsx)(H.Copy,{size:12})," Copy"]})]}),(0,t.jsx)("pre",{"aria-label":`${J.find(e=>e.id===l)?.label} code`,className:"max-h-96 overflow-auto rounded-md border border-line bg-panel-2 p-3 font-mono text-[12.5px] leading-5 whitespace-pre text-ink",children:d}),(0,t.jsxs)("p",{className:"mt-1.5 text-xs text-mute",children:[a||!c?"":`Secrets show as ${V} — choose Show secrets to put the real values in. `,"curl"===l&&e.body&&/[^\x00-\x7f]/.test(e.body)?"On Windows, curl.exe can garble non-English letters in the command line — use the PowerShell code there, or save the body to a file and send it with --data-binary @file. ":"",e.authNote&&/signed|challenge|three requests/.test(e.authNote)?"A signature or challenge answer is only good for this one request; sent again later, the server may refuse it.":e.authNote?.startsWith("OAuth 2.0")?"The token expires; the code works until it does.":""]})]})]})}function en({cookies:e}){let[s,a]=(0,r.useState)(!1);return(0,t.jsxs)("div",{className:"space-y-2 overflow-auto",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Set by this answer",e.length>1?" and the redirects on the way":"",". With the cookie jar on, they go with the next requests to the same site."]}),(0,t.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),"aria-pressed":s,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-line px-2 py-1 text-xs text-mute hover:text-ink",children:[s?(0,t.jsx)(ee,{size:12,"aria-hidden":!0}):(0,t.jsx)(Y,{size:12,"aria-hidden":!0}),s?"Hide values":"Show values"]})]}),(0,t.jsx)("div",{className:"overflow-auto rounded-md border border-line",children:(0,t.jsxs)("table",{className:"w-full text-left text-[13px]",children:[(0,t.jsx)("thead",{className:"bg-panel-2 text-xs text-mute",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Name"}),(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Value"}),(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Domain · path"}),(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Expires"}),(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Flags"})]})}),(0,t.jsx)("tbody",{children:e.map((e,a)=>{var n;return(0,t.jsxs)("tr",{className:"border-t border-line align-top",children:[(0,t.jsx)("td",{className:"px-3 py-1.5 font-mono text-ink",children:e.name}),(0,t.jsx)("td",{className:`max-w-[16rem] px-3 py-1.5 font-mono break-all ${s?"text-ink":"text-mute italic"}`,children:s?e.value||"(empty)":V}),(0,t.jsxs)("td",{className:"px-3 py-1.5 font-mono text-xs text-mute",children:[e.domain??"this host"," · ",e.path??"/"]}),(0,t.jsx)("td",{className:"px-3 py-1.5 text-xs text-mute",children:void 0!==e.maxAge?e.maxAge<=0?"deleted":`in ${(n=e.maxAge)<120?`${n} s`:n<7200?`${Math.round(n/60)} min`:n<172800?`${Math.round(n/3600)} h`:`${Math.round(n/86400)} days`}`:e.expires?new Date(e.expires).toLocaleString():"when the app closes"}),(0,t.jsx)("td",{className:"px-3 py-1.5 text-xs text-mute",children:[e.httpOnly?"HttpOnly":"",e.secure?"Secure":"",e.sameSite?`SameSite=${e.sameSite}`:""].filter(Boolean).join(" · ")||"—"})]},a)})})]})})]})}var er=e.i(19656);let el={200:"OK",201:"Created",202:"Accepted",204:"No Content",301:"Moved Permanently",302:"Found",304:"Not Modified",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",408:"Request Timeout",409:"Conflict",415:"Unsupported Media Type",422:"Unprocessable Content",429:"Too Many Requests",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function ei({logs:e}){return(0,t.jsx)("ol",{"aria-label":"Script console",className:"overflow-auto rounded-md border border-line bg-panel-2 p-2 font-mono text-[12.5px] leading-5",children:e.map((e,s)=>(0,t.jsxs)("li",{className:"flex gap-2 border-t border-line/50 px-1 py-0.5 first:border-t-0",children:[(0,t.jsx)("span",{className:"w-24 shrink-0 whitespace-nowrap text-mute",children:"pre"===e.phase?"pre-request":"tests"}),(0,t.jsx)("span",{className:"min-w-0 break-words whitespace-pre-wrap text-ink",children:e.text})]},s))})}function eo({label:e,value:s}){return(0,t.jsxs)("span",{className:"text-xs text-mute",children:[e," ",(0,t.jsx)("span",{className:"font-mono text-sm text-ink",children:s})]})}function ed({message:e}){let s,{title:a,tip:n}=(s=e.toLowerCase()).includes("econnrefused")?{title:"Connection refused",tip:"Nothing is listening on that host and port. Is the server running, and is the port right?"}:s.includes("enotfound")||s.includes("eai_again")?{title:"Host not found",tip:"DNS could not resolve the host name. Check the spelling, or connect to the VPN for internal hosts."}:s.includes("timeout")||s.includes("etimedout")||s.includes("und_err_headers_timeout")?{title:"Timed out",tip:"The server did not answer in time. Raise Timeout under Settings, or check that the host is reachable."}:s.includes("certificate")||s.includes("self-signed")||s.includes("unable to verify")||s.includes("cert_")?{title:"TLS certificate rejected",tip:"The certificate is not trusted. For a lab certificate, turn on 'Skip TLS certificate check' under Settings."}:s.includes("econnreset")||s.includes("socket hang up")?{title:"Connection reset",tip:"The server closed the connection mid-request. Check the server logs, or a proxy or firewall in between."}:s.includes("engine")?{title:"Engine problem",tip:"The local engine did not answer. Make sure pnpm dev is running."}:{title:"Request failed",tip:"See the details below."};return(0,t.jsxs)("div",{role:"alert",className:"mt-3 rounded-md border border-bad/40 bg-bad/10 px-3 py-2.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-bad",children:a}),(0,t.jsx)("p",{className:"mt-1 text-sm text-ink",children:n}),(0,t.jsx)("p",{className:"mt-2 font-mono text-xs break-all text-mute",children:e})]})}function ec({headers:e}){let s=(0,B.useToast)(),a=Object.entries(e).sort(([e],[t])=>e.localeCompare(t));return 0===a.length?(0,t.jsx)("p",{className:"text-sm text-mute",children:"No headers."}):(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 text-xs text-mute hover:text-ink",onClick:()=>{navigator.clipboard.writeText(a.map(([e,t])=>`${e}: ${t}`).join("\n")),s("Headers copied","success")},children:[(0,t.jsx)(H.Copy,{size:12})," Copy all"]})}),(0,t.jsx)("div",{className:"overflow-auto rounded-md border border-line",children:(0,t.jsx)("table",{className:"w-full text-left text-[13px]",children:(0,t.jsx)("tbody",{children:a.map(([e,s])=>(0,t.jsxs)("tr",{className:"border-t border-line first:border-t-0",children:[(0,t.jsx)("th",{scope:"row",className:"w-2/5 bg-panel-2 px-3 py-1.5 align-top font-mono font-normal text-mute",children:e}),(0,t.jsx)("td",{className:`px-3 py-1.5 font-mono break-all ${"[redacted]"===s?"text-mute italic":"text-ink"}`,children:s})]},e))})})}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Cookie and authorization headers are hidden here — see Cookies, and Request sent."})]})}function eu({body:e,contentType:s,truncated:a,url:n,base64:l}){let i=(0,B.useToast)(),d=function(e,t){let s=t.toLowerCase();if(s.startsWith("image/"))return"image";if(s.includes("json"))return"json";if(s.includes("html"))return"html";if(s.includes("xml"))return"xml";let a=e.trim();if(a.startsWith("{")||a.startsWith("["))try{return JSON.parse(a),"json"}catch{}return/^<!doctype html|^<html/i.test(a)?"html":a.startsWith("<")?"xml":"text"}(e,s),c="image"===d&&l?`data:${s.split(";")[0]};base64,${l}`:null,u=a||e.length>=16384,[h,m]=(0,r.useState)("pretty"),[p,x]=(0,r.useState)(!0),[f,b]=(0,r.useState)(""),[v,g]=(0,r.useState)(0),[j,y]=(0,r.useState)(!1),w=(0,r.useRef)(null),N=(0,r.useRef)(null);(0,r.useEffect)(()=>{m("image"===d?"preview":"pretty"),b(""),g(0)},[e,d]);let k=(0,r.useMemo)(()=>e?"raw"===h?e:function(e,t){if("json"!==t)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}(e,d):"",[e,h,d]),C=(0,r.useMemo)(()=>(function(e,t){if(!t)return 0;let s=e.toLowerCase(),a=t.toLowerCase(),n=0;for(let e=s.indexOf(a);e>=0&&n<1e4;e=s.indexOf(a,e+a.length))n++;return n})(k,f),[k,f]);function $(e){0!==C&&g(t=>(t+e+C)%C)}(0,r.useEffect)(()=>{let e=N.current?.querySelector("mark.current");e?.scrollIntoView({block:"center"})},[v,f,h]);let S=c?[{value:"preview",label:"Preview"},{value:"raw",label:"Raw"}]:[{value:"pretty",label:"Pretty"},{value:"raw",label:"Raw"},..."html"===d?[{value:"preview",label:"Preview"}]:[]];return e?(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-line bg-panel-2",onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key.toLowerCase()&&(e.preventDefault(),y(!0),window.setTimeout(()=>w.current?.focus(),0))},children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line px-2 py-1.5",children:[(0,t.jsx)(o.Segmented,{label:"Body view",value:h,onChange:m,options:S}),(0,t.jsx)("span",{className:"rounded border border-line px-1.5 py-0.5 font-mono text-xs text-mute uppercase",children:d}),a?(0,t.jsx)("span",{className:"text-xs text-warn",children:"First 64 KB shown"}):null,(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[j?(0,t.jsxs)("div",{className:"flex items-center gap-1 rounded-md border border-line bg-panel px-1.5",children:[(0,t.jsx)(U.Search,{size:12,className:"text-mute"}),(0,t.jsx)("input",{ref:w,value:f,"aria-label":"Find in body",placeholder:"Find",onChange:e=>{b(e.target.value),g(0)},onKeyDown:e=>{"Enter"===e.key&&$(e.shiftKey?-1:1),"Escape"===e.key&&(b(""),y(!1))},className:"w-28 bg-transparent py-1 text-xs text-ink outline-none"}),(0,t.jsx)("span",{className:"font-mono text-xs text-mute tabular",children:f?`${C?v+1:0}/${C}`:""}),(0,t.jsx)(eh,{label:"Previous match",onClick:()=>$(-1),children:(0,t.jsx)(z,{size:12})}),(0,t.jsx)(eh,{label:"Next match",onClick:()=>$(1),children:(0,t.jsx)(A.ChevronDown,{size:12})})]}):(0,t.jsx)(eh,{label:"Find in body (Ctrl+F)",onClick:()=>{y(!0),window.setTimeout(()=>w.current?.focus(),0)},children:(0,t.jsx)(U.Search,{size:14})}),(0,t.jsx)(eh,{label:p?"Turn off line wrap":"Wrap long lines",pressed:p,onClick:()=>x(e=>!e),children:(0,t.jsx)(F,{size:14})}),(0,t.jsx)(eh,{label:"Copy body",onClick:()=>{navigator.clipboard.writeText(k),i("Body copied","success")},children:(0,t.jsx)(H.Copy,{size:14})}),(0,t.jsx)(eh,{label:"Download body",onClick:()=>{var e;return c&&l?(0,W.downloadBlob)(ep(n,d,s),new Blob([Uint8Array.from(atob(l),e=>e.charCodeAt(0))],{type:s.split(";")[0]})):(0,W.downloadText)(ep(n,d),k,"json"===(e=d)?"application/json":"html"===e?"text/html":"xml"===e?"application/xml":"text/plain")},children:(0,t.jsx)(O.Download,{size:14})})]})]}),"preview"===h&&c?(0,t.jsx)("div",{className:"flex min-h-[12rem] flex-1 items-center justify-center overflow-auto p-3",children:(0,t.jsx)("img",{src:c,alt:"Response image",className:"max-h-[32rem] max-w-full object-contain"})}):"preview"===h?(0,t.jsx)("iframe",{title:"HTML preview",sandbox:"",srcDoc:e,className:"min-h-[24rem] w-full flex-1 bg-white"}):(0,t.jsx)("pre",{ref:N,tabIndex:0,"aria-label":"Response body",className:`min-h-[12rem] flex-1 overflow-auto p-3 font-mono text-[13px] leading-5 text-ink ${p?"break-words whitespace-pre-wrap":"whitespace-pre"}`,children:f?function(e,s,a){let n=[],r=e.toLowerCase(),l=s.toLowerCase(),i=0,o=0;for(let s=r.indexOf(l);s>=0&&o<1e4;s=r.indexOf(l,s+l.length))n.push(e.slice(i,s)),n.push((0,t.jsx)("mark",{className:`find-hit${o===a?" current":""}`,children:e.slice(s,s+l.length)},s)),i=s+l.length,o++;return n.push(e.slice(i)),n}(k,f,v):"pretty"!==h||"json"!==d||u?k:function(e){let s=[],a=0;for(let n of e.matchAll(em)){let r=n.index??0;s.push(e.slice(a,r)),n[1]?(s.push((0,t.jsx)("span",{className:n[2]?"tok-key":"tok-str",children:n[1]},r)),n[2]&&s.push(n[2])):n[3]?s.push((0,t.jsx)("span",{className:"tok-lit",children:n[3]},r)):s.push((0,t.jsx)("span",{className:"tok-num",children:n[4]},r)),a=r+n[0].length}return s.push(e.slice(a)),s}(k)})]}):(0,t.jsx)("p",{className:"text-sm text-mute",children:"Empty body."})}function eh({label:e,onClick:s,children:a,pressed:n}){return(0,t.jsx)("button",{type:"button","aria-label":e,title:e,"aria-pressed":n,onClick:s,className:`rounded p-1 hover:bg-panel hover:text-ink ${n?"text-accent":"text-mute"}`,children:a})}let em=/("(?:\\u[a-fA-F0-9]{4}|\\[^u]|[^\\"])*")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function ep(e,t,s=""){let a="response";try{a=new URL(e).pathname.split("/").filter(Boolean).pop()||"response"}catch{}let n="json"===t?"json":"html"===t?"html":"xml"===t?"xml":"image"===t?/svg/.test(s)?"svg":s.split("/")[1]?.split(/[;+]/)[0]?.replace("jpeg","jpg")||"img":"txt";return`${a.replace(/[^\w.-]+/g,"_")}.${n}`}e.s(["ResponseViewer",0,function({result:e,onSaveExample:s}){var a,n;let l,[i,o]=(0,r.useState)("body"),d=e.logs??[],c=e.cookies??[],u=("console"!==i||d.length)&&("cookies"!==i||c.length)&&("request"!==i||e.sent)&&("checks"!==i||(e.checks??[]).length)?i:"body",h=e.checks??[],m=h.filter(e=>e.ok).length,p=Object.keys(e.headers).length,x=(l=Object.keys(a=e.headers).find(e=>"content-type"===e.toLowerCase()))?a[l]??"":"",f=(0,r.useMemo)(()=>new TextEncoder().encode(e.body).length,[e.body]),b=!e.status;return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,t.jsx)("span",{className:`rounded-md border px-2 py-0.5 font-mono text-sm font-medium ${(n=e.status)>=200&&n<300?"text-ok border-ok/40 bg-ok/10":n>=300&&n<400?"text-accent border-accent/40 bg-accent/10":n>=400&&n<500?"text-warn border-warn/40 bg-warn/10":"text-bad border-bad/40 bg-bad/10"}`,children:b?"Error":`${e.status} ${el[e.status]??""}`.trim()}),(0,t.jsx)(eo,{label:"Time",value:`${e.durationMs} ms`}),b?null:(0,t.jsx)(eo,{label:"Size",value:`${(0,er.formatBytes)(f)}${e.truncated?"+":""}`}),x?(0,t.jsx)(eo,{label:"Type",value:x.split(";")[0]??x}):null,h.length?(0,t.jsxs)("button",{type:"button",onClick:()=>o("checks"),className:`rounded-md border px-2 py-0.5 text-xs ${m===h.length?"border-ok/40 text-ok":"border-bad/40 text-bad"}`,children:[m===h.length?"✓":"✕"," ",m,"/",h.length," checks"]}):null,s&&!b?(0,t.jsx)("button",{type:"button",onClick:s,title:"Use this answer as what the mock server answers for this request",className:"ml-auto rounded-md border border-line px-2 py-0.5 text-xs text-mute hover:border-accent hover:text-ink",children:"Save as example"}):null]}),(0,t.jsx)("p",{className:"mt-2 font-mono text-xs break-all text-mute",children:e.url}),e.setup||e.dataRow?(0,t.jsxs)("p",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-mute",children:[e.setup?(0,t.jsxs)("span",{className:e.setup.ok?"":"text-bad",children:["Ran first: ",(0,t.jsx)("span",{className:"text-ink",children:e.setup.label}),e.setup.status?` \xb7 ${e.setup.status} \xb7 ${e.setup.durationMs} ms`:"",e.setup.values.map(e=>(0,t.jsxs)("span",{className:`ml-2 font-mono ${e.found?"text-ok":"text-bad"}`,title:e.found?`From ${e.from}: ${e.preview}`:`Not found: ${e.from}`,children:[e.found?"✓":"✕"," ",`{{${e.name}}}`]},e.name))]}):null,e.dataRow?(0,t.jsxs)("span",{children:["Test data: row ",e.dataRow.row," of ",e.dataRow.of.toLocaleString()]}):null]}):null,e.error?(0,t.jsx)(ed,{message:e.error}):null,b&&e.sent?(0,t.jsxs)("details",{className:"mt-3 text-sm",children:[(0,t.jsx)("summary",{className:"cursor-pointer text-xs text-mute hover:text-ink",children:"What was sent"}),(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)(ea,{sent:e.sent})})]}):null,b?null:(0,t.jsxs)("div",{className:"mt-3 flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)(I.Tabs,{id:"response",label:"Response",value:u,onChange:o,items:[{id:"body",label:"Body"},{id:"headers",label:"Headers",badge:p||void 0},...c.length?[{id:"cookies",label:"Cookies",badge:c.length}]:[],...h.length?[{id:"checks",label:"Checks",badge:(0,t.jsxs)("span",{className:m===h.length?"text-ok":"text-bad",children:[m,"/",h.length]})}]:[],...e.sent?[{id:"request",label:"Request sent"}]:[],...d.length?[{id:"console",label:"Console",badge:d.length}]:[]]}),(0,t.jsx)("div",{...(0,I.tabPanelProps)("response",u),className:"flex min-h-0 flex-1 flex-col pt-3",children:"body"===u?(0,t.jsx)(eu,{body:e.body,contentType:x,truncated:e.truncated,url:e.url,base64:e.bodyBase64}):"cookies"===u?(0,t.jsx)(en,{cookies:c}):"console"===u?(0,t.jsx)(ei,{logs:d}):"request"===u&&e.sent?(0,t.jsx)(ea,{sent:e.sent}):"checks"===u?(0,t.jsx)("ul",{className:"space-y-1.5",children:h.map((e,s)=>(0,t.jsxs)("li",{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-sm ${e.ok?"border-ok/30 bg-ok/5":"border-bad/40 bg-bad/10"}`,children:[(0,t.jsx)("span",{className:e.ok?"text-ok":"text-bad","aria-hidden":!0,children:e.ok?"✓":"✕"}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block font-mono text-[13px] text-ink",children:e.name}),!e.ok&&e.detail?(0,t.jsx)("span",{className:"block text-xs text-mute",children:e.detail}):null]}),(0,t.jsx)("span",{className:`ml-auto shrink-0 text-xs ${e.ok?"text-ok":"text-bad"}`,children:e.ok?"pass":"fail"})]},s))}):(0,t.jsx)(ec,{headers:e.headers})})]})]})}],60566)},68228,65638,e=>{"use strict";var t=e.i(61666);e.i(24856);var s=e.i(99112),a=e.i(78451),n=e.i(89932),r=e.i(36620),l=e.i(73436),i=e.i(99522);let o=(0,i.default)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);var d=e.i(71189),c=e.i(43514),u=e.i(96659),h=e.i(87283),m=e.i(83067),p=e.i(39170),x=e.i(80707),f=e.i(56396);e.i(42674);var b=e.i(5305),v=e.i(65238),g=e.i(6278);let j=()=>globalThis.crypto?.randomUUID?.()??`env-${Date.now().toString(36)}`;function y({onClose:e}){let s=(0,f.useToast)(),a=(0,p.useConfirm)(),{environments:r,activeEnv:l,setActiveEnv:i,saveEnvironments:c,index:x}=(0,g.useWorkspace)(),[b,v]=(0,m.useState)(()=>structuredClone(r)),[k,C]=(0,m.useState)(l?.id??r[0]?.id??null),[$,S]=(0,m.useState)(!1),q=(0,m.useRef)(null),E=b.find(e=>e.id===k)??null,R=JSON.stringify(b)!==JSON.stringify(r);(0,m.useEffect)(()=>{let e=document.activeElement;return q.current?.querySelector("input,button")?.focus(),()=>e?.focus()},[]);let T=(e,t)=>v(s=>s.map(s=>s.id===e?{...s,...t}:s));function M(e){let t=e?{id:j(),name:`${e.name} copy`,variables:structuredClone(e.variables)}:{id:j(),name:b.length?`Environment ${b.length+1}`:"DEV",variables:[{key:"baseUrl",value:"",secret:!1}]};v(e=>[...e,t]),C(t.id)}async function L(){(!R||await a({title:"Discard changes to environments?",confirmLabel:"Discard",tone:"danger"}))&&e()}async function P(){S(!0);try{await c(b),l&&!b.some(e=>e.id===l.id)&&i(null),s("Environments saved","success"),e()}catch(e){s(e instanceof Error?e.message:"Could not save environments","error")}finally{S(!1)}}return(0,t.jsx)("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/50 p-4 backdrop-blur-sm",onMouseDown:e=>e.target===e.currentTarget&&void L(),children:(0,t.jsxs)("div",{ref:q,role:"dialog","aria-modal":"true","aria-label":"Environments",onKeyDown:e=>"Escape"===e.key&&void L(),className:"flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-line bg-panel shadow-2xl",children:[(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-line px-5 py-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium text-ink",children:"Environments"}),(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Use ",(0,t.jsx)("code",{className:"font-mono text-ink",children:"{{name}}"})," in the URL, params, headers, body, or auth. Saved to environments.json in your app-data folder."]})]}),(0,t.jsx)("button",{type:"button","aria-label":"Close",className:"rounded p-1 text-mute hover:text-ink",onClick:()=>void L(),children:(0,t.jsx)(h.X,{size:16})})]}),(0,t.jsxs)("div",{className:"grid min-h-0 flex-1 md:grid-cols-[14rem_minmax(0,1fr)]",children:[(0,t.jsxs)("nav",{"aria-label":"Environment list",className:"space-y-1 overflow-auto border-line p-3 md:border-r",children:[b.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>C(e.id),"aria-current":e.id===k?"true":void 0,className:`block w-full truncate rounded-md px-2 py-1.5 text-left text-sm ${e.id===k?"bg-accent-dim text-ink":"text-mute hover:bg-panel-2 hover:text-ink"}`,children:[e.name,(0,t.jsx)("span",{className:"ml-1 text-xs text-mute",children:e.variables.length})]},e.id)),(0,t.jsxs)("button",{type:"button",onClick:()=>M(),className:"mt-2 inline-flex items-center gap-1 text-xs text-accent hover:underline",children:[(0,t.jsx)(d.Plus,{size:12,"aria-hidden":!0})," New environment"]})]}),(0,t.jsxs)("section",{className:"min-h-0 space-y-4 overflow-auto p-4",children:[E?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("label",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"sr-only",children:"Environment name"}),(0,t.jsx)("input",{value:E.name,onChange:e=>T(E.id,{name:e.target.value}),className:"input text-base font-medium"})]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1.5 text-xs",onClick:()=>M(E),children:[(0,t.jsx)(n.Copy,{size:13})," Duplicate"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-danger py-1.5 text-xs",onClick:()=>{v(e=>e.filter(e=>e.id!==E.id)),C(b.find(e=>e.id!==E.id)?.id??null)},children:[(0,t.jsx)(u.Trash2,{size:13})," Delete"]})]}),(0,t.jsx)(N,{vars:E.variables,onPatch:(e,t)=>E&&T(E.id,{variables:E.variables.map((s,a)=>a===e?{...s,...t}:s)}),onChange:e=>T(E.id,{variables:e})}),(0,t.jsxs)("p",{className:"flex items-start gap-1.5 text-xs text-mute",children:[(0,t.jsx)(o,{size:12,className:"mt-0.5 shrink-0","aria-hidden":!0}),x?.secretsPersistent?"Secret values are encrypted on this computer and never written to environments.json.":"Secret values are never written to disk. In this browser setup they are kept by the engine until it restarts; the desktop app encrypts them."]})]}):(0,t.jsxs)("div",{className:"py-12 text-center text-sm text-mute",children:["No environments yet. Create one for each place you test — DEV, UAT, PROD.",(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsxs)("button",{type:"button",className:"btn btn-primary text-sm",onClick:()=>M(),children:[(0,t.jsx)(d.Plus,{size:14})," New environment"]})})]}),(0,t.jsx)(w,{onCopied:e=>s(`Copied ${e}`,"success")})]})]}),(0,t.jsxs)("footer",{className:"flex justify-end gap-2 border-t border-line px-5 py-3",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary text-sm",onClick:()=>void L(),children:"Cancel"}),(0,t.jsx)("button",{type:"button",className:"btn btn-primary text-sm",disabled:!R||$,onClick:()=>void P(),children:"Save environments"})]})]})})}function w({onCopied:e}){return(0,t.jsxs)("details",{className:"rounded-md border border-line bg-panel-2/40 px-3 py-2 text-sm",children:[(0,t.jsxs)("summary",{className:"cursor-pointer text-xs font-medium text-ink",children:["Built-in values ",(0,t.jsx)("span",{className:"font-normal text-mute",children:"— made anew for every request, in load tests too"})]}),(0,t.jsx)("ul",{className:"mt-2 space-y-1",children:s.BUILTIN_VALUES.map(s=>(0,t.jsxs)("li",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsxs)("button",{type:"button",title:"Copy",onClick:()=>void navigator.clipboard?.writeText(s.example).then(()=>e(s.example)),className:"inline-flex shrink-0 items-center gap-1 rounded border border-line px-1.5 py-0.5 font-mono text-accent hover:border-accent",children:[s.example,(0,t.jsx)(n.Copy,{size:11,"aria-hidden":!0})]}),(0,t.jsx)("span",{className:"text-mute",children:s.description})]},s.name))}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-mute",children:["In a JSON body put them in quotes, like ",(0,t.jsx)("code",{className:"font-mono text-ink",children:'"id": "{{$uuid}}"'}),"."]})]})}function N({vars:e,onPatch:s,onChange:a}){let[n,i]=(0,m.useState)(new Set),o=new Set(e.map(e=>e.key.trim()).filter((e,t,s)=>e&&s.indexOf(e)!==t));return(0,t.jsxs)("div",{className:"overflow-hidden rounded-md border border-line",children:[(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)_5.5rem_2rem] bg-panel-2 text-xs text-mute",children:[(0,t.jsx)("span",{className:"px-2.5 py-1.5",children:"Variable"}),(0,t.jsx)("span",{className:"border-l border-line px-2.5 py-1.5",children:"Value"}),(0,t.jsx)("span",{className:"border-l border-line px-2.5 py-1.5",children:"Secret"}),(0,t.jsx)("span",{})]}),e.map((d,c)=>{let u=d.key&&!/^[A-Za-z_][\w.-]*$/.test(d.key)||o.has(d.key.trim());return(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)_5.5rem_2rem] border-t border-line",children:[(0,t.jsx)("input",{"aria-label":`Variable ${c+1} name`,"aria-invalid":u||void 0,title:u?"Letters, digits, _ . - ; must start with a letter or _ ; must be unique":void 0,value:d.key,onChange:e=>s(c,{key:e.target.value}),placeholder:"baseUrl",className:`min-w-0 bg-transparent px-2.5 py-1.5 font-mono text-[13px] outline-none focus:bg-panel-2 ${u?"text-bad":"text-ink"}`}),(0,t.jsxs)("span",{className:"relative flex min-w-0 border-l border-line",children:[(0,t.jsx)("input",{"aria-label":`Variable ${c+1} value`,type:d.secret&&!n.has(c)?"password":"text",autoComplete:"off",value:d.value,onChange:e=>s(c,{value:e.target.value}),className:"min-w-0 flex-1 bg-transparent px-2.5 py-1.5 font-mono text-[13px] text-ink outline-none focus:bg-panel-2"}),d.secret?(0,t.jsx)("button",{type:"button","aria-label":n.has(c)?"Hide value":"Show value",onClick:()=>i(e=>{let t=new Set(e);return t.has(c)?t.delete(c):t.add(c),t}),className:"px-2 text-mute hover:text-ink",children:n.has(c)?(0,t.jsx)(l.EyeOff,{size:13}):(0,t.jsx)(r.Eye,{size:13})}):null]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 border-l border-line px-2.5 text-xs text-mute",children:[(0,t.jsx)("input",{type:"checkbox",checked:d.secret,onChange:e=>s(c,{secret:e.target.checked}),className:"accent-[var(--accent)]"}),"secret"]}),(0,t.jsx)("button",{type:"button","aria-label":`Remove ${d.key||`variable ${c+1}`}`,onClick:()=>a(e.filter((e,t)=>t!==c)),className:"grid place-items-center text-mute hover:text-bad",children:(0,t.jsx)(h.X,{size:13})})]},c)}),(0,t.jsxs)("button",{type:"button",onClick:()=>a([...e,{key:"",value:"",secret:!1}]),className:"flex w-full items-center gap-1 border-t border-line px-2.5 py-1.5 text-xs text-accent hover:bg-panel-2",children:[(0,t.jsx)(d.Plus,{size:12,"aria-hidden":!0})," Add variable"]})]})}e.s(["EnvironmentBar",0,function({drafts:e,collections:s=[]}){let{environments:n,activeEnv:r,setActiveEnv:l,vars:i,savedValues:o,clearSavedValues:d}=(0,g.useWorkspace)(),u=Object.keys(o),[h,p]=(0,m.useState)(!1),f=(0,m.useMemo)(()=>{let t=new Set;for(let s of e){let e=new Set((0,b.draftRuntimeNames)(s)),n=[s.url,s.bodyText,s.token,s.username,s.password,s.apiValue,...s.params.map(e=>e.value),...s.headers.map(e=>e.value)].join(" ");(0,a.findVariables)(n).forEach(s=>!e.has(s)&&t.add(s))}return[...t]},[e]),j=(0,v.useFolderVarNames)(s),w=f.filter(e=>!(e in i)&&!j.has(e));return(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-mute",children:["Environment",(0,t.jsx)(x.Select,{label:"Environment",value:r?.id??"",onChange:e=>l(e||null),minWidth:200,options:[{value:"",label:"None",hint:"Only built-in variables"},...n.map(e=>({value:e.id,label:e.name,hint:`${e.variables.length} variable${1===e.variables.length?"":"s"}`}))],className:"rounded-md border border-line bg-panel-2 px-2 py-1 text-xs text-ink hover:border-mute focus-visible:border-accent focus-visible:outline-none"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>p(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-mute hover:text-ink",children:[(0,t.jsx)(c.Settings2,{size:12,"aria-hidden":!0})," Manage"]}),f.length>0?w.length?(0,t.jsxs)("span",{className:"text-warn",role:"status",children:[w.map(e=>`{{${e}}}`).join(", ")," not defined",r?` in ${r.name}`:" — pick an environment"]}):(0,t.jsxs)("span",{className:"text-mute",children:["Uses ",f.map(e=>`{{${e}}}`).join(", ")]}):null,u.length?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-mute",title:u.map(e=>`{{${e}}} — saved from “${o[e].from}”`).join("\n"),children:["Saved from answers: ",(0,t.jsx)("span",{className:"font-mono text-accent",children:u.map(e=>`{{${e}}}`).join(", ")}),(0,t.jsx)("button",{type:"button",onClick:d,className:"text-mute underline-offset-2 hover:text-ink hover:underline",children:"Clear"})]}):null,h?(0,t.jsx)(y,{onClose:()=>p(!1)}):null]})},"VariableTable",0,N],68228);var k=e.i(95486),C=e.i(60961);let $=(0,i.default)("file-plus-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]),S=(0,i.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),q=(0,i.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),E=(0,i.default)("import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);var R=e.i(19286),T=e.i(81538),M=e.i(3792),L=e.i(88293),P=e.i(50804),A=e.i(67217),D=e.i(74749),z=e.i(41997),H=e.i(37837),O=e.i(27813),U=e.i(36e3),F=e.i(13318);function I({path:e,onClose:s}){let n=(0,f.useToast)(),{refresh:r}=(0,g.useWorkspace)(),[l,i]=(0,m.useState)(null),[o,d]=(0,m.useState)([]),[c,u]=(0,m.useState)([]),[p,x]=(0,m.useState)("auth"),[b,j]=(0,m.useState)(!1);async function y(){if(l&&!b){j(!0);try{await v.folderApi.save(e,{...l,headers:l.headers.filter(e=>e.key.trim()),variables:l.variables.filter(e=>e.key.trim())}),await r(),n(`Saved the settings of ${e}`,"success"),s()}catch(e){n(e instanceof Error?e.message:"Could not save","error")}finally{j(!1)}}}(0,m.useEffect)(()=>{let t=!0;return Promise.all([v.folderApi.get(e),v.folderApi.chain((0,a.parentFolder)(e))]).then(([e,s])=>{t&&(i(e.settings),d(e.secretsMissing??[]),u(s))}).catch(e=>{t&&(n(e instanceof Error?e.message:"Could not open the folder","error"),i((0,a.emptyFolderSettings)()))}),()=>{t=!1}},[e,n]);let w=[...c].reverse().find(e=>"inherit"!==e.settings.auth.authMode),k=l?{headers:l.headers.filter(e=>e.key.trim()).length,variables:l.variables.length}:{headers:0,variables:0};return(0,t.jsx)("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/50 p-4 backdrop-blur-sm",onMouseDown:e=>e.target===e.currentTarget&&s(),children:(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"folder-settings-title",onKeyDown:e=>"Escape"===e.key&&s(),className:"flex max-h-[85vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-line bg-panel shadow-2xl",children:[(0,t.jsxs)("header",{className:"flex items-start justify-between gap-3 border-b border-line px-5 py-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("h2",{id:"folder-settings-title",className:"truncate text-base font-medium text-ink",children:["Folder settings · ",e]}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Every request inside — and inside its subfolders — uses these. A request's own value wins."})]}),(0,t.jsx)("button",{type:"button","aria-label":"Close",className:"rounded p-1 text-mute hover:text-ink",onClick:s,children:(0,t.jsx)(h.X,{size:16})})]}),l?(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[(0,t.jsx)(F.Tabs,{id:"folder-settings",label:"Folder settings",value:p,onChange:x,items:[{id:"auth",label:"Auth"},{id:"headers",label:"Headers",badge:k.headers||void 0},{id:"variables",label:"Variables",badge:k.variables||void 0}]}),(0,t.jsxs)("div",{...(0,F.tabPanelProps)("folder-settings",p),className:"pt-4",children:["auth"===p?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Requests set to ",(0,t.jsx)("span",{className:"text-ink",children:"Auth → From folder"})," (the default for new requests) use this — sign in once here instead of in every request."]}),(0,t.jsx)(z.AuthFields,{value:l.auth,onChange:e=>i({...l,auth:{...l.auth,...e}}),inheritLabel:"From parent",defaults:Object.fromEntries([...c.flatMap(e=>e.settings.variables),...l.variables].map(e=>[e.key,e.value])),inheritNote:w&&"none"!==w.settings.auth.authMode?(0,t.jsxs)(t.Fragment,{children:["Passes on the ",(0,t.jsx)("span",{className:"text-ink",children:(0,z.authModeLabel)(w.settings.auth.authMode)})," of"," ",(0,t.jsx)("span",{className:"text-ink",children:w.path}),"."]}):(0,t.jsx)(t.Fragment,{children:"No folder above sets auth, so this folder passes none down."}),secretNote:"Use {{token}} to take it from the environment, or type it — it's kept encrypted on this computer, never in the folder's file."}),o.some(e=>!e.startsWith("var:"))?(0,t.jsxs)("p",{className:"text-xs text-warn",children:["The saved ",o.filter(e=>!e.startsWith("var:")).join(", ")," isn't available on this computer — enter it again."]}):null]}):null,"headers"===p?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(U.KeyValueEditor,{rows:l.headers,onChange:e=>i({...l,headers:e}),keyPlaceholder:"Header",valuePlaceholder:"Value",noun:"header"}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Sent with every request inside. An inner folder's or a request's header with the same name replaces it."})]}):null,"variables"===p?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(N,{vars:l.variables,onPatch:(e,t)=>i({...l,variables:l.variables.map((s,a)=>a===e?{...s,...t}:s)}),onChange:e=>i({...l,variables:e})}),(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Defaults for ",(0,t.jsx)("code",{className:"font-mono text-ink",children:"{{name}}"})," in the requests inside. The chosen environment wins when it has the same name — so a folder can say"," ",(0,t.jsx)("code",{className:"font-mono text-ink",children:"basePath = /v2"})," and the environment picks the server."]}),o.some(e=>e.startsWith("var:"))?(0,t.jsxs)("p",{className:"text-xs text-warn",children:["Secret values not available on this computer: ",o.filter(e=>e.startsWith("var:")).map(e=>e.slice(4)).join(", ")," — enter them again."]}):null]}):null]})]}):(0,t.jsx)("div",{className:"grid place-items-center p-10 text-mute",children:(0,t.jsx)(O.Loader2,{className:"animate-spin",size:18,"aria-label":"Loading"})}),(0,t.jsxs)("footer",{className:"flex justify-end gap-2 border-t border-line px-5 py-3",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary",onClick:s,disabled:b,children:"Cancel"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",onClick:()=>void y(),disabled:!l||b,children:[b?(0,t.jsx)(O.Loader2,{size:14,className:"animate-spin"}):null,"Save folder settings"]})]})]})})}var B=e.i(14168);let W={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad"};function V({activeId:e,onOpen:s,allowDelete:n=!0,newFolder:r,onNewFolderDone:l}){let i=(0,f.useToast)(),o=(0,p.useConfirm)(),{index:d,refresh:c}=(0,g.useWorkspace)(),[h,x]=(0,m.useState)(""),[b,j]=(0,m.useState)(new Set),[y,w]=(0,m.useState)(null),[N,$]=(0,m.useState)(null),q=d?.requests??[],E=d?.folders??[],T=h.trim().toLowerCase(),D=(0,m.useMemo)(()=>T?q.filter(e=>`${e.name} ${e.collection} ${e.url} ${e.method}`.toLowerCase().includes(T)):q,[q,T]),H=(0,m.useMemo)(()=>(function(e,t,s){let n={path:"",name:"",folders:[],requests:[],summary:null},r=new Map([["",n]]),l=e=>{let t=r.get(e);if(t)return t;let s={path:e,name:(0,a.folderName)(e),folders:[],requests:[],summary:null};return r.set(e,s),l((0,a.parentFolder)(e)).folders.push(s),s};if(s)for(let e of t)l(e.path);for(let t of e)l(t.collection).requests.push(t);for(let e of t){let t=r.get(e.path);t&&(t.summary=e)}let i=e=>{e.folders.sort((e,t)=>e.name.localeCompare(t.name)),e.folders.forEach(i)};return i(n),n})(D,E,!T),[D,E,T]);async function O(e){try{let t=await g.workspaceApi.get(e);s(t),t.secretsMissing?.length&&i(`Re-enter the ${t.secretsMissing.join(", ")} — secrets are kept only until the engine restarts in this setup`,"info")}catch(e){i(e instanceof Error?e.message:"Could not open the request","error")}}async function U(e){await o({title:`Delete “${e.name}”?`,body:"The saved request file is removed. Load test history is not affected.",confirmLabel:"Delete",tone:"danger"})&&(await g.workspaceApi.remove(e.id).catch(()=>void 0),await c())}async function F(e){if(w(null),l?.(),!y)return;let t=e.trim();if(t)try{if("new"===y.kind){let e=(0,a.folderPath)(y.parent?`${y.parent}/${t}`:t);await v.folderApi.save(e,(0,a.emptyFolderSettings)()),j(e=>{let t=new Set(e);return t.delete(y.parent),t})}else{let e=(0,a.folderPath)(t.includes("/")?t:(0,a.parentFolder)(y.path)?`${(0,a.parentFolder)(y.path)}/${t}`:t);e!==y.path&&await v.folderApi.move(y.path,e)}await c()}catch(e){i(e instanceof Error?e.message:"Could not do that","error")}}async function K(e){if(await o({title:`Delete the folder “${e}”?`,body:"Its settings and empty subfolders are removed. A folder that still has requests can't be deleted — move or delete them first.",confirmLabel:"Delete folder",tone:"danger"}))try{await v.folderApi.remove(e),await c()}catch(e){i(e instanceof Error?e.message:"Could not delete the folder","error")}}(0,m.useEffect)(()=>{r&&w({kind:"new",parent:""})},[r]);let G=s=>(0,t.jsx)("ul",{children:s.map(s=>(0,t.jsxs)("li",{className:`group flex items-center rounded ${s.id===e?"bg-accent-dim":"hover:bg-panel-2"}`,children:[(0,t.jsxs)("button",{type:"button",onClick:()=>void O(s.id),"aria-current":s.id===e?"true":void 0,title:s.url,className:"flex min-w-0 flex-1 items-center gap-2 px-1.5 py-1 text-left",children:[(0,t.jsx)("span",{className:`w-12 shrink-0 font-mono text-[11px] font-medium ${W[s.method]??"text-mute"}`,children:s.method}),(0,t.jsx)("span",{className:"min-w-0 truncate text-xs text-ink",children:s.name})]}),n?(0,t.jsx)("button",{type:"button","aria-label":`Delete ${s.name}`,onClick:()=>void U(s),className:"mr-1 rounded p-1 text-mute opacity-0 group-hover:opacity-100 hover:text-bad focus:opacity-100",children:(0,t.jsx)(u.Trash2,{size:12})}):null]},s.id))}),X=e=>{var s;let a=b.has(e.path)&&!T,r=(s=e.summary)?[s.auth?(0,z.authModeLabel)(s.auth):"",s.headers?`${s.headers} header${1===s.headers?"":"s"}`:"",s.variables?`${s.variables} variable${1===s.variables?"":"s"}`:""].filter(Boolean).join(" · "):"";return(0,t.jsxs)("div",{className:"mb-0.5",children:[y?.kind==="rename"&&y.path===e.path?(0,t.jsx)(_,{initial:e.path,label:`New name for ${e.path}`,onDone:e=>void F(e),hint:"Use / to move it into another folder"}):(0,t.jsxs)("div",{className:"group/folder flex items-center",children:[(0,t.jsxs)("button",{type:"button","aria-expanded":!a,onClick:()=>{let t;return t=e.path,j(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},title:r?`Passes down: ${r}`:e.path,className:"flex min-w-0 flex-1 items-center gap-1 rounded px-1 py-1 text-left text-xs font-medium text-mute hover:text-ink",children:[a?(0,t.jsx)(C.ChevronRight,{size:12,"aria-hidden":!0,className:"shrink-0"}):(0,t.jsx)(k.ChevronDown,{size:12,"aria-hidden":!0,className:"shrink-0"}),(0,t.jsx)(S,{size:12,"aria-hidden":!0,className:"shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.name}),e.summary?.auth?(0,t.jsx)(R.KeyRound,{size:11,className:"shrink-0 text-accent","aria-label":`signs in with ${(0,z.authModeLabel)(e.summary.auth)}`}):null,(0,t.jsx)("span",{className:"ml-auto pl-1 font-normal",children:function e(t){return t.requests.length+t.folders.reduce((t,s)=>t+e(s),0)}(e)})]}),n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(P.default,{href:(0,B.suiteHref)(e.path),title:`Run all requests in ${e.path}`,"aria-label":`Run all requests in ${e.path}`,className:"ml-0.5 rounded p-1 text-mute opacity-0 group-hover/folder:opacity-100 hover:text-accent focus:opacity-100",children:(0,t.jsx)(M.Play,{size:12})}),(0,t.jsx)(J,{path:e.path,onSettings:()=>$(e.path),onNewInside:()=>w({kind:"new",parent:e.path}),onRename:()=>w({kind:"rename",path:e.path}),onDelete:()=>void K(e.path)})]}):null]}),a?null:(0,t.jsxs)("div",{className:"ml-3 border-l border-line/60 pl-1",children:[y?.kind==="new"&&y.parent===e.path?(0,t.jsx)(_,{initial:"",label:`New folder in ${e.path}`,onDone:e=>void F(e)}):null,e.folders.map(X),G(e.requests)]})]},e.path)};return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("label",{className:"relative mb-2 block",children:[(0,t.jsx)("span",{className:"sr-only",children:"Search saved requests"}),(0,t.jsx)(L.Search,{size:13,className:"pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-mute","aria-hidden":!0}),(0,t.jsx)("input",{value:h,onChange:e=>x(e.target.value),placeholder:"Search requests",className:"input py-1 pl-7 text-xs"})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[y?.kind==="new"&&""===y.parent?(0,t.jsx)(_,{initial:"",label:"New folder",onDone:e=>void F(e),hint:"Use / for a folder inside another: Orders/Admin"}):null,0===q.length&&0===E.length?(0,t.jsxs)("div",{className:"space-y-2 px-1 py-4 text-xs text-mute",children:[(0,t.jsx)("p",{children:"No saved requests yet. Press Save (Ctrl+S) to keep the current one."}),(0,t.jsxs)("p",{children:["Coming from Postman or Swagger?"," ",(0,t.jsx)("button",{type:"button",onClick:A.openImport,className:"text-accent hover:underline",children:"Import your requests"})]})]}):T&&0===D.length?(0,t.jsx)("p",{className:"px-1 py-4 text-xs text-mute",children:"Nothing matches."}):(0,t.jsxs)(t.Fragment,{children:[H.folders.map(X),G(H.requests)]})]}),N?(0,t.jsx)(I,{path:N,onClose:()=>$(null)}):null]})}function _({initial:e,label:s,onDone:a,hint:n}){let[r,l]=(0,m.useState)(e),i=(0,m.useRef)(null),o=(0,m.useRef)(!1);(0,m.useEffect)(()=>i.current?.select(),[]);let d=e=>{o.current||(o.current=!0,a(e))};return(0,t.jsxs)("div",{className:"px-1 py-1",children:[(0,t.jsx)("input",{ref:i,value:r,"aria-label":s,placeholder:"Folder name",onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&d(r),"Escape"===e.key&&d("")},onBlur:()=>d(r),className:"input py-1 text-xs"}),n?(0,t.jsx)("p",{className:"mt-0.5 text-[11px] text-mute",children:n}):null]})}function J({path:e,onSettings:s,onNewInside:a,onRename:n,onDelete:r}){let[l,i]=(0,m.useState)(!1),o=(0,m.useRef)(null),d=(e,s,a=!1)=>(0,t.jsx)("button",{type:"button",role:"menuitem",onClick:()=>{i(!1),s()},className:`block w-full rounded px-2.5 py-1.5 text-left text-sm hover:bg-panel-2 ${a?"text-bad":"text-ink"}`,children:e});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{ref:o,type:"button","aria-label":`Actions for ${e}`,"aria-haspopup":"menu","aria-expanded":l,onClick:()=>i(e=>!e),className:`rounded p-1 text-mute hover:text-ink focus:opacity-100 ${l?"opacity-100":"opacity-0 group-hover/folder:opacity-100"}`,children:(0,t.jsx)(T.MoreHorizontal,{size:13})}),(0,t.jsx)(H.Popover,{anchor:o,open:l,onClose:()=>i(!1),label:`Actions for ${e}`,width:220,role:"menu",children:(0,t.jsxs)("div",{className:"p-1",children:[d("Folder settings — auth, headers, variables",s),d("New folder inside",a),d("Mock server for this folder",()=>(0,D.openMock)(e)),d("Rename or move",n),d("Delete folder",r,!0)]})})]})}e.s(["RequestPicker",0,function({onOpen:e}){let[s,a]=(0,m.useState)(!1),n=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(!s)return;let e=e=>!n.current?.contains(e.target)&&a(!1),t=e=>"Escape"===e.key&&a(!1);return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[s]),(0,t.jsxs)("div",{ref:n,className:"relative",children:[(0,t.jsxs)("button",{type:"button","aria-expanded":s,onClick:()=>a(e=>!e),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-mute hover:text-ink",children:[(0,t.jsx)(S,{size:12,"aria-hidden":!0})," Load saved request"]}),s?(0,t.jsx)("div",{className:"absolute left-0 z-40 mt-1 flex h-80 w-80 flex-col rounded-md border border-line bg-panel p-2 shadow-xl",children:(0,t.jsx)(V,{allowDelete:!1,onOpen:t=>{e(t),a(!1)}})}):null]})},"RequestsPanel",0,function({activeId:e,onOpen:s,onNew:a,onClose:n}){let[r,l]=(0,m.useState)(!1);return(0,t.jsxs)("aside",{"aria-label":"Saved requests",className:"flex min-h-0 flex-col border-line px-3 py-4 lg:border-r",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-xs font-medium tracking-wide text-mute uppercase",children:"Saved requests"}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)("button",{type:"button",onClick:a,title:"New request","aria-label":"New request",className:"rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)($,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:()=>l(!0),title:"New folder","aria-label":"New folder",className:"rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(q,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:A.openImport,title:"Import from Postman or OpenAPI","aria-label":"Import from Postman or OpenAPI",className:"rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(E,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:n,title:"Hide saved requests","aria-label":"Hide saved requests",className:"rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(h.X,{size:14})})]})]}),(0,t.jsx)(V,{activeId:e,onOpen:s,newFolder:r,onNewFolderDone:()=>l(!1)})]})},"SaveRequestForm",0,function({initial:e,onSave:s,onCancel:a}){let{index:n}=(0,g.useWorkspace)(),[r,l]=(0,m.useState)(e.name),[i,o]=(0,m.useState)(e.collection),d=(0,m.useRef)(null),c=[...new Set([...(n?.folders??[]).map(e=>e.path),...(n?.requests??[]).map(e=>e.collection)].filter(Boolean))].sort();return(0,m.useEffect)(()=>d.current?.select(),[]),(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),r.trim()&&s(r.trim(),i.trim())},onKeyDown:e=>"Escape"===e.key&&a(),className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-mute",children:["Name",(0,t.jsx)("input",{ref:d,value:r,onChange:e=>l(e.target.value),className:"input w-52 py-1 text-xs","aria-label":"Request name"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-mute",children:["Collection",(0,t.jsx)("input",{value:i,onChange:e=>o(e.target.value),list:"atc-collections",placeholder:"none — or Orders/Admin",title:"A folder; use / for a folder inside another",className:"input w-48 py-1 text-xs","aria-label":"Collection"}),(0,t.jsx)("datalist",{id:"atc-collections",children:c.map(e=>(0,t.jsx)("option",{value:e},e))})]}),(0,t.jsx)("button",{type:"submit",className:"btn btn-primary py-1 text-xs",children:"Save request"}),(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink","aria-label":"Cancel",onClick:a,children:(0,t.jsx)(h.X,{size:14})})]})}],65638)},46679,e=>{"use strict";var t=e.i(65238),s=e.i(6278);e.i(42674);var a=e.i(5305);async function n(e,n,r,l){let i,o,d=n.before;if(!d)return e;try{i=await s.workspaceApi.get(d.requestId)}catch{throw Error(`Run first: “${d.requestName}” is no longer saved — pick another request on the Run first tab`)}if(i.secretsMissing?.length)throw Error(`Run first: the saved ${i.secretsMissing.join(", ")} of “${i.name}” is not available — open it and enter it again`);try{let e=await (0,t.withFolders)({...(0,a.requestFromUnknown)(i.request),before:null,testData:null},i.collection,r);o=(0,a.resolveDraft)(e.draft,e.vars,l)}catch(e){throw Error(`Run first “${i.name}”: ${e instanceof Error?e.message:"invalid request"}`)}try{return{...e,setup:(0,a.buildSetup)({...d,requestName:i.name},o)}}catch(e){throw Error(e instanceof Error&&e.message.startsWith("Run first")?e.message:`Run first “${i.name}”: ${e instanceof Error?e.message:"invalid request"}`)}}e.s(["withRunFirst",0,n])},21206,e=>{"use strict";e.i(24856);var t=e.i(59100);function s(e,t,a=0){return{ok:!1,status:a,statusText:"",headers:{},body:"",truncated:!1,durationMs:0,url:e,error:t}}async function a(e){let t=await e.text();try{return{json:JSON.parse(t),text:t}}catch{return{json:null,text:t}}}function n(e){return e.slice(0,180).replace(/\s+/g," ").trim()}async function r(e){let t=e.request.url;try{let r=await fetch("/engine/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({request:e.request,auth:e.auth,options:e.options,setup:e.setup,data:e.data,save:e.save,scripts:e.scripts})}),{json:l,text:i}=await a(r);if(!l){let e=n(i);return s(t,e?`Engine error (${r.status}): ${e}`:`Engine error (${r.status}). Is it running?`,r.status)}if(!r.ok)return s(t,"string"==typeof l.error?l.error:"Request failed",r.status);return l}catch(e){return s(t,e instanceof Error?e.message:"Engine unreachable")}}async function l(e){let t=await fetch("/engine/runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),{json:s,text:r}=await a(t);if(!s)throw Error(n(r)||"Failed to start load");if(!t.ok)throw Error("string"==typeof s.error?s.error:"Failed to start load");return s}async function i(e){try{let t=await fetch(`/engine/runs/${e}`,{cache:"no-store"});if(!t.ok)return null;return await t.json()}catch{return null}}async function o(e){try{let t=await fetch(`/engine/runs/${e}/stop`,{method:"POST"});if(!t.ok)return null;return await t.json()}catch{return null}}let d=new Set(["completed","failed","cancelled","interrupted"]);e.s(["fetchRun",0,i,"hostOf",0,function(e){try{return new URL(e).host}catch{return e}},"isSuccess",0,function(e){return!!(e&&e.ok&&e.status>=200&&e.status<300)},"isTerminalStatus",0,function(e){return d.has(e)},"needsLoadConfirm",0,function(e,s,a){if(function(e){try{let t=new URL(e).hostname.toLowerCase();return"localhost"===t||"127.0.0.1"===t||"[::1]"===t||"::1"===t||t.endsWith(".localhost")}catch{return!1}}(a))return!1;if("stress"===e||"spike"===e||"soak"===e)return!0;let n=(0,t.isArrivalRate)(s.executor)?s.rate??Math.max(0,...s.stages.map(e=>e.target)):null;return null!=n?n>=50:((0,t.isArrivalRate)(s.executor)?s.maxVUs??s.vus:s.stages.length>0?Math.max(s.vus,...s.stages.map(e=>e.target)):s.vus)>=25},"sendRequest",0,r,"startLoadRun",0,l,"stopLoadRun",0,o])}]);