apitestcenter 0.11.0 → 0.12.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 +1964 -911
  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/{2xiq0vxqp_rsu.js → 1-6_oo-9egb_t.js} +1 -1
  10. package/dist/ui/_next/static/chunks/1_537szc_614o.js +1 -0
  11. package/dist/ui/_next/static/chunks/{1ffsp9e_ihf8c.js → 1_q4bnjjia0y5.js} +2 -2
  12. package/dist/ui/_next/static/chunks/{37izghagcat04.js → 1zmkb7tfqygqs.js} +1 -1
  13. package/dist/ui/_next/static/chunks/{0gfm4dc7bjzy1.js → 2t9juu3lz_5u-.js} +1 -1
  14. package/dist/ui/_next/static/chunks/3238j0_19x8_p.js +2 -0
  15. package/dist/ui/_next/static/chunks/{199g-q88qtg_i.js → 388t7tbteqx_j.js} +179 -89
  16. package/dist/ui/_next/static/chunks/3_q1wiq483s-m.css +3 -0
  17. package/dist/ui/_not-found/__next._full.txt +11 -11
  18. package/dist/ui/_not-found/__next._not-found.__PAGE__.txt +10 -10
  19. package/dist/ui/_not-found/__next._tree.txt +2 -2
  20. package/dist/ui/_not-found/index.html +1 -1
  21. package/dist/ui/_not-found/index.txt +11 -11
  22. package/dist/ui/compare/__next._full.txt +12 -12
  23. package/dist/ui/compare/__next._tree.txt +2 -2
  24. package/dist/ui/compare/__next.compare.__PAGE__.txt +11 -11
  25. package/dist/ui/compare/index.html +1 -1
  26. package/dist/ui/compare/index.txt +12 -12
  27. package/dist/ui/history/__next._full.txt +13 -13
  28. package/dist/ui/history/__next._tree.txt +2 -2
  29. package/dist/ui/history/__next.history.__PAGE__.txt +12 -12
  30. package/dist/ui/history/index.html +1 -1
  31. package/dist/ui/history/index.txt +13 -13
  32. package/dist/ui/index.html +1 -1
  33. package/dist/ui/index.txt +12 -12
  34. package/dist/ui/preview/__next._full.txt +13 -13
  35. package/dist/ui/preview/__next._tree.txt +2 -2
  36. package/dist/ui/preview/__next.preview.__PAGE__.txt +12 -12
  37. package/dist/ui/preview/index.html +1 -1
  38. package/dist/ui/preview/index.txt +13 -13
  39. package/dist/ui/suite/__next._full.txt +12 -12
  40. package/dist/ui/suite/__next._tree.txt +2 -2
  41. package/dist/ui/suite/__next.suite.__PAGE__.txt +11 -11
  42. package/dist/ui/suite/index.html +1 -1
  43. package/dist/ui/suite/index.txt +12 -12
  44. package/dist/ui/tests/__next._full.txt +11 -11
  45. package/dist/ui/tests/__next._tree.txt +2 -2
  46. package/dist/ui/tests/__next.tests.__PAGE__.txt +10 -10
  47. package/dist/ui/tests/index.html +1 -1
  48. package/dist/ui/tests/index.txt +11 -11
  49. package/package.json +1 -1
  50. package/dist/ui/_next/static/chunks/01tk3yrimgagm.js +0 -2
  51. package/dist/ui/_next/static/chunks/1ax1v4312l2w9.js +0 -1
  52. package/dist/ui/_next/static/chunks/239j59-_u852y.css +0 -3
  53. /package/dist/ui/_next/static/{XGxojrJs_nD9y7xtRMI1q → Tiehe_bgMIxGzSdltdXXB}/_buildManifest.js +0 -0
  54. /package/dist/ui/_next/static/{XGxojrJs_nD9y7xtRMI1q → Tiehe_bgMIxGzSdltdXXB}/_clientMiddlewareManifest.js +0 -0
  55. /package/dist/ui/_next/static/{XGxojrJs_nD9y7xtRMI1q → Tiehe_bgMIxGzSdltdXXB}/_ssgManifest.js +0 -0
@@ -0,0 +1,2 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,6980,e=>{"use strict";var t=e.i(61666);e.i(24856);var s=e.i(90870),a=e.i(2385),n=e.i(36163),r=e.i(78451),l=e.i(95486),i=e.i(20621),o=e.i(27813),c=e.i(99522);let d=(0,c.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),u=(0,c.default)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]);var m=e.i(3792);let h=(0,c.default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),p=(0,c.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var x=e.i(50962),f=e.i(66478),b=e.i(10281),g=e.i(83067),y=e.i(63343),v=e.i(44794),j=e.i(31753),k=e.i(29724),w=e.i(60566),N=e.i(39170),S=e.i(13318),E=e.i(68228),R=e.i(59100);let q=(0,c.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);var C=e.i(87283),$=e.i(80707),L=e.i(56396);e.i(42674);var M=e.i(5305),A=e.i(6278);let T="\0new";function O(e,t){if(!t.has("baseUrl"))return"baseUrl";let s="api";try{s=new URL(e).hostname.split(".")[0].replace(/[^A-Za-z0-9]/g,"")||"api"}catch{}let a=`${s}Url`;for(let e=2;t.has(a);e++)a=`${s}Url${e}`;return a}function P({draft:e,sent:s,onChange:a}){let{environments:n,activeEnv:r,vars:l}=(0,A.useWorkspace)(),[i,o]=(0,g.useState)(!1),c=function(e){try{let t=new URL(e);if(!/^https?:$/.test(t.protocol)||["localhost","127.0.0.1"].includes(t.hostname))return[];let s=t.origin,a=t.pathname.split("/").filter(Boolean);return a.length>=2?[s,`${s}/${a[0]}`]:[s]}catch{return[]}}(e.url),d=new Set(Object.values(l).map(e=>e.trim().replace(/\/+$/,"")));return!s||!c.length||c.some(e=>d.has(e))?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{type:"button",onClick:()=>o(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-accent hover:underline",title:"Keep this server address in an environment",children:[(0,t.jsx)(q,{size:13,"aria-hidden":!0})," Save ",c[0].replace(/^https?:\/\//,"")," as a base URL"]}),i?(0,t.jsx)(U,{draft:e,addresses:c,environments:n,activeEnvId:r?.id??null,onChange:a,onClose:()=>o(!1)}):null]})}function U({draft:e,addresses:s,environments:a,activeEnvId:n,onChange:r,onClose:l}){let i=(0,L.useToast)(),{index:o,saveEnvironments:c,setActiveEnv:d,refresh:u}=(0,A.useWorkspace)(),[m,h]=(0,g.useState)(s[0]),[p,x]=(0,g.useState)(n??a[0]?.id??T),[f,b]=(0,g.useState)(()=>{try{return new URL(s[0]).hostname.split(".").slice(0,2).join(" ")}catch{return"My API"}}),y=a.find(e=>e.id===p)??null,v=(0,g.useMemo)(()=>new Set((y?.variables??[]).map(e=>e.key)),[y]),[j,k]=(0,g.useState)(()=>O(s[0],v)),[w,N]=(0,g.useState)(!0),[S,E]=(0,g.useState)(!1),q=(0,g.useRef)(null);(0,g.useEffect)(()=>q.current?.focus(),[]),(0,g.useEffect)(()=>k(O(m,v)),[m,v]);let P=(o?.requests??[]).filter(t=>t.url.startsWith(m)&&t.url!==e.url),F=y?.variables.find(e=>e.key===j),I=R.VARIABLE_NAME.test(j)&&(p!==T||f.trim());async function z(){if(I&&!S){E(!0);try{let t=p===T?globalThis.crypto?.randomUUID?.()??`env-${Date.now().toString(36)}`:p,s=structuredClone(a),n=s.find(e=>e.id===t);n||(n={id:t,name:f.trim(),variables:[]},s.push(n)),n.variables=[...n.variables.filter(e=>e.key!==j),{key:j,value:m,secret:!1}],await c(s),d(t),r((0,M.withUrl)(e,`{{${j}}}${e.url.slice(m.length)}`));let o=0,h=0;if(w){for(let e of P){let t=await A.workspaceApi.get(e.id).catch(()=>null);if(!t||t.secretsMissing?.length){h++;continue}let s=(0,M.requestFromUnknown)(t.request);s.url.startsWith(m)&&(await A.workspaceApi.update(e.id,{name:t.name,collection:t.collection,request:(0,M.withUrl)(s,`{{${j}}}${s.url.slice(m.length)}`)}),o++)}await u()}i(`Saved {{${j}}} in ${n.name}.${o?` ${o} other saved request${1===o?"":"s"} now use it.`:""}${h?` ${h} left as they were (a saved secret isn't available).`:""} Save this request to keep the change.`,"success"),l()}catch(e){i(e instanceof Error?e.message:"Could not save the base URL","error")}finally{E(!1)}}}return(0,t.jsx)("div",{className:"fixed inset-0 z-[75] flex items-start justify-center overflow-y-auto bg-black/50 p-4 sm:p-16",role:"presentation",onMouseDown:e=>e.target===e.currentTarget&&!S&&l(),children:(0,t.jsxs)("form",{role:"dialog","aria-modal":"true","aria-labelledby":"save-base-title",onSubmit:e=>{e.preventDefault(),z()},onKeyDown:e=>"Escape"===e.key&&!S&&l(),className:"w-full max-w-lg space-y-4 rounded-xl border border-line bg-panel p-5 shadow-2xl",children:[(0,t.jsxs)("header",{className:"flex items-center gap-2",children:[(0,t.jsx)("h2",{id:"save-base-title",className:"text-base font-medium text-ink",children:"Save as a base URL"}),(0,t.jsx)("button",{type:"button",onClick:l,"aria-label":"Close",className:"ml-auto rounded p-1 text-mute hover:text-ink",children:(0,t.jsx)(C.X,{size:16})})]}),(0,t.jsx)("p",{className:"text-sm text-mute",children:"Keep the server address in an environment, so you type only the path — and switch servers (UAT, Prod) by switching environments."}),(0,t.jsxs)("fieldset",{className:"space-y-1.5",children:[(0,t.jsx)("legend",{className:"mb-1 text-xs text-mute",children:"Address"}),s.map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm text-ink",children:[(0,t.jsx)("input",{type:"radio",name:"address",checked:m===e,onChange:()=>h(e)}),(0,t.jsx)("span",{className:"font-mono text-xs break-all",children:e})]},e))]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["Environment",(0,t.jsx)($.Select,{label:"Environment",value:p,onChange:x,options:[...a.map(e=>({value:e.id,label:e.name,hint:`${e.variables.length} variables`})),{value:T,label:"New environment…"}],className:"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:["Variable name",(0,t.jsx)("input",{ref:q,value:j,onChange:e=>k(e.target.value.replace(/[^\w.-]/g,"")),className:"input py-1.5 font-mono text-sm"})]}),p===T?(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute sm:col-span-2",children:["New environment name",(0,t.jsx)("input",{value:f,onChange:e=>b(e.target.value),className:"input py-1.5 text-sm"})]}):null]}),F&&F.value!==m?(0,t.jsxs)("p",{className:"text-xs text-warn",children:[`{{${j}}}`," already exists in this environment (",F.value,") — it will be replaced."]}):null,(0,t.jsxs)("p",{className:"rounded-md bg-panel-2 px-3 py-2 font-mono text-xs text-ink break-all",children:[`{{${j}}}`,(0,t.jsx)("span",{className:"text-mute",children:e.url.slice(m.length)||"/"})]}),P.length?(0,t.jsxs)("label",{className:"flex items-start gap-2 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:w,onChange:e=>N(e.target.checked),className:"mt-1"}),(0,t.jsxs)("span",{children:["Also switch ",P.length," other saved request",1===P.length?"":"s"," that use this address",(0,t.jsxs)("span",{className:"block text-xs text-mute",children:[P.slice(0,3).map(e=>e.name).join(", "),P.length>3?` and ${P.length-3} more`:""]})]})]}):null,(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary",onClick:l,disabled:S,children:"Cancel"}),(0,t.jsx)("button",{type:"submit",className:"btn btn-primary",disabled:!I||S,children:"Save base URL"})]})]})})}var F=e.i(65638);function I(e,t){let s=(0,g.useRef)(!0);(0,g.useEffect)(()=>{if(s.current){s.current=!1;return}let t=e.current;!t||function(){try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}()||"function"!=typeof t.animate||t.animate([{opacity:.35,transform:"translateY(3px)"},{opacity:1,transform:"none"}],{duration:180,easing:"cubic-bezier(0.2, 0, 0, 1)"})},[e,t])}var z=e.i(97716);let D=(e,t)=>"number"==typeof t?`${e}[${t}]`:/^[A-Za-z_$][\w$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`;var V=e.i(91694),_=e.i(96659),J=e.i(37837);function W({requestId:e,refreshKey:s,onOpen:a}){let n=(0,g.useRef)(null),[r,l]=(0,g.useState)(!1),[i,o]=(0,g.useState)([]),c=()=>void fetch(`/engine/responses/${e}`,{cache:"no-store"}).then(e=>e.ok?e.json():{answers:[]}).then(e=>o(e.answers)).catch(()=>void 0);return((0,g.useEffect)(c,[e,s]),i.length<2)?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{ref:n,type:"button",onClick:()=>l(e=>!e),"aria-expanded":r,title:"Earlier answers of this request — open one, or see what changed",className:"inline-flex items-center gap-1 rounded-md border border-line px-2 py-0.5 text-xs text-mute hover:border-accent hover:text-ink",children:[(0,t.jsx)(V.History,{size:12,"aria-hidden":!0})," Earlier · ",i.length-1]}),(0,t.jsx)(J.Popover,{anchor:n,open:r,onClose:()=>l(!1),label:"Earlier answers",width:340,children:(0,t.jsxs)("div",{className:"max-h-80 overflow-auto p-1",children:[(0,t.jsxs)("p",{className:"px-2 py-1.5 text-xs text-mute",children:["The last ",i.length," answers of this request, newest first."]}),(0,t.jsx)("ul",{children:i.map((s,n)=>{let r;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:async()=>{let t=await fetch(`/engine/responses/${e}/${n}`,{cache:"no-store"});t.ok&&a(await t.json(),n),l(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-panel-2",children:[(0,t.jsx)("span",{className:`rounded border px-1.5 font-mono ${(0,w.statusTone)(s.status)}`,children:s.status||"ERR"}),(0,t.jsx)("span",{className:"text-ink",children:0===n?"Latest":(r=new Date(s.at),new Date().toDateString()===r.toDateString()?r.toLocaleTimeString():r.toLocaleString())}),(0,t.jsxs)("span",{className:"ml-auto font-mono text-mute",children:[Math.round(s.durationMs)," ms"]}),s.checks?(0,t.jsxs)("span",{className:s.passed===s.checks?"text-ok":"text-bad",children:[s.passed,"/",s.checks]}):null]})},s.at)})}),(0,t.jsxs)("button",{type:"button",onClick:async()=>{await fetch(`/engine/responses/${e}`,{method:"DELETE"}),l(!1),c()},className:"mt-1 flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs text-mute hover:bg-panel-2 hover:text-bad",children:[(0,t.jsx)(_.Trash2,{size:12,"aria-hidden":!0})," Forget these answers"]})]})})]})}function K(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}let H=e=>{let t="string"==typeof e?JSON.stringify(e):JSON.stringify(e)??"undefined";return t.length>80?`${t.slice(0,79)}…`:t};function B({earlier:e,latest:s}){let a=(0,g.useMemo)(()=>(function(e,t,s=200){let a,n;try{a=JSON.parse(e),n=JSON.parse(t)}catch{return null}let r=[],l=(e,t,a,n)=>{if(r.length>=s)return;let i=null!==t&&"object"==typeof t;if(null!==e&&"object"==typeof e&&i&&Array.isArray(e)===Array.isArray(t)&&n<40){if(Array.isArray(e)&&Array.isArray(t)){for(let i=0;i<Math.max(e.length,t.length)&&(i>=e.length?r.push({path:D(a,i),kind:"added",after:t[i]}):i>=t.length?r.push({path:D(a,i),kind:"removed",before:e[i]}):l(e[i],t[i],D(a,i),n+1),!(r.length>=s));i++);return}for(let i of new Set([...Object.keys(e),...Object.keys(t)]))if(i in t?i in e?l(e[i],t[i],D(a,i),n+1):r.push({path:D(a,i),kind:"added",after:t[i]}):r.push({path:D(a,i),kind:"removed",before:e[i]}),r.length>=s)break;return}JSON.stringify(e)!==JSON.stringify(t)&&r.push({path:a,kind:"changed",before:e,after:t})};return l(a,n,"$",0),r})(e.body,s.body),[e.body,s.body]),n=(0,g.useMemo)(()=>(function(e,t,s=3e3){let a=e.split("\n"),n=t.split("\n"),r=a.length>s||n.length>s;a=a.slice(0,s),n=n.slice(0,s);let l=0;for(;l<a.length&&l<n.length&&a[l]===n[l];)l++;let i=a.length,o=n.length;for(;i>l&&o>l&&a[i-1]===n[o-1];)i--,o--;let c=a.slice(l,i),d=n.slice(l,o),u=a.slice(0,l).map(e=>({kind:"same",text:e}));if(c.length*d.length>4e6)u.push(...c.map(e=>({kind:"removed",text:e})),...d.map(e=>({kind:"added",text:e})));else{let e=d.length+1,t=new Uint32Array((c.length+1)*e);for(let s=c.length-1;s>=0;s--)for(let a=d.length-1;a>=0;a--)t[s*e+a]=c[s]===d[a]?t[(s+1)*e+a+1]+1:Math.max(t[(s+1)*e+a],t[s*e+a+1]);let s=0,a=0;for(;s<c.length&&a<d.length;)c[s]===d[a]?(u.push({kind:"same",text:c[s]}),s++,a++):t[(s+1)*e+a]>=t[s*e+a+1]?u.push({kind:"removed",text:c[s++]}):u.push({kind:"added",text:d[a++]});for(;s<c.length;)u.push({kind:"removed",text:c[s++]});for(;a<d.length;)u.push({kind:"added",text:d[a++]})}return u.push(...a.slice(i).map(e=>({kind:"same",text:e}))),{lines:u,cut:r}})(K(e.body),K(s.body)),[e.body,s.body]),r=n.lines.filter(e=>"same"!==e.kind).length;return(0,t.jsxs)("div",{className:"space-y-3 overflow-auto",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-mute",children:[(0,t.jsxs)("span",{children:["Status ",(0,t.jsx)("span",{className:"font-mono text-ink",children:e.status})," → ",(0,t.jsx)("span",{className:"font-mono text-ink",children:s.status}),e.status===s.status?" (same)":""]}),(0,t.jsxs)("span",{children:["Time ",(0,t.jsxs)("span",{className:"font-mono text-ink",children:[Math.round(e.durationMs)," ms"]})," → ",(0,t.jsxs)("span",{className:"font-mono text-ink",children:[Math.round(s.durationMs)," ms"]})]}),(0,t.jsx)("span",{children:r?`${r} line${1===r?"":"s"} differ`:"The body is the same"})]}),e.masked?(0,t.jsx)("p",{className:"text-xs text-mute",children:"Values that look like secrets were hidden when the earlier answer was kept, so they show as changed."}):null,a&&a.length?(0,t.jsxs)("section",{"aria-label":"Changed fields",children:[(0,t.jsxs)("h3",{className:"mb-1 text-xs font-medium text-mute",children:[a.length," field",1===a.length?"":"s"," changed",a.length>=200?" (the first 200)":""]}),(0,t.jsx)("ul",{className:"max-h-56 space-y-0.5 overflow-auto rounded-md border border-line bg-panel-2 p-2 font-mono text-xs",children:a.map((e,s)=>(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"text-ink",children:e.path})," ","changed"===e.kind?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-bad line-through decoration-bad/60",children:H(e.before)})," → ",(0,t.jsx)("span",{className:"text-ok",children:H(e.after)})]}):"added"===e.kind?(0,t.jsxs)("span",{className:"text-ok",children:["added ",H(e.after)]}):(0,t.jsxs)("span",{className:"text-bad",children:["removed (was ",H(e.before),")"]})]},s))})]}):null,(0,t.jsxs)("section",{"aria-label":"Line by line",children:[(0,t.jsxs)("h3",{className:"mb-1 text-xs font-medium text-mute",children:["Line by line",n.cut?" (the first 3,000 lines)":""]}),(0,t.jsx)("pre",{className:"max-h-[28rem] overflow-auto rounded-md border border-line bg-panel-2 py-2 font-mono text-[12.5px] leading-5",children:n.lines.map((e,s)=>(0,t.jsxs)("div",{className:"added"===e.kind?"bg-ok/10 text-ok":"removed"===e.kind?"bg-bad/10 text-bad":"text-ink",children:[(0,t.jsx)("span",{className:"inline-block w-5 select-none text-center text-mute",children:"added"===e.kind?"+":"removed"===e.kind?"−":" "}),e.text]},s))})]})]})}var Q=e.i(21206),Y=e.i(20054);let Z="apitestcenter-lab-draft";var G=e.i(59180),X=e.i(88153),ee=e.i(2603),et=e.i(46679),es=e.i(65238),ea=e.i(727),en=e.i(45672),er=e.i(69578);let el="apitestcenter-lab-saved",ei="apitestcenter-requests-panel",eo="apitestcenter-last-run";function ec(e){try{sessionStorage.setItem(eo,e)}catch{}}function ed(){return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-accent opacity-60"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-accent"})]}),"Load running"]})}function eu({title:e,lines:s,action:a}){return(0,t.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center rounded-lg border border-dashed border-line px-6 py-14 text-center",children:[(0,t.jsx)("h2",{className:"text-base font-medium text-ink",children:e}),(0,t.jsx)("div",{className:"mt-2 max-w-md space-y-1.5 text-sm text-mute",children:s.map((e,s)=>(0,t.jsx)("p",{children:e},s))}),a?(0,t.jsx)("div",{className:"mt-5",children:a}):null]})}function em({runs:e,current:s,disabled:n,onPick:r}){let{slo:i}=(0,X.useSlo)(),[o,c]=(0,g.useState)(!1),d=(0,g.useRef)(null),u=(0,g.useMemo)(()=>e.slice(0,30),[e]);return(0,g.useEffect)(()=>{if(!o)return;let e=e=>{d.current?.contains(e.target)||c(!1)},t=e=>"Escape"===e.key&&c(!1);return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[o]),(0,t.jsxs)("div",{ref:d,className:"relative",children:[(0,t.jsxs)("button",{type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":o,onClick:()=>c(e=>!e),className:"inline-flex items-center gap-1 rounded-md border border-line px-2 py-1 text-xs text-mute hover:text-ink disabled:opacity-40",children:["Recent runs",(0,t.jsx)(l.ChevronDown,{size:12})]}),o?(0,t.jsx)("ul",{role:"listbox","aria-label":"Recent runs",className:"absolute right-0 z-30 mt-1 max-h-80 w-80 overflow-auto rounded-md border border-line bg-panel p-1 shadow-xl",children:u.map(e=>{let n=(0,a.buildVerdictFromInputs)(e.verdict,{slo:i}).overall,l=s?.id===e.id;return(0,t.jsx)("li",{role:"option","aria-selected":l,children:(0,t.jsxs)("button",{type:"button",onClick:()=>{r(e),c(!1)},className:`flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-xs ${l?"bg-accent-dim text-ink":"text-ink hover:bg-panel-2"}`,children:[(0,t.jsxs)("span",{className:"min-w-0 truncate",children:[e.baseline?(0,t.jsx)("span",{className:"mr-1 text-accent",title:"Baseline",children:"◆"}):null,e.name]}),(0,t.jsx)(eh,{level:n})]})},e.id)})}):null]})}function eh({level:e}){let s="pass"===e?"text-ok":"fail"===e?"text-bad":"text-warn";return(0,t.jsxs)("span",{className:`shrink-0 font-mono text-xs uppercase ${s}`,children:[(0,t.jsxs)("span",{"aria-hidden":!0,children:["pass"===e?"✓":"fail"===e?"✕":"!"," "]}),e]})}function ep(){let{slo:e,setSlo:s,ready:a}=(0,X.useSlo)(),[n,r]=(0,g.useState)(!1),[l,i]=(0,g.useState)(500),[o,c]=(0,g.useState)(0),[d,u]=(0,g.useState)(1),[m,h]=(0,g.useState)(99),[p,x]=(0,g.useState)(!1),f=(0,g.useRef)(!1);function b(e){let t={on:n,p95:l,p99:o,errPct:d,checksPct:m,abort:p,...e};if(r(t.on),i(t.p95),c(t.p99),u(t.errPct),h(t.checksPct),x(t.abort),!t.on||!(t.p95>0)||t.errPct<0)return s(null);s({p95Ms:t.p95,errorRate:t.errPct/100,p99Ms:t.p99>0?t.p99:void 0,checksRate:Math.min(100,Math.max(0,t.checksPct))/100,abortOnFail:t.abort})}(0,g.useEffect)(()=>{a&&!f.current&&(f.current=!0,e&&(r(!0),i(e.p95Ms),c(e.p99Ms??0),u(Number((100*e.errorRate).toFixed(4))),h(null!=e.checksRate?Number((100*e.checksRate).toFixed(2)):99),x(!0===e.abortOnFail)))},[a,e]);let y=(e,s,a,n)=>(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"mb-1 block text-xs text-mute",children:e}),(0,t.jsx)("input",{type:"number",min:n.min,max:n.max,step:n.step,value:s,onChange:e=>b({[a]:Number(e.target.value)}),className:"input font-mono"}),n.hint?(0,t.jsx)("span",{className:"mt-1 block text-xs text-mute",children:n.hint}):null]});return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-sm text-mute",children:"Targets decide whether a load test passes. They are sent to k6 as thresholds, drive the verdict and the report colours, and are remembered on this computer."}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:e=>b({on:e.target.checked}),className:"accent-[var(--accent)]"}),"Use my own performance targets"]}),n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[y("p95 must stay under (ms)",l,"p95",{min:1}),y("p99 must stay under (ms)",o,"p99",{min:0,hint:"0 = no p99 target"}),y("Error rate must stay under (%)",d,"errPct",{min:0,max:100,step:.1}),y("Checks must pass at least (%)",m,"checksPct",{min:0,max:100,step:.1,hint:"Only used when the request has checks"})]}),(0,t.jsxs)("label",{className:"flex items-start gap-2 rounded-md border border-line px-3 py-2.5 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:p,onChange:e=>b({abort:e.target.checked}),className:"mt-0.5 accent-[var(--accent)]"}),(0,t.jsxs)("span",{children:["Stop the test early if a target is clearly missed",(0,t.jsx)("span",{className:"block text-xs text-mute",children:"After a 10-second warm-up, k6 ends the run as soon as a target fails — saves time and stops hammering a struggling API."})]})]})]}):(0,t.jsx)("p",{className:"rounded-md bg-panel-2 px-3 py-2 text-sm text-mute",children:"Using built-in defaults: warn at p95 ≥ 500 ms or errors ≥ 1%, fail at p95 ≥ 2 s or errors ≥ 5%. No thresholds are sent to k6."})]})}e.s(["LabPage",0,function(){var e;let l=(0,L.useToast)(),c=(0,N.useConfirm)(),R=(0,Y.useEngineHealth)(),q=(0,ee.useModKey)(),{slo:C}=(0,X.useSlo)(),{vars:$,activeEnv:T,refresh:O,rememberValues:U}=(0,A.useWorkspace)(),[D,V]=(0,g.useState)(null),[_,J]=(0,g.useState)(!1),[K,H]=(0,g.useState)(!0),eh=(0,g.useRef)(null),[ex,ef]=(0,g.useState)(M.defaultRequestDraft),[eb,eg]=(0,g.useState)(M.DEFAULT_LOAD),[ey,ev]=(0,g.useState)(!1),[ej,ek]=(0,g.useState)(null),[ew,eN]=(0,g.useState)(null),[eS,eE]=(0,g.useState)(!1),[eR,eq]=(0,g.useState)(null),[eC,e$]=(0,g.useState)(!1),eL=(0,g.useRef)(null),eM=(0,g.useRef)(null);I(eL,D?.id),I(eM,ej);let[eA,eT]=(0,g.useState)(!1),[eO,eP]=(0,g.useState)(!1),[eU,eF]=(0,g.useState)(!1),[eI,ez]=(0,g.useState)(null),[eD,eV]=(0,g.useState)(null),{index:e_,refresh:eJ}=(0,G.useHistory)(),eW=e_?.runs??[],[eK,eH]=(0,g.useState)("response"),[eB,eQ]=(0,g.useState)(!1),eY=eD?.status==="running"||eD?.status==="queued",eZ=(0,M.isReady)(ex),eG=(0,M.loadProblem)(eb),eX=eA||eO;(0,g.useEffect)(()=>{let e=null;try{e=sessionStorage.getItem(eo)}catch{}e&&(0,Q.fetchRun)(e).then(async t=>{if(t)return eV(t);let s=await G.historyApi.run(e).catch(()=>null);s&&eV({id:s.report.id,status:s.report.status,report:s.report})});let t=function(){try{let e=sessionStorage.getItem(Z);if(!e)return null;let t=JSON.parse(e);if(2===t.v)return{request:(0,M.requestFromUnknown)(t.request),load:(0,M.loadFromUnknown)(t.load)};return{request:(0,M.requestFromUnknown)(t),load:(0,M.loadFromUnknown)(t)}}catch{return null}}();t&&(ef(t.request),eg(t.load));try{let e=sessionStorage.getItem(el);e&&V(JSON.parse(e)),H("closed"!==localStorage.getItem(ei))}catch{}ev(!0)},[]),(0,g.useEffect)(()=>{if(!ey)return;let e=window.setTimeout(()=>(function(e){try{sessionStorage.setItem(Z,JSON.stringify({v:2,...e}))}catch{}})({request:ex,load:eb}),250);return()=>window.clearTimeout(e)},[ex,eb,ey]),(0,g.useEffect)(()=>{if(!eD||!eY)return;let e=!1,t=window.setInterval(async()=>{let t=await (0,Q.fetchRun)(eD.id);if(t&&!e&&(eV(t),(0,Q.isTerminalStatus)(t.status))){eJ();let e="completed"===t.status?"finished":t.status;l(`Load test ${e}`,"failed"===t.status?"error":"success");let s=(0,a.buildVerdict)(t.report,{slo:C});(0,ea.notifyFinished)({title:`Load test ${e}`,body:`${t.report.testName}
2
+ ${"completed"===t.status?s.headline:t.error??"See the report for details."}`,ok:"completed"===t.status&&"fail"!==s.overall})}},500);return()=>{e=!0,window.clearInterval(t)}},[eD?.id,eY]);let e0=!!D&&JSON.stringify(ex)!==D.snapshot;function e1(e){V(e);try{e?sessionStorage.setItem(el,JSON.stringify(e)):sessionStorage.removeItem(el)}catch{}}function e2(e){H(e);try{localStorage.setItem(ei,e?"open":"closed")}catch{}}async function e5(e){try{let t={name:e?.name??D.name,collection:e?.collection??D.collection,request:ex},s=D&&!e?await A.workspaceApi.update(D.id,t):await A.workspaceApi.create(t);e1({id:s.id,name:s.name,collection:s.collection,snapshot:JSON.stringify(ex)}),J(!1),await O(),l(`Saved “${s.name}”${s.collection?` in ${s.collection}`:""}`,"success")}catch(e){l(e instanceof Error?e.message:"Could not save the request","error")}}async function e6(){return!e0||c({title:`Discard changes to “${D.name}”?`,body:"They have not been saved.",confirmLabel:"Discard",tone:"danger"})}let[e3,e4]=(0,g.useState)(!1);async function e9(){await e6()&&(ef({...(0,M.withUrl)((0,M.defaultRequestDraft)(),"{{practiceApi}}/products"),checks:[{type:"status",expect:"2xx"},{type:"json",path:"items[0].name",op:"exists",value:""}]}),e1(null),ek(null),eF(!1),ez(null),eH("response"),l("Practice request ready — press Send","success"))}async function e7(){try{let e=await A.workspaceApi.index(),t=t=>e.requests.find(e=>"Practice"===e.collection&&e.name===t),s=t("Sign in")?.id??(await A.workspaceApi.create({name:"Sign in",collection:"Practice",request:{...(0,M.withUrl)({...(0,M.defaultRequestDraft)(),method:"POST"},"{{practiceApi}}/login"),bodyMode:"json",bodyText:'{\n "username": "you",\n "password": "demo"\n}',checks:[{type:"status",expect:"200"}]}})).id,a=t("My orders"),n=a?await A.workspaceApi.get(a.id):await A.workspaceApi.create({name:"My orders",collection:"Practice",request:{...(0,M.withUrl)((0,M.defaultRequestDraft)(),"{{practiceApi}}/orders"),authMode:"bearer",token:"{{token}}",checks:[{type:"status",expect:"200"}],before:{requestId:s,requestName:"Sign in",extract:[{name:"token",from:"json",path:"data.token"}]}}});await O(),e2(!0),await e8(n),l("Added Practice → Sign in and My orders. Press Send: it signs in first, then uses the token.","success")}catch(e){l(e instanceof Error?e.message:"Could not add the practice requests","error")}}async function e8(e){if(!await e6())return;let t=(0,M.requestFromUnknown)(e.request);ef(t),e1({id:e.id,name:e.name,collection:e.collection,snapshot:JSON.stringify(t)}),ek(null),eF(!1),ez(null),eH("response")}async function te(){await e6()&&(ef((0,M.defaultRequestDraft)()),e1(null),ek(null),ez(null),window.setTimeout(()=>eh.current?.focus(),0))}async function tt(){try{ez(null);let e=await (0,es.withFolders)(ex,D?.collection,$),t=(0,M.resolveDraft)(e.draft,e.vars,T?.name),s=/^wss?:\/\//i.test(t.url),a=s?(0,M.withUrl)(t,t.url.replace(/^ws/i,"http")):t,n=(0,M.buildPayload)(a,(0,M.toLoadConfig)(eb),(0,M.autoRunName)(a,D?.name),(0,M.targetsFromSlo)(C));return s&&(n.request={...n.request,url:n.request.url.replace(/^http/i,"ws")}),await (0,et.withRunFirst)(n,t,$,T?.name)}catch(e){return ez(e instanceof Error?e.message:"Request is not valid"),null}}async function ts(){try{let e={...ex,method:"POST",bodyMode:"graphql",graphqlQuery:s.INTROSPECTION_QUERY,graphqlVariables:"",graphqlOperation:"IntrospectionQuery",graphqlErrorsFail:!1,checks:[],saveValues:[],testData:null},t=await (0,es.withFolders)(e,D?.collection,$),a=(0,M.resolveDraft)(t.draft,t.vars,T?.name),{request:n,auth:r,options:l,setup:i}=await (0,et.withRunFirst)((0,M.buildPayload)(a,(0,M.toLoadConfig)(eb),"schema"),a,$,T?.name),o=await fetch("/engine/graphql/introspect",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({request:n,auth:r,options:l,setup:i})}),c=await o.json();return o.ok?c:{status:0,body:"",error:c.error??`Engine error (${o.status})`}}catch(e){return{status:0,body:"",error:e instanceof Error?e.message:String(e)}}}async function ta(){if(eX||!eZ)return;let e=await tt();if(e){if(/^wss?:\/\//i.test(e.request.url)){if(ew&&eS)return void await z.realtimeApi.close(ew);eT(!0),eH("response");try{ew&&z.realtimeApi.close(ew);let{id:t}=await z.realtimeApi.connect({request:e.request,auth:e.auth,options:e.options});ek(null),eN(t),eE(!0)}catch(e){ez(e instanceof Error?e.message:"Could not connect")}finally{eT(!1)}return}eT(!0),eF(!1),eH("response");try{eN(null);let t=await (0,Q.sendRequest)(e,D?.id);eq(null),e$(!1),ek(t);let s=(t.saved??[]).flatMap(e=>e.found&&void 0!==e.value?[{name:e.name,value:e.value}]:[]);U(s,D?.name??"the last Send")}finally{eT(!1)}}}async function tn(e=!1){if(eX||eY||!eZ||!R.k6Ready)return;if(eG)return void ez(eG);let s=await tt();if(s){if(eF(!1),!e){eP(!0);try{let e=await (0,Q.sendRequest)(s);if(ek(e),!(0,Q.isSuccess)(e)){eF(!0),eH("response");return}}finally{eP(!1)}}if((0,Q.needsLoadConfirm)(eb.preset,s.load,s.request.url)&&!await c({title:`Start a ${(0,y.profileSummary)(eb)} load test against ${(0,Q.hostOf)(s.request.url)}?`,body:(0,t.jsxs)(t.Fragment,{children:["This is a ",(0,t.jsx)("span",{className:"text-ink",children:eb.preset})," profile against a non-local host (",(0,y.profileSummary)(eb),"). Only load-test systems you own or are allowed to test.",(0,t.jsxs)("span",{className:"mt-2 block",children:["Each simulated user sends its next request as soon as the last one returns, so a few dozen users can mean thousands of requests per second. Public sites and APIs behind a CDN or firewall usually answer that with ",(0,t.jsx)("span",{className:"text-ink",children:"429"})," or"," ",(0,t.jsx)("span",{className:"text-ink",children:"403"})," and may block this computer for a while — test a staging server, or use Requests per second mode with a modest rate."]})]}),confirmLabel:"Start load test",tone:"danger"}))return;try{let e=await (0,Q.startLoadRun)(s);ec(e.id),eV(e),eH("report")}catch(e){l(e instanceof Error?e.message:"Failed to start load","error")}}}async function tr(){if(!eD)return;let e=await (0,Q.stopLoadRun)(eD.id);e?eV(e):l("Could not reach the engine to stop the run","error")}(0,g.useEffect)(()=>{let e=()=>e4(!(0,en.welcomeHidden)());return e(),window.addEventListener(en.WELCOME_EVENT,e),()=>window.removeEventListener(en.WELCOME_EVENT,e)},[]),(0,g.useEffect)(()=>{let e=()=>{let e=null;try{e=sessionStorage.getItem(er.OPEN_REQUEST_KEY),sessionStorage.removeItem(er.OPEN_REQUEST_KEY)}catch{}e&&A.workspaceApi.get(e).then(e=>void e8(e)).catch(()=>l("That saved request is gone","error"))};return ey&&e(),window.addEventListener(er.OPEN_REQUEST_EVENT,e),()=>window.removeEventListener(er.OPEN_REQUEST_EVENT,e)},[ey]),(0,ee.useShortcuts)({send:()=>void ta(),run:()=>void tn(),focusUrl:()=>eh.current?.focus(),save:()=>D?void e5():J(!0)});let tl=/^wss?:\/\//i.test((0,r.substitute)(ex.url,$).text),ti=tl?"Load tests of WebSockets aren't available yet — Connect to try it":R.k6Ready?eZ?eG??void 0:"Enter a URL first":R.k6Label,to=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{type:"button","data-tour":"send",onClick:()=>void ta(),disabled:eX||!eZ,title:tl?eS?"Close the connection":`Open the WebSocket (${q}+Enter)`:`Send one request (${q}+Enter)`,className:tl&&eS?"btn btn-secondary":"btn btn-primary",children:[eA?(0,t.jsx)(o.Loader2,{size:16,className:"animate-spin"}):tl?eS?(0,t.jsx)(b.Unplug,{size:16}):(0,t.jsx)(h,{size:16}):(0,t.jsx)(x.Send,{size:16}),tl?eS?"Disconnect":"Connect":"Send"]}),eY?(0,t.jsxs)("button",{type:"button",onClick:()=>void tr(),disabled:eD?.stopping,className:"btn btn-danger",children:[eD?.stopping?(0,t.jsx)(o.Loader2,{size:16,className:"animate-spin"}):(0,t.jsx)(f.Square,{size:16}),eD?.stopping?"Stopping…":"Stop"]}):(0,t.jsxs)("button",{type:"button","data-tour":"run",onClick:()=>void tn(),disabled:eX||!!ti,title:ti??`Check the request, then run the load profile (${q}+Shift+Enter)`,className:"btn btn-secondary",children:[eO?(0,t.jsx)(o.Loader2,{size:16,className:"animate-spin"}):(0,t.jsx)(m.Play,{size:16}),eO?"Checking…":"Run load test"]})]});return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("header",{className:"border-b border-line bg-panel px-4 py-3 lg:px-6",children:[(0,t.jsx)("h1",{className:"sr-only",children:"Test an API"}),(0,t.jsx)(v.RequestBar,{ref:eh,draft:ex,onChange:e=>{ef(e),ez(null)},onImported:e=>l(e,"success"),actions:to}),(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-mute",children:[K?null:(0,t.jsxs)("button",{type:"button",onClick:()=>e2(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 hover:text-ink",children:[(0,t.jsx)(i.FolderOpen,{size:13,"aria-hidden":!0})," Saved requests"]}),(0,t.jsx)(E.EnvironmentBar,{drafts:[ex],collections:[D?.collection]}),(0,t.jsx)(P,{draft:ex,sent:!!(ej&&ej.status>0),onChange:ef}),_?(0,t.jsx)(F.SaveRequestForm,{initial:{name:D?.name??(0,M.autoRunName)(ex).replace(/ · \d.*$/,""),collection:D?.collection??""},onSave:(e,t)=>void e5({name:e,collection:t}),onCancel:()=>J(!1)}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[D?(0,t.jsxs)("span",{className:"text-ink",title:D.collection?`${D.collection} / ${D.name}`:D.name,children:[D.collection?(0,t.jsxs)("span",{className:"text-mute",children:[D.collection," / "]}):null,D.name,e0?(0,t.jsx)("span",{className:"ml-1 text-warn","aria-label":"unsaved changes",children:"● unsaved"}):null]}):null,(0,t.jsxs)("button",{type:"button",onClick:()=>D?void e5():J(!0),disabled:!!D&&!e0,title:`Save request (${q}+S)`,className:"inline-flex items-center gap-1 rounded-md border border-line px-2 py-0.5 text-ink hover:border-accent disabled:opacity-40",children:[(0,t.jsx)(p,{size:12,"aria-hidden":!0})," ",D?"Save":"Save request"]}),D?(0,t.jsx)("button",{type:"button",onClick:()=>J(!0),className:"rounded-md px-1.5 py-0.5 hover:text-ink",children:"Save as…"}):null]}),eI?(0,t.jsx)("span",{className:"text-bad",role:"alert",children:eI}):null,(0,t.jsxs)("span",{className:"ml-auto hidden items-center gap-1.5 sm:inline-flex",children:[(0,t.jsx)("span",{className:"kbd",children:q}),"+",(0,t.jsx)("span",{className:"kbd",children:"Enter"})," send",(0,t.jsx)("span",{className:"kbd ml-2",children:q}),"+",(0,t.jsx)("span",{className:"kbd",children:"Shift"}),"+",(0,t.jsx)("span",{className:"kbd",children:"Enter"})," load",(0,t.jsx)("span",{className:"kbd ml-2",children:"/"})," URL"]})]})]}),(0,t.jsxs)("div",{className:`grid min-h-0 flex-1 overflow-y-auto transition-[grid-template-columns] duration-200 ease-out motion-reduce:transition-none lg:overflow-hidden ${eB?"":K?"lg:grid-cols-[15rem_minmax(0,1fr)_minmax(0,1fr)] 2xl:grid-cols-[16rem_minmax(0,5fr)_minmax(0,7fr)]":"lg:grid-cols-[0rem_minmax(0,1fr)_minmax(0,1fr)] 2xl:grid-cols-[0rem_minmax(0,5fr)_minmax(0,7fr)]"}`,children:[eB?null:(0,t.jsx)("div",{inert:!K,"aria-hidden":!K||void 0,className:`min-h-0 min-w-0 overflow-hidden transition-opacity duration-200 motion-reduce:transition-none ${K?"opacity-100":"opacity-0 max-lg:hidden"}`,children:(0,t.jsx)("div",{className:"flex h-full w-[15rem] flex-col 2xl:w-[16rem] [&>aside]:flex-1",children:(0,t.jsx)(F.RequestsPanel,{activeId:D?.id??null,onOpen:e=>void e8(e),onNew:()=>void te(),onClose:()=>e2(!1)})})}),eB?null:(0,t.jsx)("section",{ref:eL,"aria-label":"Request",className:"min-w-0 px-4 py-4 lg:overflow-y-auto lg:px-6",children:(0,t.jsx)(j.RequestEditor,{id:"lab-request",draft:ex,onChange:ef,checkResults:ej?.checks,lastBody:ej?.body,lastResult:ej??void 0,setupResult:ej?.setup,savedResults:ej?.saved,currentId:D?.id,collection:D?.collection,introspect:ts,extraTabs:[{id:"load",label:"Load",badge:eb.stages?.length?"stages":"rate"===eb.mode?`${eb.rps}/s`:`${eb.vus} users \xb7 ${eb.duration}`,content:(0,t.jsx)(y.LoadEditor,{load:eb,onChange:eg})},{id:"targets",label:"Goals",content:(0,t.jsx)(ep,{})}]})}),(0,t.jsxs)("section",{ref:eM,"aria-label":"Results",className:"@container flex min-h-[32rem] min-w-0 flex-col border-line bg-panel/40 px-4 py-4 lg:min-h-0 lg:overflow-y-auto lg:border-l lg:px-6",children:[(0,t.jsx)(S.Tabs,{id:"lab-results",label:"Results",value:eK,onChange:eH,items:[{id:"response",label:"Response",badge:ej?ej.status||"ERR":void 0},{id:"report",label:eY?(0,t.jsx)(ed,{}):"Load report",badge:eW.length||void 0}],trailing:(0,t.jsxs)(t.Fragment,{children:["report"===eK&&eW.length>0?(0,t.jsx)(em,{runs:eW,current:eD,disabled:eY,onPick:async e=>{try{let t=await G.historyApi.run(e.id);ec(e.id),eV({id:t.report.id,status:t.report.status,report:t.report})}catch(e){l(e instanceof Error?e.message:"Could not open that run","error")}}}):null,(0,t.jsx)("button",{type:"button",onClick:()=>eQ(e=>!e),"aria-label":eB?"Show the request editor":"Expand results to full width",title:eB?"Show the request editor":"Expand results",className:"hidden rounded p-1.5 text-mute hover:bg-panel-2 hover:text-ink lg:block",children:eB?(0,t.jsx)(u,{size:14}):(0,t.jsx)(d,{size:14})})]})}),(0,t.jsx)("div",{...(0,S.tabPanelProps)("lab-results",eK),className:"flex min-h-0 flex-1 flex-col pt-4",children:"response"===eK?(0,t.jsxs)(t.Fragment,{children:[eU&&ej?(0,t.jsxs)("div",{role:"alert",className:"mb-4 flex flex-wrap items-center gap-3 rounded-md border border-warn/40 bg-warn/10 px-3 py-2.5",children:[(0,t.jsxs)("p",{className:"min-w-0 flex-1 text-sm text-ink",children:[(0,t.jsx)("span",{className:"font-medium text-warn",children:"Load test not started."})," The check returned"," ",ej.status||"an error",", not 2xx. Fix the request, or run anyway if this status is expected."]}),(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-1.5 text-xs",onClick:()=>void tn(!0),children:"Run anyway"})]}):null,ew&&!ej?(0,t.jsx)(z.LiveView,{id:ew,onClosed:()=>eE(!1)}):ej&&eR?(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-accent/40 bg-accent/10 px-3 py-2 text-xs",children:[(0,t.jsxs)("span",{className:"text-ink",children:[eC?"What changed since":"An earlier answer —"," ",new Date(eR.answer.at).toLocaleString()]}),(0,t.jsxs)("span",{className:"ml-auto flex gap-2",children:[(0,t.jsx)("button",{type:"button",className:"text-accent hover:underline",onClick:()=>e$(e=>!e),children:eC?"Show that answer":"Compare with the latest"}),(0,t.jsx)("button",{type:"button",className:"text-accent hover:underline",onClick:()=>eq(null),children:"Back to the latest"})]})]}),eC?(0,t.jsx)(B,{earlier:eR.answer,latest:ej}):(0,t.jsx)(w.ResponseViewer,{result:{ok:(e=eR.answer).status>=200&&e.status<400,status:e.status,statusText:String(e.status),headers:e.headers,body:e.body,truncated:e.truncated,durationMs:e.durationMs,url:e.url,...e.error?{error:e.error}:{},...e.checks?{checks:e.checks}:{}}})]}):ej?(0,t.jsx)(w.ResponseViewer,{result:ej,extra:D?.id?(0,t.jsx)(W,{requestId:D.id,refreshKey:ej,onOpen:(e,t)=>0===t?eq(null):(eq({answer:e,index:t}),e$(!1))}):null,onSaveExample:()=>{ef(e=>({...e,mock:(0,n.exampleFromResponse)(ej.status,ej.headers,ej.body)})),l(D?"Kept as the mock example — save the request to keep it":"Kept as the mock example — save the request to use it in the mock server","success")}}):e3?(0,t.jsx)(en.WelcomeCard,{practiceReady:!!R.demoApi,onSimple:()=>void e9(),onSignIn:()=>void e7(),onHide:()=>(0,en.setWelcomeHidden)(!0)}):(0,t.jsx)(eu,{title:"Send a request to see the response",lines:[(0,t.jsx)(t.Fragment,{children:"Paste a URL — or a whole curl command from your browser's DevTools — into the bar above."}),(0,t.jsxs)(t.Fragment,{children:["Press ",(0,t.jsx)("span",{className:"kbd",children:q}),"+",(0,t.jsx)("span",{className:"kbd",children:"Enter"})," to send it."]})]})]}):eD?(0,t.jsxs)(t.Fragment,{children:[eD.error?(0,t.jsx)("p",{role:"alert",className:"mb-3 rounded-md border border-bad/40 bg-bad/10 px-3 py-2 text-sm text-bad",children:eD.error}):null,(0,t.jsx)(k.ReportView,{report:eD.report,source:"session",live:eY,probe:ej})]}):(0,t.jsx)(eu,{title:"No load test yet",lines:[(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-ink",children:"Run load test"})," sends one check request first, then runs"," ",(0,t.jsx)("span",{className:"font-mono text-ink",children:(0,y.profileSummary)(eb)})," with k6."]}),(0,t.jsx)(t.Fragment,{children:"Change users, duration, and ramps in the Load tab. Set pass/fail goals in Goals."})],action:(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",disabled:eX||!!ti,title:ti,onClick:()=>void tn(),children:[(0,t.jsx)(m.Play,{size:16}),"Run load test"]})})})]})]})]})},"VerdictTag",0,eh],6980)}]);