apitestcenter 0.12.0 → 0.13.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 (55) hide show
  1. package/dist/THIRD-PARTY-NOTICES-UI.txt +1 -1
  2. package/dist/THIRD-PARTY-NOTICES.txt +1 -1
  3. package/dist/cli.mjs +722 -388
  4. package/dist/ui/404/index.html +1 -1
  5. package/dist/ui/404.html +1 -1
  6. package/dist/ui/__next.__PAGE__.txt +11 -11
  7. package/dist/ui/__next._full.txt +12 -12
  8. package/dist/ui/__next._tree.txt +2 -2
  9. package/dist/ui/_next/static/chunks/0gi0-hmzkqhl_.js +9 -0
  10. package/dist/ui/_next/static/chunks/0k57pe238zzo_.js +119 -0
  11. package/dist/ui/_next/static/chunks/1xkm-ij6841fr.js +19 -0
  12. package/dist/ui/_next/static/chunks/2alsmi687ind7.css +3 -0
  13. package/dist/ui/_next/static/chunks/3nzrtm85qus90.js +1 -0
  14. package/dist/ui/_next/static/chunks/{388t7tbteqx_j.js → 3rlhnherpqpp5.js} +73 -73
  15. package/dist/ui/_not-found/__next._full.txt +11 -11
  16. package/dist/ui/_not-found/__next._not-found.__PAGE__.txt +10 -10
  17. package/dist/ui/_not-found/__next._tree.txt +2 -2
  18. package/dist/ui/_not-found/index.html +1 -1
  19. package/dist/ui/_not-found/index.txt +11 -11
  20. package/dist/ui/compare/__next._full.txt +12 -12
  21. package/dist/ui/compare/__next._tree.txt +2 -2
  22. package/dist/ui/compare/__next.compare.__PAGE__.txt +11 -11
  23. package/dist/ui/compare/index.html +1 -1
  24. package/dist/ui/compare/index.txt +12 -12
  25. package/dist/ui/history/__next._full.txt +13 -13
  26. package/dist/ui/history/__next._tree.txt +2 -2
  27. package/dist/ui/history/__next.history.__PAGE__.txt +12 -12
  28. package/dist/ui/history/index.html +1 -1
  29. package/dist/ui/history/index.txt +13 -13
  30. package/dist/ui/index.html +1 -1
  31. package/dist/ui/index.txt +12 -12
  32. package/dist/ui/preview/__next._full.txt +13 -13
  33. package/dist/ui/preview/__next._tree.txt +2 -2
  34. package/dist/ui/preview/__next.preview.__PAGE__.txt +12 -12
  35. package/dist/ui/preview/index.html +1 -1
  36. package/dist/ui/preview/index.txt +13 -13
  37. package/dist/ui/suite/__next._full.txt +12 -12
  38. package/dist/ui/suite/__next._tree.txt +2 -2
  39. package/dist/ui/suite/__next.suite.__PAGE__.txt +11 -11
  40. package/dist/ui/suite/index.html +1 -1
  41. package/dist/ui/suite/index.txt +12 -12
  42. package/dist/ui/tests/__next._full.txt +11 -11
  43. package/dist/ui/tests/__next._tree.txt +2 -2
  44. package/dist/ui/tests/__next.tests.__PAGE__.txt +10 -10
  45. package/dist/ui/tests/index.html +1 -1
  46. package/dist/ui/tests/index.txt +11 -11
  47. package/package.json +1 -1
  48. package/dist/ui/_next/static/chunks/1-6_oo-9egb_t.js +0 -1
  49. package/dist/ui/_next/static/chunks/1_537szc_614o.js +0 -1
  50. package/dist/ui/_next/static/chunks/1_q4bnjjia0y5.js +0 -19
  51. package/dist/ui/_next/static/chunks/3_q1wiq483s-m.css +0 -3
  52. package/dist/ui/_next/static/chunks/3jywp_61ylz0z.js +0 -119
  53. /package/dist/ui/_next/static/{Tiehe_bgMIxGzSdltdXXB → 9J5wOX3Ij2I3Gph37vpQ-}/_buildManifest.js +0 -0
  54. /package/dist/ui/_next/static/{Tiehe_bgMIxGzSdltdXXB → 9J5wOX3Ij2I3Gph37vpQ-}/_clientMiddlewareManifest.js +0 -0
  55. /package/dist/ui/_next/static/{Tiehe_bgMIxGzSdltdXXB → 9J5wOX3Ij2I3Gph37vpQ-}/_ssgManifest.js +0 -0
@@ -0,0 +1,9 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63343,44794,54792,88871,36620,73436,12580,55680,e=>{"use strict";var t=e.i(61666);e.i(24856);var s=e.i(59100),n=e.i(71189),a=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:n,max:a,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:n,max:a,value:s,onChange:e=>r(h(e.target.value,n,a)),className:"input font-mono"})]})}function p({stages:e,unit:s,rate:r,onChange:l}){let i=(t,s)=>l(e.map((e,n)=>n===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,n)=>{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:n+1}),(0,t.jsx)("input",{"aria-label":`Stage ${n+1} duration`,"aria-invalid":!!o||void 0,title:o,value:s.duration,onChange:e=>i(n,{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 ${n+1} target`,type:"number",min:0,max:r?1e5:500,value:s.target,onChange:e=>i(n,{target:h(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 ${n+1}`,disabled:e.length<=1,onClick:()=>l(e.filter((e,t)=>t!==n)),className:"grid place-items-center text-mute hover:text-bad disabled:opacity-30",children:(0,t.jsx)(a.X,{size:13})})]},n)})]}),(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)(n.Plus,{size:12,"aria-hidden":!0})," Add stage"]})]})}function h(e,t,s){let n=Math.round(Number(e));return Number.isFinite(n)?Math.min(s,Math.max(t,n)):t}function m(e){let t="rate"===e.mode;if(e.stages&&e.stages.length){let t=[[0,0]],n=0;for(let a of e.stages)n+=(0,s.durationToMs)(a.duration),t.push([n,a.target]);return{points:t,totalMs:n,peak:Math.max(0,...e.stages.map(e=>e.target))}}let n=t?e.rps??20:e.vus,a=(0,s.durationToMs)(e.rampUp),r=(0,s.durationToMs)(e.duration),l=(0,s.durationToMs)(e.rampDown);return{points:[[0,a>0?0:n],[a,n],[a+r,n],[a+r+l,l>0?0:n]],totalMs:a+r+l,peak:n}}function x(e){let{totalMs:t,peak:s}=m(e),n="rate"===e.mode?"req/s":1===s?"VU":"VUs";return`${e.stages?.length?"peak ":""}${s.toLocaleString()} ${n} \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:n,peak:a}=m(e),r=s.map(([e,t])=>`${e/Math.max(n,1)*300},${56-t/Math.max(a,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(n)})]})]})}e.s(["LoadEditor",0,function({load:e,onChange:n}){let[a,h]=(0,r.useState)(!1),m=t=>n({...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=>n((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=>m({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 m({stages:null});let n=x?e.rps??20:e.vus,a=[];(0,s.durationToMs)(e.rampUp)>0&&a.push({duration:e.rampUp,target:n}),a.push({duration:e.duration,target:n}),(0,s.durationToMs)(e.rampDown)>0&&a.push({duration:e.rampDown,target:0}),m({stages:a})},options:[{value:"simple",label:"Ramp · hold · down"},{value:"stages",label:"Step by step"}]})]})]}),f?(0,t.jsx)(p,{stages:e.stages,unit:x?"req/s":"VUs",rate:x,onChange:e=>m({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=>m({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=>m({vus:e})}),(0,t.jsx)(i.LabeledInput,{label:"Hold for",mono:!0,value:e.duration,error:(0,d.durationError)(e.duration,!1),onChange:e=>m({duration:e})}),(0,t.jsx)(i.LabeledInput,{label:"Ramp up",mono:!0,value:e.rampUp,error:(0,d.durationError)(e.rampUp),onChange:e=>m({rampUp:e})}),(0,t.jsx)(i.LabeledInput,{label:"Ramp down",mono:!0,value:e.rampDown,error:(0,d.durationError)(e.rampDown),onChange:e=>m({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=>m({maxVus:e})})}):null,(0,t.jsx)(b,{load:e}),(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>h(e=>!e),"aria-expanded":a,children:a?"Hide pacing options":"Pacing options"}),a?(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=>m({thinkTimeMs:e})}),(0,t.jsx)(u,{label:"Random extra (ms)",value:e.thinkJitterMs,min:0,max:6e5,onChange:e=>m({thinkJitterMs:e})})]}),(0,t.jsx)(i.LabeledInput,{label:"Graceful stop",mono:!0,value:e.gracefulStop,error:(0,d.durationError)(e.gracefulStop),onChange:e=>m({gracefulStop:e}),hint:"Time in-flight requests get to finish."})]}):null]})},"profileSummary",0,x],63343);var v=e.i(1675),g=e.i(458),y=e.i(80707);let j=null,w=null,k=new Set;function N(){return w??=fetch("/engine/local-servers",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>(e&&(j=e.servers),j)).catch(()=>j).finally(()=>{w=null,k.forEach(e=>e())}),k.forEach(e=>e()),w}var $=e.i(6278);let C=/^\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/,S=/^(https?):\/\/(localhost|127\.0\.0\.1)(?::(\d{1,5}))?(?=[/?#]|$)/i,T="\0none",q="\0local-other",R="apitestcenter-local-ports",M={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad",HEAD:"text-mute",OPTIONS:"text-mute"};function E(){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 H(e){try{localStorage.setItem(R,JSON.stringify([e,...E().filter(t=>t!==e)].slice(0,5)))}catch{}}let L=(0,r.forwardRef)(function({draft:e,onChange:s,onImported:n,actions:l},i){let{vars:o,environments:c,activeEnv:u}=(0,$.useWorkspace)(),[p,h]=(0,r.useState)([]),[m,x]=(0,r.useState)(null),[f,b]=(0,r.useState)(!1),R=(0,r.useRef)(null);(0,r.useEffect)(()=>h(E()),[]),(0,r.useEffect)(()=>{m&&R.current?.focus()},[m]);let L=e.url,A=C.exec(L)?.[1],P=Object.entries(o).filter(([e,t])=>/^https?:\/\//i.test(t.trim())&&("practiceApi"!==e||A===e)),D=(()=>{if(f)return null;let e=C.exec(L);if(e&&P.some(([t])=>t===e[1]))return{prefix:e[0],text:`{{${e[1]}}}`,value:e[1]};let t=S.exec(L);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})(),z=L.startsWith("/"),F=z||""===L||null!=D,U=function(e){let[,t]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=()=>t(e=>e+1);return k.add(e),()=>void k.delete(e)},[]),(0,r.useEffect)(()=>{e&&null==j&&!w&&N()},[e]);let s=(0,r.useCallback)(()=>void N(),[]);return{servers:j??[],checked:null!=j,checking:null!=w,refresh:s}}(F),B=D?L.slice(D.prefix.length):L,O=e=>{let t=""===B||B.startsWith("/")||B.startsWith("?")?B:`/${B}`;return`${e}${t||(e.startsWith("{{")?"":"/")}`},I=U.servers,V=[...I.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})),...p.filter(e=>!I.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}))];D?.value.startsWith("local:")&&!V.some(e=>e.value===D.value)&&V.unshift({value:D.value,label:D.text,hint:"in this request",text:D.text,className:"font-mono",group:"local",inline:!0});let W=null!=D&&!D.value.startsWith("local:"),_=[...P.length?[{id:"env",label:u?.name??"Variables",text:u?.name??"variables",defaultOpen:W||null==D,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…":`${I.length||"none"} running${U.checking?" · checking…":""}`,defaultOpen:!P.length&&null==D,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=D?"text-accent":z?"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)(y.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 ${M[e]}`})),minWidth:140,className:`shrink-0 border-r border-line px-3 font-mono text-sm font-medium outline-none focus-visible:bg-panel ${M[e.method]}`}),m?(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(!m)return;let t=Number(m.port);!Number.isInteger(t)||t<1||t>65535||(H(t),h(E()),s((0,d.withUrl)(e,O(`${m.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({...m,scheme:"http"===m.scheme?"https":"http"}),className:"rounded px-1 text-accent hover:bg-panel",children:m.scheme}),(0,t.jsx)("span",{className:"text-mute",children:"://localhost:"}),(0,t.jsx)("input",{ref:R,value:m.port,onChange:e=>x({...m,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)(a.X,{size:14})})]}):F?(0,t.jsx)(y.Select,{label:"Base URL",value:D?.value??T,onChange:t=>{if(t===q)return x({scheme:"http",port:""});if(t===T)return s((0,d.withUrl)(e,B));if(t.startsWith("local:")){let[,n,a]=t.split(":"),r=Number(a);return H(r),h(E()),s((0,d.withUrl)(e,O(`${n}://localhost:${r}`)))}s((0,d.withUrl)(e,O(`{{${t}}}`)))},onOpen:U.refresh,minWidth:320,buttonContent:D?.text??"Base URL",groups:_,options:[...P.map(([e,t])=>({value:e,label:`{{${e}}}`,hint:t,text:e,className:"font-mono text-accent",group:"env"})),...V,{value:q,label:"Another port…",text:"another port",group:"local"},{value:T,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:B,spellCheck:!1,autoComplete:"off",onChange:t=>{let n=t.target.value,a=/^(https?:\/\/|\{\{)/i.test(n.trim())||""===B&&""!==n&&!/^[/?#]/.test(n);/^https?:\/\//i.test(n.trim())&&b(!0),s((0,d.withUrl)(e,D&&!a?`${D.prefix}${n}`:n))},onBlur:()=>b(!1),onPaste:t=>{let a=(0,d.withPaste)(e,t.clipboardData.getData("text"));a&&(t.preventDefault(),s(a.draft),a.note&&n?.(a.note))},placeholder:D?"/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,L],44794);var A=e.i(99522);let P=(0,A.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);e.s(["ChevronUp",0,P],54792);let D=(0,A.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"}]]);e.s(["WrapText",0,D],88871);let z="<hidden>";function F(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]} ${z}`}return z}(e,s):s]),n=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,z);n=t.toString().replace(/%3Chidden%3E/g,z)}catch{}return{...e,url:n,headers:s}}let U=[{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"}],B=new Set(["host","content-length","connection","accept-encoding"]);function O(e){return e.headers.filter(([e,t])=>!B.has(e.toLowerCase())&&!("user-agent"===e.toLowerCase()&&t.startsWith("ApiTestCenter/")))}let I=e=>JSON.stringify(e),V=e=>`'${e.replace(/'/g,"'\\''")}'`,W=e=>`'${e.replace(/'/g,"''")}'`,_=e=>`@"${e.replace(/"/g,'""')}"`;var J=e.i(89932);let K=(0,A.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,K],36620);let G=(0,A.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,G],73436);var X=e.i(42967),Z=e.i(56396);let Q="apitestcenter-code-target";e.s(["ResponseCookiesView",0,function({cookies:e}){let[s,n]=(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:()=>n(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)(G,{size:12,"aria-hidden":!0}):(0,t.jsx)(K,{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,n)=>{var a;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)":z}),(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 ${(a=e.maxAge)<120?`${a} s`:a<7200?`${Math.round(a/60)} min`:a<172800?`${Math.round(a/3600)} h`:`${Math.round(a/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(" · ")||"—"})]},n)})})]})})]})},"SentRequestView",0,function({sent:e}){let s=(0,Z.useToast)(),[n,a]=(0,r.useState)(!1),[l,i]=(0,r.useState)("curl");(0,r.useEffect)(()=>i(function(){try{let e=localStorage.getItem(Q);if(U.some(t=>t.id===e))return e}catch{}return"curl"}()),[]);let o=(0,r.useMemo)(()=>n?e:F(e),[e,n]),d=(0,r.useMemo)(()=>(function(e,t){if(t.form||t.file)return function(e,t){let s=t.form,n=t.file,a=O(t).filter(([e])=>!(s&&"content-type"===e.toLowerCase())),r=t.method.toUpperCase(),l=(s??[]).filter(e=>void 0!==e.file),i=l.length+ +!!n===1,o=e=>`${e} ${i?"The file name stands for the file you chose: put its path there.":"File names stand for the files you chose: put their paths there."}`,d=e=>e.replace(/["\\\r\n]/g,"_"),c=[];switch(e){case"curl":for(let[e,s]of(c.push(`curl -X ${r} ${V(t.url)}`),a))c.push(` -H ${V(`${e}: ${s}`)}`);for(let e of s??[])c.push(void 0!==e.file?` -F ${V(`${e.name}=@${e.file}${e.contentType?`;type=${e.contentType}`:""}`)}`:` --form-string ${V(`${e.name}=${e.value??""}`)}`);return n&&c.push(` --data-binary ${V(`@${n.name}`)}`),t.insecure&&c.push(" -k"),`${o("#")}
2
+ ${c.join(" \\\n")}`;case"powershell":{let e=a.filter(([e])=>"content-type"!==e.toLowerCase());if(c.push(o("#"),"# PowerShell 7 or later."),e.length){for(let[t,s]of(c.push("$headers = @{"),e))c.push(` ${W(t)} = ${W(s)}`);c.push("}")}let l=[`-Uri ${W(t.url)}`,`-Method ${r}`];if(e.length&&l.push("-Headers $headers"),s){for(let e of(c.push("$form = @{"),s))c.push(` ${W(e.name)} = ${void 0!==e.file?`Get-Item -Path ${W(e.file)}`:W(e.value??"")}`);c.push("}"),l.push("-Form $form")}return n&&l.push(`-InFile ${W(n.name)}`,`-ContentType ${W(n.contentType)}`),t.insecure&&l.push("-SkipCertificateCheck"),c.push(`$response = Invoke-WebRequest ${l.join(" ")}`,"$response.StatusCode","$response.Content"),c.join("\n")}case"javascript":if(c.push(o("//"),'import { openAsBlob } from "node:fs";',""),s)for(let e of(c.push("const form = new FormData();"),s))c.push(void 0!==e.file?`form.append(${I(e.name)}, await openAsBlob(${I(e.file)}${e.contentType?`, { type: ${I(e.contentType)} }`:""}), ${I(e.file)});`:`form.append(${I(e.name)}, ${I(e.value??"")});`);if(c.push(`const response = await fetch(${I(t.url)}, {`,` method: ${I(r)},`),a.length){for(let[e,t]of(c.push(" headers: {"),a))c.push(` ${I(e)}: ${I(t)},`);c.push(" },")}return c.push(s?" body: form,":` body: await openAsBlob(${I(n.name)}),`),c.push("});","console.log(response.status);","console.log(await response.text());"),c.join("\n");case"python":{if(c.push(o("#"),"import requests","",`url = ${I(t.url)}`),a.length){for(let[e,t]of(c.push("headers = {"),a))c.push(` ${I(e)}: ${I(t)},`);c.push("}")}let e=[I(r),"url"];if(a.length&&e.push("headers=headers"),s){let t=s.filter(e=>void 0===e.file);if(t.length){for(let e of(c.push("data = ["),t))c.push(` (${I(e.name)}, ${I(e.value??"")}),`);c.push("]"),e.push("data=data")}for(let e of(c.push("files = ["),l))c.push(` (${I(e.name)}, (${I(e.file)}, open(${I(e.file)}, "rb")${e.contentType?`, ${I(e.contentType)}`:""})),`);c.push("]"),e.push("files=files")}return n&&e.push(`data=open(${I(n.name)}, "rb")`),t.insecure&&e.push("verify=False"),c.push("",`response = requests.request(${e.join(", ")})`,"print(response.status_code)","print(response.text)"),c.join("\n")}case"csharp":{let e=a.filter(([e])=>"content-type"!==e.toLowerCase());for(let[s,n]of(c.push(o("//"),"using System.Net.Http.Headers;",""),c.push(t.insecure?"using var client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator });":"using var client = new HttpClient();"),c.push(`var request = new HttpRequestMessage(new HttpMethod(${_(r)}), ${_(t.url)});`),e))c.push(`request.Headers.TryAddWithoutValidation(${_(s)}, ${_(n)});`);return s&&(c.push("var form = new MultipartFormDataContent();"),s.forEach((e,t)=>{void 0===e.file?c.push(`form.Add(new StringContent(${_(e.value??"")}), ${_(e.name)});`):(c.push(`var file${t} = new ByteArrayContent(File.ReadAllBytes(${_(e.file)}));`),e.contentType&&c.push(`file${t}.Headers.ContentType = MediaTypeHeaderValue.Parse(${_(e.contentType)});`),c.push(`form.Add(file${t}, ${_(e.name)}, ${_(e.file)});`))}),c.push("request.Content = form;")),n&&c.push(`request.Content = new ByteArrayContent(File.ReadAllBytes(${_(n.name)}));`,`request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(${_(n.contentType)});`),c.push("var response = await client.SendAsync(request);","Console.WriteLine((int)response.StatusCode);","Console.WriteLine(await response.Content.ReadAsStringAsync());"),c.join("\n")}case"java":if(c.push(o("//"),"import java.net.URI;","import java.net.http.HttpClient;","import java.net.http.HttpRequest;","import java.net.http.HttpResponse;","import java.nio.file.Files;","import java.nio.file.Path;"),s&&c.push("import java.util.ArrayList;"),c.push(""),s){for(let e of(c.push('String boundary = "----ApiTestCenter" + System.currentTimeMillis();',"var parts = new ArrayList<byte[]>();"),s)){let t=`form-data; name="${d(e.name)}"`;void 0===e.file?c.push(`parts.add(("--" + boundary + ${I(`\r
3
+ Content-Disposition: ${t}\r
4
+ \r
5
+ `)} + ${I(e.value??"")} + "\\r\\n").getBytes("UTF-8"));`):(c.push(`parts.add(("--" + boundary + ${I(`\r
6
+ Content-Disposition: ${t}; filename="${d(e.file)}"\r
7
+ Content-Type: ${e.contentType??"application/octet-stream"}\r
8
+ \r
9
+ `)}).getBytes("UTF-8"));`),c.push(`parts.add(Files.readAllBytes(Path.of(${I(e.file)})));`,'parts.add("\\r\\n".getBytes("UTF-8"));'))}c.push('parts.add(("--" + boundary + "--\\r\\n").getBytes("UTF-8"));',"")}for(let[e,s]of(t.insecure&&c.push("// The certificate check was skipped in the app; Java's HttpClient needs an SSLContext that trusts the test server."),c.push("HttpClient client = HttpClient.newHttpClient();","HttpRequest request = HttpRequest.newBuilder()",` .uri(URI.create(${I(t.url)}))`),a))c.push(` .header(${I(e)}, ${I(s)})`);return s&&c.push(' .header("Content-Type", "multipart/form-data; boundary=" + boundary)'),c.push(` .method(${I(r)}, ${s?"HttpRequest.BodyPublishers.ofByteArrays(parts)":`HttpRequest.BodyPublishers.ofFile(Path.of(${I(n.name)}))`})`," .build();"),c.push("HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());","System.out.println(response.statusCode());","System.out.println(response.body());"),c.join("\n");case"go":{let e=['"fmt"','"io"','"net/http"','"os"',...s?['"bytes"','"mime/multipart"','"net/textproto"']:[],...t.insecure?['"crypto/tls"']:[]].sort();if(c.push(o("//"),"package main","","import (",...e.map(e=>` ${e}`),")","","func main() {"),s){for(let e of(c.push(" var body bytes.Buffer"," w := multipart.NewWriter(&body)"),s)){if(void 0===e.file){c.push(` w.WriteField(${I(e.name)}, ${I(e.value??"")})`);continue}c.push(" {"," h := make(textproto.MIMEHeader)",` h.Set("Content-Disposition", ${I(`form-data; name="${d(e.name)}"; filename="${d(e.file)}"`)})`,` h.Set("Content-Type", ${I(e.contentType??"application/octet-stream")})`," part, _ := w.CreatePart(h)",` data, err := os.ReadFile(${I(e.file)})`," if err != nil {"," panic(err)"," }"," part.Write(data)"," }")}c.push(" w.Close()")}else c.push(` body, err := os.Open(${I(n.name)})`," if err != nil {"," panic(err)"," }"," defer body.Close()");for(let[e,n]of(c.push(` req, err := http.NewRequest(${I(r)}, ${I(t.url)}, ${s?"&body":"body"})`," if err != nil {"," panic(err)"," }"),a))c.push(` req.Header.Set(${I(e)}, ${I(n)})`);return s&&c.push(' req.Header.Set("Content-Type", w.FormDataContentType())'),c.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))","}"),c.join("\n")}case"k6":if(c.push(o("//"),'import http from "k6/http";','import { check, sleep } from "k6";',""),l.forEach((e,t)=>c.push(`const file${t} = open(${I(e.file)}, "b");`)),n&&c.push(`const body = open(${I(n.name)}, "b");`),c.push("",`export const options = { vus: 5, duration: "30s"${t.insecure?", insecureSkipTLSVerify: true":""} };`,""),c.push("export default function () {"),s){let e=0;for(let t of(c.push(" const body = {"),s))c.push(` ${I(t.name)}: ${void 0!==t.file?`http.file(file${e++}, ${I(t.file)}${t.contentType?`, ${I(t.contentType)}`:""})`:I(t.value??"")},`);c.push(" };")}if(c.push(` const res = http.request(${I(r)}, ${I(t.url)}, body, {`),a.length){for(let[e,t]of(c.push(" headers: {"),a))c.push(` ${I(e)}: ${I(t)},`);c.push(" },")}return c.push(" });",' check(res, { "status is 2xx": (r) => r.status >= 200 && r.status < 300 });'," sleep(1);","}"),c.join("\n")}}(e,t);let s=O(t),n=t.body,a=t.method.toUpperCase(),r=[];switch(e){case"curl":for(let[e,l]of(r.push(`curl${"GET"===a&&void 0===n?"":` -X ${a}`} ${V(t.url)}`),s))r.push(` -H ${V(`${e}: ${l}`)}`);return void 0!==n&&r.push(` --data-raw ${V(n)}`),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(` ${W(e)} = ${W(t)}`);r.push("}")}let i=[`-Uri ${W(t.url)}`,`-Method ${a}`];return l.length&&i.push("-Headers $headers"),e&&i.push(`-ContentType ${W(e)}`),void 0!==n&&i.push(/^[\x20-\x7e\r\n\t]*$/.test(n)?`-Body ${W(n)}`:`-Body ([System.Text.Encoding]::UTF8.GetBytes(${W(n)}))`),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(${I(t.url)}, {`,` method: ${I(a)},`),s.length){for(let[e,t]of(r.push(" headers: {"),s))r.push(` ${I(e)}: ${I(t)},`);r.push(" },")}return void 0!==n&&r.push(` body: ${I(n)},`),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 = ${I(t.url)}`),s.length){for(let[e,t]of(r.push("headers = {"),s))r.push(` ${I(e)}: ${I(t)},`);r.push("}")}void 0!==n&&r.push(`payload = ${I(n)}`);let e=[I(a),"url"];return s.length&&e.push("headers=headers"),void 0!==n&&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(${_(a)}), ${_(t.url)});`),l))r.push(`request.Headers.TryAddWithoutValidation(${_(e)}, ${_(s)});`);return void 0!==n&&(r.push(`request.Content = new StringContent(${_(n)});`),e&&r.push(`request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(${_(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,n]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(${I(t.url)}))`),s))r.push(` .header(${I(e)}, ${I(n)})`);return r.push(` .method(${I(a)}, ${void 0!==n?`HttpRequest.BodyPublishers.ofString(${I(n)})`:"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!==n?['"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(${I(a)}, ${I(t.url)}, ${void 0!==n?`strings.NewReader(${I(n)})`:"nil"})`),r.push(" if err != nil {"," panic(err)"," }"),s))r.push(` req.Header.Set(${I(l)}, ${I(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(${I(a)}, ${I(t.url)}, ${void 0!==n?I(n):"null"}, {`),s.length){for(let[e,t]of(r.push(" headers: {"),s))r.push(` ${I(e)}: ${I(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(F(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:()=>a(e=>!e),"aria-pressed":n,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:[n?(0,t.jsx)(G,{size:12,"aria-hidden":!0}):(0,t.jsx)(K,{size:12,"aria-hidden":!0}),n?"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)(X.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)(J.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],n)=>(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(z)?"text-mute italic":"text-ink"}`,children:s})]},n))})})})]}),(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)(y.Select,{label:"Language",value:l,onChange:e=>{i(e);try{localStorage.setItem(Q,e)}catch{}},options:U.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)(J.Copy,{size:12})," Copy"]})]}),(0,t.jsx)("pre",{"aria-label":`${U.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:[n||!c?"":`Secrets show as ${z} — 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.":""]})]})]})}],12580);let Y=(0,A.default)("arrow-down-left",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);e.s(["ArrowDownLeft",0,Y],55680)},60566,97716,68228,65638,46679,e=>{"use strict";var t=e.i(61666),s=e.i(95486),n=e.i(54792),a=e.i(89932),r=e.i(75117),l=e.i(88293),i=e.i(88871),o=e.i(83067),d=e.i(28867),c=e.i(13318),u=e.i(56396),p=e.i(15060),h=e.i(12580),m=e.i(55680),x=e.i(20738),f=e.i(42967),b=e.i(50962),v=e.i(42709),g=e.i(10281);let y={async connect(e){let t=await fetch("/engine/realtime/ws",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),s=await t.json();if(!t.ok||!s.id)throw Error(s.error??`Could not connect (${t.status})`);return{id:s.id}},close:e=>fetch(`/engine/realtime/${e}/close`,{method:"POST"}).catch(()=>void 0)};function j({id:e,onClosed:s}){let n=(0,u.useToast)(),[r,i]=(0,o.useState)([]),[d,c]=(0,o.useState)(null),[p,h]=(0,o.useState)(!1),[w,k]=(0,o.useState)(""),[N,$]=(0,o.useState)(""),[C,S]=(0,o.useState)(!0),T=(0,o.useRef)(null),q=(0,o.useRef)(0),R=(0,o.useRef)(s);R.current=s,(0,o.useEffect)(()=>{i([]),c(null),h(!1),q.current=0;let t=!0,s=0,n=async()=>{try{let s=await fetch(`/engine/realtime/${e}?since=${q.current}`,{cache:"no-store"});if(404===s.status)return void h(!0);let n=await s.json();if(!t)return;if(q.current=n.next,n.events.length&&i(e=>[...e,...n.events].slice(-2e3)),c({kind:n.kind,url:n.url,status:n.status,dropped:n.dropped}),"closed"===n.status)return void R.current?.()}catch{}t&&(s=window.setTimeout(()=>void n(),350))};return n(),()=>{t=!1,window.clearTimeout(s)}},[e]),(0,o.useEffect)(()=>{C&&T.current?.lastElementChild?.scrollIntoView({block:"nearest"})},[r,C]);let M=(0,o.useMemo)(()=>N?r.filter(e=>e.text.toLowerCase().includes(N.toLowerCase())||(e.event??"").toLowerCase().includes(N.toLowerCase())):r,[r,N]),E=(0,o.useMemo)(()=>({in:r.filter(e=>"in"===e.dir).length,out:r.filter(e=>"out"===e.dir).length}),[r]),H=d?.status==="open",L=d?.kind==="ws",A=async()=>{if(!w.trim()||!H)return;let t=await fetch(`/engine/realtime/${e}/send`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:w})});t.ok||n((await t.json().catch(()=>({}))).error??"Could not send","error")};return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[(0,t.jsx)("span",{className:`rounded-md border px-2 py-0.5 font-mono text-sm ${p?"border-line text-mute":H?"border-ok/40 bg-ok/10 text-ok":d?.status==="connecting"?"border-accent/40 text-accent":"border-line text-mute"}`,children:p?"Gone":H?L?"Connected":"Receiving":d?.status==="connecting"?"Connecting…":"Closed"}),(0,t.jsxs)("span",{className:"text-xs text-mute",children:[L?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-ink",children:E.in})," received · ",(0,t.jsx)("span",{className:"text-ink",children:E.out})," sent"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-ink",children:E.in})," events"]}),d?.dropped?` \xb7 first ${d.dropped} no longer kept`:""]}),(0,t.jsxs)("label",{className:"ml-auto flex items-center gap-1 rounded-md border border-line bg-panel px-1.5",children:[(0,t.jsx)(l.Search,{size:12,className:"text-mute","aria-hidden":!0}),(0,t.jsx)("input",{value:N,onChange:e=>$(e.target.value),"aria-label":"Filter messages",placeholder:"Filter",className:"w-28 bg-transparent py-1 text-xs text-ink outline-none"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-mute",children:[(0,t.jsx)("input",{type:"checkbox",checked:C,onChange:e=>S(e.target.checked),className:"accent-[var(--accent)]"}),"Follow"]}),H?(0,t.jsxs)("button",{type:"button",onClick:()=>void y.close(e),className:"inline-flex items-center gap-1 rounded-md border border-line px-2 py-1 text-xs text-mute hover:text-ink",children:[(0,t.jsx)(g.Unplug,{size:12,"aria-hidden":!0})," ",L?"Disconnect":"Stop"]}):null]}),d?.url?(0,t.jsx)("p",{className:"font-mono text-xs break-all text-mute",children:d.url}):null,(0,t.jsxs)("ol",{ref:T,"aria-label":L?"Messages":"Events","aria-live":"polite",className:"min-h-[14rem] flex-1 space-y-1 overflow-auto rounded-md border border-line bg-panel-2 p-2",children:[0===M.length?(0,t.jsx)("li",{className:"p-2 text-xs text-mute",children:N?"Nothing matches the filter.":L?"No messages yet.":"No events yet."}):null,M.map((e,s)=>{let r;return(0,t.jsxs)("li",{className:`group flex gap-2 rounded px-1.5 py-1 text-[12.5px] ${"error"===e.dir?"bg-bad/10":"out"===e.dir?"bg-accent/5":""}`,children:[(0,t.jsx)("span",{className:"w-14 shrink-0 pt-0.5 text-right font-mono text-[11px] text-mute tabular",children:(r=e.at/1e3)<60?`${r.toFixed(2)} s`:`${Math.floor(r/60)}:${String(Math.floor(r%60)).padStart(2,"0")}`}),(0,t.jsx)("span",{className:"shrink-0 pt-0.5","aria-label":"in"===e.dir?"received":"out"===e.dir?"sent":e.dir,children:"in"===e.dir?(0,t.jsx)(m.ArrowDownLeft,{size:13,className:"text-ok"}):"out"===e.dir?(0,t.jsx)(x.ArrowUpRight,{size:13,className:"text-accent"}):"error"===e.dir?(0,t.jsx)(v.TriangleAlert,{size:13,className:"text-bad"}):(0,t.jsx)(f.Info,{size:13,className:"text-mute"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[e.event||e.id?(0,t.jsxs)("span",{className:"mr-2 font-mono text-[11px] text-mute",children:[e.event?`event: ${e.event}`:"",e.id?` id: ${e.id}`:""]}):null,(0,t.jsx)("span",{className:`block font-mono break-words whitespace-pre-wrap ${"info"===e.dir?"text-mute":"error"===e.dir?"text-bad":"text-ink"}`,children:"in"===e.dir||"out"===e.dir?function(e){let t=e.trim();if(!(t.startsWith("{")||t.startsWith("[")))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}(e.text):e.text})]}),"in"===e.dir||"out"===e.dir?(0,t.jsx)("button",{type:"button","aria-label":"Copy message",onClick:()=>{navigator.clipboard.writeText(e.text),n("Message copied","success")},className:"shrink-0 self-start rounded p-0.5 text-mute opacity-0 group-hover:opacity-100 hover:text-ink focus:opacity-100",children:(0,t.jsx)(a.Copy,{size:12})}):null]},s)})]}),L?(0,t.jsxs)("form",{className:"flex items-end gap-2",onSubmit:e=>{e.preventDefault(),A()},children:[(0,t.jsxs)("label",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"sr-only",children:"Message to send"}),(0,t.jsx)("textarea",{value:w,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),A())},rows:Math.min(8,Math.max(2,w.split("\n").length)),disabled:!H,placeholder:H?'{ "type": "subscribe", "channel": "orders" } — Ctrl+Enter sends':"Connect to send messages",spellCheck:!1,className:"w-full resize-y rounded-md border border-line bg-panel-2 px-3 py-2 font-mono text-[13px] text-ink outline-none focus:border-accent disabled:opacity-50"})]}),(0,t.jsxs)("button",{type:"submit",disabled:!H||!w.trim(),className:"btn btn-primary py-2",children:[(0,t.jsx)(b.Send,{size:14})," Send"]})]}):null]})}e.s(["LiveView",0,j,"realtimeApi",0,y],97716);var w=e.i(19656);let k={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 N(e){return e>=200&&e<300?"text-ok border-ok/40 bg-ok/10":e>=300&&e<400?"text-accent border-accent/40 bg-accent/10":e>=400&&e<500?"text-warn border-warn/40 bg-warn/10":"text-bad border-bad/40 bg-bad/10"}function $({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 C({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 S({message:e}){let s,{title:n,tip:a}=(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:n}),(0,t.jsx)("p",{className:"mt-1 text-sm text-ink",children:a}),(0,t.jsx)("p",{className:"mt-2 font-mono text-xs break-all text-mute",children:e})]})}function T({headers:e}){let s=(0,u.useToast)(),n=Object.entries(e).sort(([e],[t])=>e.localeCompare(t));return 0===n.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(n.map(([e,t])=>`${e}: ${t}`).join("\n")),s("Headers copied","success")},children:[(0,t.jsx)(a.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:n.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 q({body:e,contentType:c,truncated:h,url:m,base64:x}){let f=(0,u.useToast)(),b=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 n=e.trim();if(n.startsWith("{")||n.startsWith("["))try{return JSON.parse(n),"json"}catch{}return/^<!doctype html|^<html/i.test(n)?"html":n.startsWith("<")?"xml":"text"}(e,c),v="image"===b&&x?`data:${c.split(";")[0]};base64,${x}`:null,g=h||e.length>=16384,[y,j]=(0,o.useState)("pretty"),[w,k]=(0,o.useState)(!0),[N,$]=(0,o.useState)(""),[C,S]=(0,o.useState)(0),[T,H]=(0,o.useState)(!1),L=(0,o.useRef)(null),A=(0,o.useRef)(null);(0,o.useEffect)(()=>{j("image"===b?"preview":"pretty"),$(""),S(0)},[e,b]);let P=(0,o.useMemo)(()=>e?"raw"===y?e:function(e,t){if("json"!==t)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}(e,b):"",[e,y,b]),D=(0,o.useMemo)(()=>(function(e,t){if(!t)return 0;let s=e.toLowerCase(),n=t.toLowerCase(),a=0;for(let e=s.indexOf(n);e>=0&&a<1e4;e=s.indexOf(n,e+n.length))a++;return a})(P,N),[P,N]);function z(e){0!==D&&S(t=>(t+e+D)%D)}(0,o.useEffect)(()=>{let e=A.current?.querySelector("mark.current");e?.scrollIntoView({block:"center"})},[C,N,y]);let F=v?[{value:"preview",label:"Preview"},{value:"raw",label:"Raw"}]:[{value:"pretty",label:"Pretty"},{value:"raw",label:"Raw"},..."html"===b?[{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(),H(!0),window.setTimeout(()=>L.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)(d.Segmented,{label:"Body view",value:y,onChange:j,options:F}),(0,t.jsx)("span",{className:"rounded border border-line px-1.5 py-0.5 font-mono text-xs text-mute uppercase",children:b}),h?(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:[T?(0,t.jsxs)("div",{className:"flex items-center gap-1 rounded-md border border-line bg-panel px-1.5",children:[(0,t.jsx)(l.Search,{size:12,className:"text-mute"}),(0,t.jsx)("input",{ref:L,value:N,"aria-label":"Find in body",placeholder:"Find",onChange:e=>{$(e.target.value),S(0)},onKeyDown:e=>{"Enter"===e.key&&z(e.shiftKey?-1:1),"Escape"===e.key&&($(""),H(!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:N?`${D?C+1:0}/${D}`:""}),(0,t.jsx)(R,{label:"Previous match",onClick:()=>z(-1),children:(0,t.jsx)(n.ChevronUp,{size:12})}),(0,t.jsx)(R,{label:"Next match",onClick:()=>z(1),children:(0,t.jsx)(s.ChevronDown,{size:12})})]}):(0,t.jsx)(R,{label:"Find in body (Ctrl+F)",onClick:()=>{H(!0),window.setTimeout(()=>L.current?.focus(),0)},children:(0,t.jsx)(l.Search,{size:14})}),(0,t.jsx)(R,{label:w?"Turn off line wrap":"Wrap long lines",pressed:w,onClick:()=>k(e=>!e),children:(0,t.jsx)(i.WrapText,{size:14})}),(0,t.jsx)(R,{label:"Copy body",onClick:()=>{navigator.clipboard.writeText(P),f("Body copied","success")},children:(0,t.jsx)(a.Copy,{size:14})}),(0,t.jsx)(R,{label:"Download body",onClick:()=>{var e;return v&&x?(0,p.downloadBlob)(E(m,b,c),new Blob([Uint8Array.from(atob(x),e=>e.charCodeAt(0))],{type:c.split(";")[0]})):(0,p.downloadText)(E(m,b),P,"json"===(e=b)?"application/json":"html"===e?"text/html":"xml"===e?"application/xml":"text/plain")},children:(0,t.jsx)(r.Download,{size:14})})]})]}),"preview"===y&&v?(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:v,alt:"Response image",className:"max-h-[32rem] max-w-full object-contain"})}):"preview"===y?(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:A,tabIndex:0,"aria-label":"Response body",className:`min-h-[12rem] flex-1 overflow-auto p-3 font-mono text-[13px] leading-5 text-ink ${w?"break-words whitespace-pre-wrap":"whitespace-pre"}`,children:N?function(e,s,n){let a=[],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))a.push(e.slice(i,s)),a.push((0,t.jsx)("mark",{className:`find-hit${o===n?" current":""}`,children:e.slice(s,s+l.length)},s)),i=s+l.length,o++;return a.push(e.slice(i)),a}(P,N,C):"pretty"!==y||"json"!==b||g?P:function(e){let s=[],n=0;for(let a of e.matchAll(M)){let r=a.index??0;s.push(e.slice(n,r)),a[1]?(s.push((0,t.jsx)("span",{className:a[2]?"tok-key":"tok-str",children:a[1]},r)),a[2]&&s.push(a[2])):a[3]?s.push((0,t.jsx)("span",{className:"tok-lit",children:a[3]},r)):s.push((0,t.jsx)("span",{className:"tok-num",children:a[4]},r)),n=r+a[0].length}return s.push(e.slice(n)),s}(P)})]}):(0,t.jsx)("p",{className:"text-sm text-mute",children:"Empty body."})}function R({label:e,onClick:s,children:n,pressed:a}){return(0,t.jsx)("button",{type:"button","aria-label":e,title:e,"aria-pressed":a,onClick:s,className:`rounded p-1 hover:bg-panel hover:text-ink ${a?"text-accent":"text-mute"}`,children:n})}let M=/("(?:\\u[a-fA-F0-9]{4}|\\[^u]|[^\\"])*")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function E(e,t,s=""){let n="response";try{n=new URL(e).pathname.split("/").filter(Boolean).pop()||"response"}catch{}let a="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`${n.replace(/[^\w.-]+/g,"_")}.${a}`}e.s(["ResponseViewer",0,function({result:e,onSaveExample:s,extra:n}){var a;let r,[l,i]=(0,o.useState)("body"),d=e.logs??[],u=e.cookies??[],p=("console"!==l||d.length)&&("cookies"!==l||u.length)&&("request"!==l||e.sent)&&("checks"!==l||(e.checks??[]).length)?l:"body",m=e.checks??[],x=m.filter(e=>e.ok).length,f=Object.keys(e.headers).length,b=(r=Object.keys(a=e.headers).find(e=>"content-type"===e.toLowerCase()))?a[r]??"":"",v=(0,o.useMemo)(()=>new TextEncoder().encode(e.body).length,[e.body]),g=!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)}`,children:g?"Error":`${e.status} ${k[e.status]??""}`.trim()}),(0,t.jsx)(C,{label:"Time",value:`${e.durationMs} ms`}),g?null:(0,t.jsx)(C,{label:"Size",value:`${(0,w.formatBytes)(v)}${e.truncated?"+":""}`}),b?(0,t.jsx)(C,{label:"Type",value:b.split(";")[0]??b}):null,m.length?(0,t.jsxs)("button",{type:"button",onClick:()=>i("checks"),className:`rounded-md border px-2 py-0.5 text-xs ${x===m.length?"border-ok/40 text-ok":"border-bad/40 text-bad"}`,children:[x===m.length?"✓":"✕"," ",x,"/",m.length," checks"]}):null,n?(0,t.jsx)("span",{className:s&&!g?"":"ml-auto",children:n}):null,s&&!g?(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)(S,{message:e.error}):null,g&&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)(h.SentRequestView,{sent:e.sent})})]}):null,g?null:(0,t.jsxs)("div",{className:"mt-3 flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)(c.Tabs,{id:"response",label:"Response",value:p,onChange:i,items:[{id:"body",label:"Body"},{id:"headers",label:"Headers",badge:f||void 0},...u.length?[{id:"cookies",label:"Cookies",badge:u.length}]:[],...m.length?[{id:"checks",label:"Checks",badge:(0,t.jsxs)("span",{className:x===m.length?"text-ok":"text-bad",children:[x,"/",m.length]})}]:[],...e.sent?[{id:"request",label:"Request sent"}]:[],...d.length?[{id:"console",label:"Console",badge:d.length}]:[]]}),(0,t.jsx)("div",{...(0,c.tabPanelProps)("response",p),className:"flex min-h-0 flex-1 flex-col pt-3",children:"body"===p?e.streamId?(0,t.jsx)(j,{id:e.streamId}):(0,t.jsx)(q,{body:e.body,contentType:b,truncated:e.truncated,url:e.url,base64:e.bodyBase64}):"cookies"===p?(0,t.jsx)(h.ResponseCookiesView,{cookies:u}):"console"===p?(0,t.jsx)($,{logs:d}):"request"===p&&e.sent?(0,t.jsx)(h.SentRequestView,{sent:e.sent}):"checks"===p?(0,t.jsx)("ul",{className:"space-y-1.5",children:m.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)(T,{headers:e.headers})})]})]})},"statusTone",0,N],60566),e.i(24856);var H=e.i(99112),L=e.i(78451),A=e.i(36620),P=e.i(73436),D=e.i(99522);let z=(0,D.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 F=e.i(71189),U=e.i(43514),B=e.i(96659),O=e.i(87283),I=e.i(39170),V=e.i(80707);e.i(42674);var W=e.i(5305),_=e.i(65238),J=e.i(6278);let K=()=>globalThis.crypto?.randomUUID?.()??`env-${Date.now().toString(36)}`;function G({onClose:e}){let s=(0,u.useToast)(),n=(0,I.useConfirm)(),{environments:r,activeEnv:l,setActiveEnv:i,saveEnvironments:d,index:c}=(0,J.useWorkspace)(),[p,h]=(0,o.useState)(()=>structuredClone(r)),[m,x]=(0,o.useState)(l?.id??r[0]?.id??null),[f,b]=(0,o.useState)(!1),v=(0,o.useRef)(null),g=p.find(e=>e.id===m)??null,y=JSON.stringify(p)!==JSON.stringify(r);(0,o.useEffect)(()=>{let e=document.activeElement;return v.current?.querySelector("input,button")?.focus(),()=>e?.focus()},[]);let j=(e,t)=>h(s=>s.map(s=>s.id===e?{...s,...t}:s));function w(e){let t=e?{id:K(),name:`${e.name} copy`,variables:structuredClone(e.variables)}:{id:K(),name:p.length?`Environment ${p.length+1}`:"DEV",variables:[{key:"baseUrl",value:"",secret:!1}]};h(e=>[...e,t]),x(t.id)}async function k(){(!y||await n({title:"Discard changes to environments?",confirmLabel:"Discard",tone:"danger"}))&&e()}async function N(){b(!0);try{await d(p),l&&!p.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{b(!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 k(),children:(0,t.jsxs)("div",{ref:v,role:"dialog","aria-modal":"true","aria-label":"Environments",onKeyDown:e=>"Escape"===e.key&&void k(),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 k(),children:(0,t.jsx)(O.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:[p.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>x(e.id),"aria-current":e.id===m?"true":void 0,className:`block w-full truncate rounded-md px-2 py-1.5 text-left text-sm ${e.id===m?"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:()=>w(),className:"mt-2 inline-flex items-center gap-1 text-xs text-accent hover:underline",children:[(0,t.jsx)(F.Plus,{size:12,"aria-hidden":!0})," New environment"]})]}),(0,t.jsxs)("section",{className:"min-h-0 space-y-4 overflow-auto p-4",children:[g?(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:g.name,onChange:e=>j(g.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:()=>w(g),children:[(0,t.jsx)(a.Copy,{size:13})," Duplicate"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-danger py-1.5 text-xs",onClick:()=>{h(e=>e.filter(e=>e.id!==g.id)),x(p.find(e=>e.id!==g.id)?.id??null)},children:[(0,t.jsx)(B.Trash2,{size:13})," Delete"]})]}),(0,t.jsx)(Z,{vars:g.variables,onPatch:(e,t)=>g&&j(g.id,{variables:g.variables.map((s,n)=>n===e?{...s,...t}:s)}),onChange:e=>j(g.id,{variables:e})}),(0,t.jsxs)("p",{className:"flex items-start gap-1.5 text-xs text-mute",children:[(0,t.jsx)(z,{size:12,className:"mt-0.5 shrink-0","aria-hidden":!0}),c?.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:()=>w(),children:[(0,t.jsx)(F.Plus,{size:14})," New environment"]})})]}),(0,t.jsx)(X,{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 k(),children:"Cancel"}),(0,t.jsx)("button",{type:"button",className:"btn btn-primary text-sm",disabled:!y||f,onClick:()=>void N(),children:"Save environments"})]})]})})}function X({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:H.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)(a.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 Z({vars:e,onPatch:s,onChange:n}){let[a,r]=(0,o.useState)(new Set),l=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((i,o)=>{let d=i.key&&!/^[A-Za-z_][\w.-]*$/.test(i.key)||l.has(i.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 ${o+1} name`,"aria-invalid":d||void 0,title:d?"Letters, digits, _ . - ; must start with a letter or _ ; must be unique":void 0,value:i.key,onChange:e=>s(o,{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 ${d?"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 ${o+1} value`,type:i.secret&&!a.has(o)?"password":"text",autoComplete:"off",value:i.value,onChange:e=>s(o,{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"}),i.secret?(0,t.jsx)("button",{type:"button","aria-label":a.has(o)?"Hide value":"Show value",onClick:()=>r(e=>{let t=new Set(e);return t.has(o)?t.delete(o):t.add(o),t}),className:"px-2 text-mute hover:text-ink",children:a.has(o)?(0,t.jsx)(P.EyeOff,{size:13}):(0,t.jsx)(A.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:i.secret,onChange:e=>s(o,{secret:e.target.checked}),className:"accent-[var(--accent)]"}),"secret"]}),(0,t.jsx)("button",{type:"button","aria-label":`Remove ${i.key||`variable ${o+1}`}`,onClick:()=>n(e.filter((e,t)=>t!==o)),className:"grid place-items-center text-mute hover:text-bad",children:(0,t.jsx)(O.X,{size:13})})]},o)}),(0,t.jsxs)("button",{type:"button",onClick:()=>n([...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)(F.Plus,{size:12,"aria-hidden":!0})," Add variable"]})]})}e.s(["EnvironmentBar",0,function({drafts:e,collections:s=[]}){let{environments:n,activeEnv:a,setActiveEnv:r,vars:l,savedValues:i,clearSavedValues:d}=(0,J.useWorkspace)(),c=Object.keys(i),[u,p]=(0,o.useState)(!1),h=(0,o.useMemo)(()=>{let t=new Set;for(let s of e){let e=new Set((0,W.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,L.findVariables)(n).forEach(s=>!e.has(s)&&t.add(s))}return[...t]},[e]),m=(0,_.useFolderVarNames)(s),x=h.filter(e=>!(e in l)&&!m.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)(V.Select,{label:"Environment",value:a?.id??"",onChange:e=>r(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)(U.Settings2,{size:12,"aria-hidden":!0})," Manage"]}),h.length>0?x.length?(0,t.jsxs)("span",{className:"text-warn",role:"status",children:[x.map(e=>`{{${e}}}`).join(", ")," not defined",a?` in ${a.name}`:" — pick an environment"]}):(0,t.jsxs)("span",{className:"text-mute",children:["Uses ",h.map(e=>`{{${e}}}`).join(", ")]}):null,c.length?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-mute",title:c.map(e=>`{{${e}}} — saved from “${i[e].from}”`).join("\n"),children:["Saved from answers: ",(0,t.jsx)("span",{className:"font-mono text-accent",children:c.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,u?(0,t.jsx)(G,{onClose:()=>p(!1)}):null]})},"VariableTable",0,Z],68228);var Q=e.i(60961);let Y=(0,D.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"}]]),ee=(0,D.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"}]]),et=(0,D.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"}]]),es=(0,D.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 en=e.i(19286),ea=e.i(81538),er=e.i(3792),el=e.i(50804),ei=e.i(67217),eo=e.i(74749),ed=e.i(41997),ec=e.i(37837),eu=e.i(27813),ep=e.i(36e3),eh=e.i(55925);function em({path:e,onClose:s}){let n=(0,u.useToast)(),{refresh:a}=(0,J.useWorkspace)(),[r,l]=(0,o.useState)(null),[i,d]=(0,o.useState)([]),[p,h]=(0,o.useState)([]),[m,x]=(0,o.useState)("auth"),[f,b]=(0,o.useState)(!1);async function v(){if(r&&!f){b(!0);try{await _.folderApi.save(e,{...r,headers:r.headers.filter(e=>e.key.trim()),variables:r.variables.filter(e=>e.key.trim())}),await a(),n(`Saved the settings of ${e}`,"success"),s()}catch(e){n(e instanceof Error?e.message:"Could not save","error")}finally{b(!1)}}}(0,o.useEffect)(()=>{let t=!0;return Promise.all([_.folderApi.get(e),_.folderApi.chain((0,L.parentFolder)(e))]).then(([e,s])=>{t&&(l(e.settings),d(e.secretsMissing??[]),h(s))}).catch(e=>{t&&(n(e instanceof Error?e.message:"Could not open the folder","error"),l((0,L.emptyFolderSettings)()))}),()=>{t=!1}},[e,n]);let g=[...p].reverse().find(e=>"inherit"!==e.settings.auth.authMode),y=r?{headers:r.headers.filter(e=>e.key.trim()).length,variables:r.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)(O.X,{size:16})})]}),r?(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[(0,t.jsx)(c.Tabs,{id:"folder-settings",label:"Folder settings",value:m,onChange:x,items:[{id:"auth",label:"Auth"},{id:"headers",label:"Headers",badge:y.headers||void 0},{id:"variables",label:"Variables",badge:y.variables||void 0},{id:"scripts",label:"Scripts",badge:+!!r.preScript.trim()+ +!!r.postScript.trim()||void 0}]}),(0,t.jsxs)("div",{...(0,c.tabPanelProps)("folder-settings",m),className:"pt-4",children:["auth"===m?(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)(ed.AuthFields,{value:r.auth,onChange:e=>l({...r,auth:{...r.auth,...e}}),inheritLabel:"From parent",defaults:Object.fromEntries([...p.flatMap(e=>e.settings.variables),...r.variables].map(e=>[e.key,e.value])),inheritNote:g&&"none"!==g.settings.auth.authMode?(0,t.jsxs)(t.Fragment,{children:["Passes on the ",(0,t.jsx)("span",{className:"text-ink",children:(0,ed.authModeLabel)(g.settings.auth.authMode)})," of"," ",(0,t.jsx)("span",{className:"text-ink",children:g.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."}),i.some(e=>!e.startsWith("var:"))?(0,t.jsxs)("p",{className:"text-xs text-warn",children:["The saved ",i.filter(e=>!e.startsWith("var:")).join(", ")," isn't available on this computer — enter it again."]}):null]}):null,"headers"===m?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ep.KeyValueEditor,{rows:r.headers,onChange:e=>l({...r,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,"scripts"===m?(0,t.jsx)(eh.ScriptsPanel,{draft:r,onChange:l,forFolder:!0}):null,"variables"===m?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Z,{vars:r.variables,onPatch:(e,t)=>l({...r,variables:r.variables.map((s,n)=>n===e?{...s,...t}:s)}),onChange:e=>l({...r,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."]}),i.some(e=>e.startsWith("var:"))?(0,t.jsxs)("p",{className:"text-xs text-warn",children:["Secret values not available on this computer: ",i.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)(eu.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:f,children:"Cancel"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",onClick:()=>void v(),disabled:!r||f,children:[f?(0,t.jsx)(eu.Loader2,{size:14,className:"animate-spin"}):null,"Save folder settings"]})]})]})})}var ex=e.i(14168);let ef={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad"};function eb({activeId:e,onOpen:n,allowDelete:a=!0,newFolder:r,onNewFolderDone:i}){let d=(0,u.useToast)(),c=(0,I.useConfirm)(),{index:p,refresh:h}=(0,J.useWorkspace)(),[m,x]=(0,o.useState)(""),[f,b]=(0,o.useState)(new Set),[v,g]=(0,o.useState)(null),[y,j]=(0,o.useState)(null),w=p?.requests??[],k=p?.folders??[],N=m.trim().toLowerCase(),$=(0,o.useMemo)(()=>N?w.filter(e=>`${e.name} ${e.collection} ${e.url} ${e.method}`.toLowerCase().includes(N)):w,[w,N]),C=(0,o.useMemo)(()=>(function(e,t,s){let n={path:"",name:"",folders:[],requests:[],summary:null},a=new Map([["",n]]),r=e=>{let t=a.get(e);if(t)return t;let s={path:e,name:(0,L.folderName)(e),folders:[],requests:[],summary:null};return a.set(e,s),r((0,L.parentFolder)(e)).folders.push(s),s};if(s)for(let e of t)r(e.path);for(let t of e)r(t.collection).requests.push(t);for(let e of t){let t=a.get(e.path);t&&(t.summary=e)}let l=e=>{e.folders.sort((e,t)=>e.name.localeCompare(t.name)),e.folders.forEach(l)};return l(n),n})($,k,!N),[$,k,N]);async function S(e){try{let t=await J.workspaceApi.get(e);n(t),t.secretsMissing?.length&&d(`Re-enter the ${t.secretsMissing.join(", ")} — secrets are kept only until the engine restarts in this setup`,"info")}catch(e){d(e instanceof Error?e.message:"Could not open the request","error")}}async function T(e){await c({title:`Delete “${e.name}”?`,body:"The saved request file is removed. Load test history is not affected.",confirmLabel:"Delete",tone:"danger"})&&(await J.workspaceApi.remove(e.id).catch(()=>void 0),await h())}async function q(e){if(g(null),i?.(),!v)return;let t=e.trim();if(t)try{if("new"===v.kind){let e=(0,L.folderPath)(v.parent?`${v.parent}/${t}`:t);await _.folderApi.save(e,(0,L.emptyFolderSettings)()),b(e=>{let t=new Set(e);return t.delete(v.parent),t})}else{let e=(0,L.folderPath)(t.includes("/")?t:(0,L.parentFolder)(v.path)?`${(0,L.parentFolder)(v.path)}/${t}`:t);e!==v.path&&await _.folderApi.move(v.path,e)}await h()}catch(e){d(e instanceof Error?e.message:"Could not do that","error")}}async function R(e){if(await c({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 _.folderApi.remove(e),await h()}catch(e){d(e instanceof Error?e.message:"Could not delete the folder","error")}}(0,o.useEffect)(()=>{r&&g({kind:"new",parent:""})},[r]);let M=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 S(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 ${ef[s.method]??"text-mute"}`,children:s.method}),(0,t.jsx)("span",{className:"min-w-0 truncate text-xs text-ink",children:s.name})]}),a?(0,t.jsx)("button",{type:"button","aria-label":`Delete ${s.name}`,onClick:()=>void T(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)(B.Trash2,{size:12})}):null]},s.id))}),E=e=>{var n;let r=f.has(e.path)&&!N,l=(n=e.summary)?[n.auth?(0,ed.authModeLabel)(n.auth):"",n.headers?`${n.headers} header${1===n.headers?"":"s"}`:"",n.variables?`${n.variables} variable${1===n.variables?"":"s"}`:""].filter(Boolean).join(" · "):"";return(0,t.jsxs)("div",{className:"mb-0.5",children:[v?.kind==="rename"&&v.path===e.path?(0,t.jsx)(ev,{initial:e.path,label:`New name for ${e.path}`,onDone:e=>void q(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":!r,onClick:()=>{let t;return t=e.path,b(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},title:l?`Passes down: ${l}`: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:[r?(0,t.jsx)(Q.ChevronRight,{size:12,"aria-hidden":!0,className:"shrink-0"}):(0,t.jsx)(s.ChevronDown,{size:12,"aria-hidden":!0,className:"shrink-0"}),(0,t.jsx)(ee,{size:12,"aria-hidden":!0,className:"shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.name}),e.summary?.auth?(0,t.jsx)(en.KeyRound,{size:11,className:"shrink-0 text-accent","aria-label":`signs in with ${(0,ed.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)})]}),a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(el.default,{href:(0,ex.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)(er.Play,{size:12})}),(0,t.jsx)(eg,{path:e.path,onSettings:()=>j(e.path),onNewInside:()=>g({kind:"new",parent:e.path}),onRename:()=>g({kind:"rename",path:e.path}),onDelete:()=>void R(e.path)})]}):null]}),r?null:(0,t.jsxs)("div",{className:"ml-3 border-l border-line/60 pl-1",children:[v?.kind==="new"&&v.parent===e.path?(0,t.jsx)(ev,{initial:"",label:`New folder in ${e.path}`,onDone:e=>void q(e)}):null,e.folders.map(E),M(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:m,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:[v?.kind==="new"&&""===v.parent?(0,t.jsx)(ev,{initial:"",label:"New folder",onDone:e=>void q(e),hint:"Use / for a folder inside another: Orders/Admin"}):null,0===w.length&&0===k.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:ei.openImport,className:"text-accent hover:underline",children:"Import your requests"})]})]}):N&&0===$.length?(0,t.jsx)("p",{className:"px-1 py-4 text-xs text-mute",children:"Nothing matches."}):(0,t.jsxs)(t.Fragment,{children:[C.folders.map(E),M(C.requests)]})]}),y?(0,t.jsx)(em,{path:y,onClose:()=>j(null)}):null]})}function ev({initial:e,label:s,onDone:n,hint:a}){let[r,l]=(0,o.useState)(e),i=(0,o.useRef)(null),d=(0,o.useRef)(!1);(0,o.useEffect)(()=>i.current?.select(),[]);let c=e=>{d.current||(d.current=!0,n(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&&c(r),"Escape"===e.key&&c("")},onBlur:()=>c(r),className:"input py-1 text-xs"}),a?(0,t.jsx)("p",{className:"mt-0.5 text-[11px] text-mute",children:a}):null]})}function eg({path:e,onSettings:s,onNewInside:n,onRename:a,onDelete:r}){let[l,i]=(0,o.useState)(!1),d=(0,o.useRef)(null),c=(e,s,n=!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 ${n?"text-bad":"text-ink"}`,children:e});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{ref:d,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)(ea.MoreHorizontal,{size:13})}),(0,t.jsx)(ec.Popover,{anchor:d,open:l,onClose:()=>i(!1),label:`Actions for ${e}`,width:220,role:"menu",children:(0,t.jsxs)("div",{className:"p-1",children:[c("Folder settings — auth, headers, variables",s),c("New folder inside",n),c("Mock server for this folder",()=>(0,eo.openMock)(e)),c("Rename or move",a),c("Delete folder",r,!0)]})})]})}async function ey(e,t,s,n){let a,r,l=t.before;if(!l)return e;try{a=await J.workspaceApi.get(l.requestId)}catch{throw Error(`Run first: “${l.requestName}” is no longer saved — pick another request on the Run first tab`)}if(a.secretsMissing?.length)throw Error(`Run first: the saved ${a.secretsMissing.join(", ")} of “${a.name}” is not available — open it and enter it again`);try{let e=await (0,_.withFolders)({...(0,W.requestFromUnknown)(a.request),before:null,testData:null},a.collection,s);r=(0,W.resolveDraft)(e.draft,e.vars,n)}catch(e){throw Error(`Run first “${a.name}”: ${e instanceof Error?e.message:"invalid request"}`)}try{return{...e,setup:(0,W.buildSetup)({...l,requestName:a.name},r)}}catch(e){throw Error(e instanceof Error&&e.message.startsWith("Run first")?e.message:`Run first “${a.name}”: ${e instanceof Error?e.message:"invalid request"}`)}}e.s(["RequestPicker",0,function({onOpen:e}){let[s,n]=(0,o.useState)(!1),a=(0,o.useRef)(null);return(0,o.useEffect)(()=>{if(!s)return;let e=e=>!a.current?.contains(e.target)&&n(!1),t=e=>"Escape"===e.key&&n(!1);return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[s]),(0,t.jsxs)("div",{ref:a,className:"relative",children:[(0,t.jsxs)("button",{type:"button","aria-expanded":s,onClick:()=>n(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)(ee,{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)(eb,{allowDelete:!1,onOpen:t=>{e(t),n(!1)}})}):null]})},"RequestsPanel",0,function({activeId:e,onOpen:s,onNew:n,onClose:a}){let[r,l]=(0,o.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:n,title:"New request","aria-label":"New request",className:"rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(Y,{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)(et,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:ei.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)(es,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:a,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)(O.X,{size:14})})]})]}),(0,t.jsx)(eb,{activeId:e,onOpen:s,newFolder:r,onNewFolderDone:()=>l(!1)})]})},"SaveRequestForm",0,function({initial:e,onSave:s,onCancel:n}){let{index:a}=(0,J.useWorkspace)(),[r,l]=(0,o.useState)(e.name),[i,d]=(0,o.useState)(e.collection),c=(0,o.useRef)(null),u=[...new Set([...(a?.folders??[]).map(e=>e.path),...(a?.requests??[]).map(e=>e.collection)].filter(Boolean))].sort();return(0,o.useEffect)(()=>c.current?.select(),[]),(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),r.trim()&&s(r.trim(),i.trim())},onKeyDown:e=>"Escape"===e.key&&n(),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:c,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=>d(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:u.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:n,children:(0,t.jsx)(O.X,{size:14})})]})}],65638),e.s(["withRunFirst",0,ey],46679)},10281,e=>{"use strict";let t=(0,e.i(99522).default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);e.s(["Unplug",0,t],10281)}]);
@@ -0,0 +1,119 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,93639,e=>{"use strict";var t=e.i(61666);e.i(24856);var s=e.i(78451);function a(e){let t=t=>e.filter(e=>e.state===t).length;return{total:e.length,passed:t("passed"),failed:t("failed"),errors:t("error"),skipped:t("skipped"),durationMs:Math.round(e.reduce((e,t)=>e+(t.durationMs??0),0))}}function n(e){let t=a(e.steps);return t.passed>0&&0===t.failed&&0===t.errors}function r(e){let t=a(e.steps),s=t.total-t.skipped;if("running"===e.status)return`Running ${t.passed+t.failed+t.errors+1} of ${s}…`;if(!s)return"Nothing ran";let n=[`${t.passed} of ${s} passed`];return t.failed&&n.push(`${t.failed} failed`),t.errors&&n.push(`${t.errors} could not run`),t.skipped&&n.push(`${t.skipped} skipped`),"stopped"===e.status&&n.push("stopped early"),n.join(" · ")}let i=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),l=e=>((e??0)/1e3).toFixed(3),o=e=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),d={passed:"Passed",failed:"Failed",error:"Could not run",skipped:"Skipped",pending:"Not run",running:"Not finished"};var c=e.i(53012),u=e.i(99522);let p=(0,u.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),m=(0,u.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);var h=e.i(17118),x=e.i(95486),f=e.i(60961);let b=(0,u.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var g=e.i(75117);let v=(0,u.default)("file-archive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);var k=e.i(29091),y=e.i(27813);let $=(0,u.default)("circle-minus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);var w=e.i(3792),j=e.i(66478),N=e.i(27122),S=e.i(46443),C=e.i(83067),z=e.i(69578),q=e.i(80707),M=e.i(56396);function P({collection:e,environment:t,data:s="api-tests"}){let a=t?` --env ${JSON.stringify(t)}`:"";return`npx --yes apitestcenter suite ${JSON.stringify(e)} --data ${s}${a} --junit atc-results.xml`}var A=e.i(17219);async function R(e,t){var s;let a,n=await fetch(`/engine/suites/export?collection=${encodeURIComponent(e)}`,{cache:"no-store"}),r=await n.json().catch(()=>null);if(!n.ok||!r?.files)throw Error(r?.error??`Engine error (${n.status})`);let i=r.secrets??[],l={};for(let e of r.files)l[`api-tests/${e.path}`]=e.text;l["api-tests/README.md"]=function(e){let{collection:t,environment:s,secrets:a=[],data:n="api-tests"}=e,r=s?` --env ${JSON.stringify(s)}`:"";return`# API checks — ${t||"requests outside a collection"}
2
+
3
+ Every request in this collection is sent once, in the saved order, and checked. The run fails
4
+ (exit code 1) when any request fails.
5
+
6
+ ${P(e)}
7
+
8
+ - Nothing to install first: \`npx\` fetches the command line (Node.js 20 or later).
9
+ - Edit these tests in a window: \`npx apitestcenter ui --data ${n}\` (or the desktop app).
10
+ - \`${n}/requests\` holds the saved requests, \`environments.json\` the environments, and
11
+ \`suites.json\` the run order. Secret values are never in these files.
12
+ - Pass secrets from your CI's secret store: write \`{{token}}\` in the request, then add
13
+ \`--var token=$MY_TOKEN\` to the command.
14
+ ${a.length?`
15
+ **These requests have a secret typed straight into them, which is not exported** — change it to a
16
+ {{variable}} and pass it with --var, or they will not run here:
17
+
18
+ ${a.map(e=>`- ${e}`).join("\n")}
19
+ `:""}
20
+ To check speed too, load-test one request with goals, and compare with a baseline:
21
+
22
+ npx --yes apitestcenter run "${t?`${t}/`:""}<request name>" --data ${n}${r} --p95 500 --errors 1 --baseline ${n}/baseline.json --max-slower 10
23
+
24
+ Guide: https://apitestcenter.com/docs/ci-walkthrough.html
25
+ `}({collection:e,environment:t,secrets:i}),l[".github/workflows/api-checks.yml"]=(a=(s={collection:e,environment:t}).collection||"requests outside a collection",`# Runs the "${a}" API checks on every push. Made by APITestCenter.
26
+ # Guide: https://apitestcenter.com/docs/ci-walkthrough.html
27
+ name: API checks
28
+
29
+ on:
30
+ push:
31
+ workflow_dispatch:
32
+
33
+ jobs:
34
+ api-checks:
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+
39
+ - uses: actions/setup-node@v4
40
+ with:
41
+ node-version: 22
42
+
43
+ # Fails the job when any request fails. Secrets: add --var name=\${{ secrets.NAME }}
44
+ - name: Check every request
45
+ run: ${P(s)}
46
+
47
+ - name: Keep the results
48
+ if: always()
49
+ uses: actions/upload-artifact@v4
50
+ with:
51
+ name: api-check-results
52
+ path: atc-results.xml
53
+ `);let o=(e||"requests").replace(/[^\w.-]+/g,"-").replace(/^-|-$/g,"")||"requests";return{blob:(0,A.zipStore)(l),name:`${o}-for-ci.zip`,secrets:i}}var T=e.i(15060),E=e.i(14168),I=e.i(6278),U=e.i(15868);let O={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad"},L="apitestcenter-suite-stop-on-fail";function F({state:e}){return"passed"===e?(0,t.jsx)(h.CheckCircle2,{size:16,className:"text-ok","aria-label":"Passed"}):"failed"===e?(0,t.jsx)(N.XCircle,{size:16,className:"text-bad","aria-label":"Failed"}):"error"===e?(0,t.jsx)(c.AlertTriangle,{size:16,className:"text-bad","aria-label":"Could not run"}):"skipped"===e?(0,t.jsx)($,{size:16,className:"text-mute","aria-label":"Skipped"}):"running"===e?(0,t.jsx)(y.Loader2,{size:16,className:"animate-spin text-accent","aria-label":"Running"}):(0,t.jsx)(b,{size:16,className:"text-line","aria-label":"Not run yet"})}let D=e=>`${(e.collection||"requests").replace(/[^\w.-]+/g,"-")}-${e.startedAt.slice(0,16).replace(/[:T]/g,"-")}`;e.s(["SuitePage",0,function(){let e=(0,S.useRouter)(),c=(0,S.useSearchParams)(),u=(0,M.useToast)(),{index:b,environments:$,activeEnv:P,setActiveEnv:A}=(0,I.useWorkspace)(),B=(0,C.useMemo)(()=>b?.requests??[],[b]),J=(0,C.useMemo)(()=>[...new Set(B.flatMap(e=>e.collection?(0,s.folderChain)(e.collection):[""]))].sort((e,t)=>""===e?1:""===t?-1:e.localeCompare(t)),[B]),H=(0,C.useCallback)(e=>B.filter(t=>e?(0,s.inFolder)(t.collection,e):""===t.collection),[B]),G=c.get("c"),K=null!==G&&J.includes(G)?G:J[0]??null,V=(0,C.useMemo)(()=>null===K?[]:H(K),[H,K]),[_,W]=(0,C.useState)(null),[X,Y]=(0,C.useState)(null),[Q,Z]=(0,C.useState)(!1),[ee,et]=(0,C.useState)(new Set),[es,ea]=(0,C.useState)(!1),[en,er]=(0,C.useState)(!1),ei=(0,C.useRef)(null);(0,C.useEffect)(()=>{try{Z("1"===localStorage.getItem(L))}catch{}},[]),(0,C.useEffect)(()=>{if(null===K)return;W(null),Y(null),et(new Set);let e=!0;return E.suiteApi.plan(K).then(t=>e&&W(t)).catch(()=>e&&W({order:[],skip:[]})),()=>{e=!1}},[K]),(0,C.useEffect)(()=>()=>void(ei.current&&window.clearInterval(ei.current)),[]);let el=(0,C.useMemo)(()=>(function(e,t){let s=new Map(e.map(e=>[e.id,e])),a=new Set,n=[];for(let e of t?.order??[]){let t=s.get(e);t&&!a.has(e)&&(n.push(t),a.add(e))}for(let t of e)a.has(t.id)||n.push(t);let r=new Set(t?.skip??[]);return n.map(e=>({item:e,skipped:r.has(e.id)}))})(V,_),[V,_]),eo=X?.status==="running";(0,C.useMemo)(()=>new Map((X?.steps??[]).map(e=>[e.id,e])),[X]);let ed=X?X.steps.flatMap(e=>{let t=V.find(t=>t.id===e.id);return t?[{item:t,skipped:"skipped"===e.state&&!!e.message?.startsWith("Left out"),step:e}]:[]}):el,ec=(0,C.useCallback)(e=>{null!==K&&(W(e),E.suiteApi.savePlan(K,e).catch(e=>u(e instanceof Error?e.message:"Could not save the order","error")))},[K,u]);function eu(e,t){let s=el.map(e=>e.item.id),a=s.indexOf(e),n=a+t;a<0||n<0||n>=s.length||([s[a],s[n]]=[s[n],s[a]],Y(null),ec({order:s,skip:_?.skip??[]}))}async function ep(){if(null!==K&&!es){ea(!0),et(new Set);try{let e=await E.suiteApi.start({collection:K,environmentId:P?.id??null,stopOnFail:Q});Y(e),ei.current&&window.clearInterval(ei.current),ei.current=window.setInterval(async()=>{try{let t=await E.suiteApi.get(e.id);Y(t),"running"!==t.status&&(window.clearInterval(ei.current),ei.current=null,et(new Set(t.steps.filter(e=>"failed"===e.state||"error"===e.state).map(e=>e.id))))}catch{}},400)}catch(e){u(e instanceof Error?e.message:"Could not start the run","error")}finally{ea(!1)}}}async function em(){if(null!==K){er(!0);try{let{blob:e,name:t,secrets:s}=await R(K,P?.name??null);(0,T.downloadBlob)(t,e),u(s.length?`Saved ${t}. ${s.length} request${1===s.length?" has":"s have"} a secret typed in — switch to a {{variable}} for CI (see README in the zip).`:`Saved ${t} — unzip it into your repository. No secrets are in it.`,s.length?"info":"success")}catch(e){u(e instanceof Error?e.message:"Could not export","error")}finally{er(!1)}}}async function eh(){X&&await E.suiteApi.stop(X.id).catch(()=>void 0)}let ex=X?a(X.steps):null,ef=X&&"running"!==X.status,eb=el.filter(e=>!e.skipped).length;return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-line bg-panel px-4 py-3 lg:px-6",children:(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h1",{className:"text-lg font-medium text-ink",children:"Run a collection"}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Sends every request once, in order, and checks each one. Passes when all its checks pass, or on any 2xx/3xx when it has none."})]})}),0===J.length?(0,t.jsx)("div",{className:"m-6 max-w-xl space-y-2 text-sm text-mute",children:(0,t.jsx)("p",{children:"No saved requests yet. Save requests into a collection on the Test API page (Ctrl+S), or import a Postman collection, then come back here to run them all."})}):(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4 lg:px-6",children:(0,t.jsxs)("div",{className:"mx-auto max-w-5xl space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["Collection",(0,t.jsx)(q.Select,{label:"Collection",value:K??"",disabled:eo,onChange:t=>e.replace((0,E.suiteHref)(t)),minWidth:240,buttonContent:null===K?"":`${K||"No collection"} (${V.length})`,options:J.map(e=>({value:e,label:(0,t.jsx)("span",{style:{paddingLeft:`${.9*Math.max(0,(0,s.folderChain)(e).length-1)}rem`},children:e?(0,s.folderName)(e):"No collection"}),hint:`${H(e).length} request${1===H(e).length?"":"s"}${e.includes("/")?` \xb7 ${e}`:""}`,text:e||"no collection"})),className:"min-w-48 rounded-md border border-line bg-panel-2 px-2 py-1.5 text-sm text-ink"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["Environment",(0,t.jsxs)("select",{value:P?.id??"",disabled:eo,onChange:e=>A(e.target.value||null),className:"min-w-40 rounded-md border border-line bg-panel-2 px-2 py-1.5 text-sm text-ink",children:[(0,t.jsx)("option",{value:"",children:"None"}),$.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 pb-1.5 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:Q,disabled:eo,onChange:e=>{Z(e.target.checked);try{localStorage.setItem(L,e.target.checked?"1":"0")}catch{}}}),"Stop at the first failure"]}),(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary",disabled:en||null===K,onClick:()=>void em(),title:"A zip for your repository: this collection's requests, environments and run order (never secrets), plus a ready GitHub Actions pipeline",children:[en?(0,t.jsx)(y.Loader2,{size:14,className:"animate-spin"}):(0,t.jsx)(v,{size:14}),"Download for CI"]}),eo?(0,t.jsxs)("button",{type:"button",className:"btn btn-danger",onClick:()=>void eh(),children:[(0,t.jsx)(j.Square,{size:14})," Stop"]}):(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",disabled:!_||0===eb||es,onClick:()=>void ep(),children:[es?(0,t.jsx)(y.Loader2,{size:14,className:"animate-spin"}):(0,t.jsx)(w.Play,{size:14}),"Run ",eb," request",1===eb?"":"s"]})]})]}),X?(0,t.jsxs)("div",{role:"status",className:`flex flex-wrap items-center gap-x-4 gap-y-2 rounded-lg border px-4 py-3 ${eo?"border-line bg-panel":n(X)?"border-ok/40 bg-ok/10":"border-bad/40 bg-bad/10"}`,children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 font-medium text-ink",children:[eo?(0,t.jsx)(y.Loader2,{size:16,className:"animate-spin text-accent"}):n(X)?(0,t.jsx)(h.CheckCircle2,{size:16,className:"text-ok"}):(0,t.jsx)(N.XCircle,{size:16,className:"text-bad"}),eo?"Running…":n(X)?"All requests passed":"Not all requests passed"]}),(0,t.jsx)("span",{className:"text-sm text-mute",children:r(X)}),ex&&ef?(0,t.jsxs)("span",{className:"text-sm text-mute",children:["· ",(ex.durationMs/1e3).toFixed(1)," s of response time"]}):null,ef?(0,t.jsxs)("span",{className:"ml-auto flex flex-wrap items-center gap-1",children:[(0,t.jsx)("span",{className:"mr-1 text-xs text-mute",children:"Save as"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>(0,T.downloadText)(`${D(X)}.html`,function(e,t={}){let s=a(e.steps),i=n(e),l=e.collection||"Saved requests",c=e=>"passed"===e?"ok":"failed"===e||"error"===e?"bad":"mute",u=e.steps.map((e,t)=>{let s=e.checks?.length?`<ul class="checks">${e.checks.map(e=>`<li class="${e.ok?"ok":"bad"}">${e.ok?"✓":"✕"} ${o(e.name)}</li>`).join("")}</ul>`:"",a=e.bodyPreview?`<details><summary>Response body</summary><pre>${o(e.bodyPreview)}</pre></details>`:"",n=e.runFirst?`<div class="sub">Run first: ${o(e.runFirst.label)}${e.runFirst.reused?" (reused)":""}</div>`:"",r=e.saved?.length?`<div class="sub">${e.saved.map(e=>e.found?`Saved {{${o(e.name)}}} = ${o(e.preview??"")}`:`✕ {{${o(e.name)}}} not found`).join(" · ")}</div>`:"";return`<tr>
54
+ <td class="n">${t+1}</td>
55
+ <td><span class="state ${c(e.state)}">${d[e.state]}</span></td>
56
+ <td><div><b class="m">${o(e.method)}</b> ${o(e.name)}</div><div class="sub mono">${o(e.url)}</div>${n}${r}${e.message?`<div class="msg ${c(e.state)}">${o(e.message)}</div>`:""}${s}${a}</td>
57
+ <td class="num">${e.status??"–"}</td>
58
+ <td class="num">${null!=e.durationMs?`${Math.round(e.durationMs)} ms`:"–"}</td>
59
+ </tr>`}).join("\n");return`<!doctype html>
60
+ <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
61
+ <title>${o(l)} — collection run</title>
62
+ <style>
63
+ :root { --ink:#12151c; --mute:#5c6778; --line:#d5dce6; --panel:#fff; --canvas:#f4f6f9; --ok:#137333; --bad:#c62828; --okbg:#e6f4ea; --badbg:#fce8e6; }
64
+ * { box-sizing:border-box; }
65
+ body { margin:0; background:var(--canvas); color:var(--ink); font:14px/1.5 "Segoe UI",system-ui,-apple-system,sans-serif; }
66
+ main { max-width:1000px; margin:0 auto; padding:28px 16px 48px; }
67
+ h1 { font-size:22px; margin:0 0 4px; }
68
+ .meta { color:var(--mute); font-size:13px; margin-bottom:18px; }
69
+ .banner { border-radius:10px; padding:14px 16px; font-weight:600; margin-bottom:16px; }
70
+ .banner.ok { background:var(--okbg); color:var(--ok); } .banner.bad { background:var(--badbg); color:var(--bad); }
71
+ .tiles { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:10px; margin-bottom:18px; }
72
+ .tile { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:10px 14px; }
73
+ .tile b { display:block; font-size:24px; }
74
+ .tile span { color:var(--mute); font-size:12.5px; }
75
+ table { width:100%; border-collapse:collapse; background:var(--panel); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
76
+ th, td { text-align:left; vertical-align:top; padding:9px 10px; border-bottom:1px solid var(--line); }
77
+ th { font-size:12px; color:var(--mute); font-weight:600; background:#eef1f6; }
78
+ .n, .num { white-space:nowrap; font-variant-numeric:tabular-nums; } .num { text-align:right; }
79
+ .state { display:inline-block; font-size:12px; font-weight:600; padding:1px 8px; border-radius:999px; white-space:nowrap; }
80
+ .state.ok { background:var(--okbg); color:var(--ok); } .state.bad { background:var(--badbg); color:var(--bad); } .state.mute { background:#eef1f6; color:var(--mute); }
81
+ .m { font-family:ui-monospace,Consolas,monospace; font-size:12px; }
82
+ .sub { color:var(--mute); font-size:12.5px; } .mono { font-family:ui-monospace,Consolas,monospace; word-break:break-all; }
83
+ .msg { font-size:13px; margin-top:4px; } .msg.bad { color:var(--bad); } .msg.mute { color:var(--mute); }
84
+ .checks { list-style:none; padding:0; margin:6px 0 0; font-size:12.5px; } .checks .ok { color:var(--ok); } .checks .bad { color:var(--bad); }
85
+ details { margin-top:6px; font-size:12.5px; } summary { cursor:pointer; color:var(--mute); }
86
+ pre { white-space:pre-wrap; word-break:break-all; background:#eef1f6; padding:8px; border-radius:6px; max-height:300px; overflow:auto; }
87
+ footer { color:var(--mute); font-size:12px; margin-top:16px; }
88
+ </style></head><body><main>
89
+ <h1>${o(l)}</h1>
90
+ <div class="meta">Collection run \xb7 ${o(new Date(e.startedAt).toLocaleString("en-GB"))}${e.environment?` \xb7 environment ${o(e.environment)}`:""}</div>
91
+ <div class="banner ${i?"ok":"bad"}">${i?"✓ All requests passed":"✕ Not all requests passed"} — ${o(r(e))}</div>
92
+ <div class="tiles">
93
+ <div class="tile"><b>${s.passed}</b><span>passed</span></div>
94
+ <div class="tile"><b>${s.failed}</b><span>failed</span></div>
95
+ <div class="tile"><b>${s.errors}</b><span>could not run</span></div>
96
+ <div class="tile"><b>${s.skipped}</b><span>skipped</span></div>
97
+ <div class="tile"><b>${(s.durationMs/1e3).toFixed(1)} s</b><span>total response time</span></div>
98
+ </div>
99
+ <table>
100
+ <thead><tr><th>#</th><th>Result</th><th>Request</th><th class="num">Status</th><th class="num">Time</th></tr></thead>
101
+ <tbody>
102
+ ${u}
103
+ </tbody></table>
104
+ <footer>Made with APITestCenter \xb7 ${o(t.generatedAt??new Date().toISOString())}. A request passes when all its checks pass; without checks, on any 2xx or 3xx status.</footer>
105
+ </main></body></html>
106
+ `}(X),"text/html"),children:[(0,t.jsx)(g.Download,{size:12})," HTML"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>{let e,t,s,n;return(0,T.downloadText)(`${D(X)}.xml`,(e=a(X.steps),t=X.collection||"Saved requests",s=X.steps.map(e=>{let s=`${e.method} ${e.name}`,a=` <testcase classname="${i(t)}" name="${i(s)}" time="${l(e.durationMs)}">`;if("passed"===e.state)return`${a}</testcase>`;if("skipped"===e.state||"pending"===e.state||"running"===e.state)return`${a}
107
+ <skipped message="${i(e.message??"Not run")}"/>
108
+ </testcase>`;let n="error"===e.state?"error":"failure",r=[e.status?`Status ${e.status}`:"",...(e.checks??[]).map(e=>`${e.ok?"✓":"✕"} ${e.name}`),e.bodyPreview?`
109
+ Response:
110
+ ${e.bodyPreview}`:""].filter(Boolean).join("\n");return`${a}
111
+ <${n} message="${i(e.message??e.state)}">${i(r)}</${n}>
112
+ </testcase>`}),n=l(e.durationMs),`<?xml version="1.0" encoding="UTF-8"?>
113
+ <testsuites name="APITestCenter" tests="${e.total}" failures="${e.failed}" errors="${e.errors}" skipped="${e.skipped}" time="${n}">
114
+ <testsuite name="${i(t)}" tests="${e.total}" failures="${e.failed}" errors="${e.errors}" skipped="${e.skipped}" time="${n}" timestamp="${i(X.startedAt)}">
115
+ ${s.join("\n")}
116
+ </testsuite>
117
+ </testsuites>
118
+ `),"application/xml")},title:"JUnit XML for CI dashboards",children:[(0,t.jsx)(g.Download,{size:12})," JUnit"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>(0,T.downloadText)(`${D(X)}.json`,`${JSON.stringify({kind:"apitestcenter-suite",version:1,...X,totals:a(X.steps),passed:n(X)},null,2)}
119
+ `,"application/json"),children:[(0,t.jsx)(g.Download,{size:12})," JSON"]})]}):null]}):null,(0,t.jsxs)("section",{"aria-label":"Requests in run order",className:"overflow-hidden rounded-lg border border-line bg-panel",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b border-line px-4 py-2 text-xs text-mute",children:[(0,t.jsx)(k.ListChecks,{size:14,"aria-hidden":!0}),(0,t.jsx)("span",{children:X?"Results":"Run order — untick to leave a request out; use the arrows to reorder. Saved for next time and for the CLI."})]}),_?(0,t.jsx)("ol",{children:ed.map(({item:s,skipped:a,step:n},r)=>{let i=ee.has(s.id),l=n&&(n.message||n.checks?.length||n.bodyPreview||n.runFirst||n.saved?.length);return(0,t.jsxs)("li",{className:"border-b border-line last:border-b-0",children:[(0,t.jsxs)("div",{className:`flex items-center gap-3 px-4 py-2 ${a&&!X?"opacity-50":""}`,children:[X?(0,t.jsx)(F,{state:n?.state??"pending"}):(0,t.jsx)("input",{type:"checkbox",checked:!a,onChange:()=>{var e;let t;return e=s.id,void((t=new Set(_?.skip??[])).has(e)?t.delete(e):t.add(e),Y(null),ec({order:el.map(e=>e.item.id),skip:[...t]}))},"aria-label":`Include ${s.name}`}),(0,t.jsx)("span",{className:"w-6 shrink-0 text-right font-mono text-xs text-mute",children:r+1}),(0,t.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:()=>l?et(e=>{let t=new Set(e);return t.has(s.id)?t.delete(s.id):t.add(s.id),t}):void 0,"aria-expanded":l?i:void 0,children:[(0,t.jsx)("span",{className:`w-14 shrink-0 font-mono text-xs font-medium ${O[s.method]??"text-mute"}`,children:s.method}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block truncate text-sm text-ink",children:s.name}),(0,t.jsx)("span",{className:"block truncate font-mono text-[11px] text-mute",children:s.url})]}),l?i?(0,t.jsx)(x.ChevronDown,{size:14,className:"shrink-0 text-mute"}):(0,t.jsx)(f.ChevronRight,{size:14,className:"shrink-0 text-mute"}):null]}),n?.status?(0,t.jsx)("span",{className:`font-mono text-xs ${n.status<400?"text-ok":"text-bad"}`,children:n.status}):null,n?.durationMs!=null?(0,t.jsxs)("span",{className:"w-16 text-right font-mono text-xs text-mute",children:[Math.round(n.durationMs)," ms"]}):null,X?null:(0,t.jsxs)("span",{className:"flex items-center",children:[(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink disabled:opacity-30",disabled:0===r,onClick:()=>eu(s.id,-1),"aria-label":`Move ${s.name} up`,children:(0,t.jsx)(m,{size:14})}),(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink disabled:opacity-30",disabled:r===ed.length-1,onClick:()=>eu(s.id,1),"aria-label":`Move ${s.name} down`,children:(0,t.jsx)(p,{size:14})})]})]}),i&&n?(0,t.jsxs)("div",{className:"space-y-2 bg-panel-2 px-4 py-3 pl-[4.75rem] text-sm",children:[n.message?(0,t.jsx)("p",{className:"skipped"===n.state?"text-mute":"text-bad",children:n.message}):null,n.runFirst?(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Run first: ",n.runFirst.label,n.runFirst.reused?" (reused from an earlier request)":""]}):null,n.saved?.length?(0,t.jsx)("p",{className:"text-xs",children:n.saved.map(e=>(0,t.jsx)("span",{className:`mr-3 ${e.found?"text-ok":"text-bad"}`,children:e.found?`Saved {{${e.name}}} = ${e.preview??""}`:`✕ {{${e.name}}} not found`},e.name))}):null,n.checks?.length?(0,t.jsx)("ul",{className:"space-y-0.5 text-xs",children:n.checks.map((e,s)=>(0,t.jsxs)("li",{className:e.ok?"text-ok":"text-bad",children:[e.ok?"✓":"✕"," ",e.name,!e.ok&&e.detail?(0,t.jsxs)("span",{className:"text-mute",children:[" — ",e.detail]}):null]},s))}):null,n.bodyPreview?(0,t.jsx)("pre",{className:"max-h-48 overflow-auto rounded-md border border-line bg-canvas p-2 font-mono text-[11px] whitespace-pre-wrap text-ink",children:n.bodyPreview}):null,(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>(function(t){try{sessionStorage.setItem(z.OPEN_REQUEST_KEY,t)}catch{}(0,U.startNavProgress)(),e.push("/")})(s.id),children:"Open this request"})]}):null]},s.id)})}):(0,t.jsx)("p",{className:"px-4 py-6 text-sm text-mute",children:"Loading…"}),ef?(0,t.jsx)("div",{className:"border-t border-line px-4 py-2 text-right",children:(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>Y(null),children:"Edit the run order"})}):null]})]})})]})}],93639)},17219,15060,e=>{"use strict";let t=new Uint32Array(256).map((e,t)=>{let s=t;for(let e=0;e<8;e++)s=1&s?0xedb88320^s>>>1:s>>>1;return s>>>0});function s(e){let t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!0),t}function a(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),t}function n(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),s=0;for(let a of e)t.set(a,s),s+=a.length;return t}function r(e,t){let s=URL.createObjectURL(t),a=document.createElement("a");a.href=s,a.download=e,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s)}e.s(["zipStore",0,function(e){let r=new TextEncoder,i=[],l=[],o=0;for(let[d,c]of Object.entries(e)){let e=r.encode(d),u="string"==typeof c?r.encode(c):c,p=function(e){let s=0xffffffff;for(let a of e)s=t[(s^a)&255]^s>>>8;return(0xffffffff^s)>>>0}(u),m=n([a(0x4034b50),s(20),s(0),s(0),s(0),s(0),a(p),a(u.length),a(u.length),s(e.length),s(0),e,u]),h=n([a(0x2014b50),s(20),s(20),s(0),s(0),s(0),s(0),a(p),a(u.length),a(u.length),s(e.length),s(0),s(0),s(0),s(0),a(0),a(o),e]);i.push(m),l.push(h),o+=m.length}let d=n(l),c=n([a(0x6054b50),s(0),s(0),s(Object.keys(e).length),s(Object.keys(e).length),a(d.length),a(o),s(0)]),u=n([...i,d,c]);return new Blob([u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength)],{type:"application/zip"})}],17219),e.s(["downloadBlob",0,r,"downloadText",0,function(e,t,s){r(e,new Blob([t],{type:s}))}],15060)},3792,66478,14168,e=>{"use strict";var t=e.i(99522);let s=(0,t.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);e.s(["Play",0,s],3792);let a=(0,t.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);async function n(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error??`Engine error (${e.status})`);return t}e.s(["Square",0,a],66478);let r=(e,t,s)=>fetch(t,{method:e,headers:void 0===s?void 0:{"content-type":"application/json"},body:void 0===s?void 0:JSON.stringify(s)});e.s(["suiteApi",0,{plan:e=>fetch(`/engine/suites/plan?collection=${encodeURIComponent(e)}`,{cache:"no-store"}).then(e=>n(e)),savePlan:(e,t)=>r("PUT","/engine/suites/plan",{collection:e,...t}).then(e=>n(e)),start:e=>r("POST","/engine/suites/runs",e).then(e=>n(e)),get:e=>fetch(`/engine/suites/runs/${encodeURIComponent(e)}`,{cache:"no-store"}).then(e=>n(e)),stop:e=>r("POST",`/engine/suites/runs/${encodeURIComponent(e)}/stop`).then(e=>n(e))},"suiteHref",0,function(e){return`/suite?c=${encodeURIComponent(e)}`}],14168)}]);