@specbook/ui 0.3.0 → 0.5.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.
- package/dist-viewer/THIRD-PARTY-NOTICES.txt +0 -66
- package/dist-viewer/assets/Host-ClcN3YPO.js +41 -0
- package/dist-viewer/assets/{index-BBlFcQUE.js → index-BcHcUWbc.js} +1 -1
- package/dist-viewer/assets/main-CAlriyIm.js +15 -0
- package/dist-viewer/assets/{mount-DfwluJy4.js → mount-D3holu10.js} +2 -2
- package/dist-viewer/assets/panel-l1xvY4kI.css +1 -0
- package/dist-viewer/assets/{worker-BmvGpsJS.js → worker-13v89DyZ.js} +13 -13
- package/dist-viewer/index.html +4 -4
- package/dist-viewer/specbook.js +1 -1
- package/package.json +4 -4
- package/src/app.tsx +12 -3
- package/src/branding.ts +2 -1
- package/src/engine.ts +17 -0
- package/src/panel/OperationDocs.tsx +1 -1
- package/src/panel/RequestPanel.tsx +45 -5
- package/src/panel/SequencePanel.tsx +8 -1
- package/src/store.ts +2 -0
- package/src/styles/app.css +14 -1
- package/src/styles/panel.css +2 -4
- package/src/viewer/embed.ts +9 -2
- package/src/viewer/mount.ts +3 -18
- package/src/viewer/registry.ts +9 -13
- package/dist-viewer/assets/Host-Cq-4gDuM.js +0 -41
- package/dist-viewer/assets/faker-B3c03STC.js +0 -11
- package/dist-viewer/assets/main-CSkB-O_8.js +0 -14
- package/dist-viewer/assets/panel-hNOojwiM.css +0 -1
- package/dist-viewer/assets/registry-DIHX11uY.js +0 -2
- package/src/viewer/faker-en.ts +0 -3
- /package/dist-viewer/assets/{panel-9eYU7Gz6.js → panel-nV09I7Wr.js} +0 -0
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import{_ as e,a as t,d as n,f as r,g as i,h as a,m as o,p as s,u as c,y as l}from"./panel-9eYU7Gz6.js";import{i as u}from"./mount-DfwluJy4.js";import{i as d,l as f}from"./registry-DIHX11uY.js";import{A as p,C as m,D as h,E as g,M as _,N as v,O as y,S as b,T as x,_ as S,a as C,b as w,c as T,d as E,f as D,g as O,h as k,i as A,j,k as M,l as ee,m as te,n as ne,o as re,p as ie,r as N,s as P,u as F,v as I,w as ae,x as oe,y as L}from"./main-CSkB-O_8.js";var se={200:`OK`,201:`Created`,202:`Accepted`,204:`No Content`,301:`Moved Permanently`,302:`Found`,304:`Not Modified`,400:`Bad Request`,401:`Unauthorized`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,422:`Unprocessable Entity`,429:`Too Many Requests`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`},ce=e=>se[e]??``;function R(e){if(typeof e==`string`)return e.includes(`
|
|
2
|
-
`)?e.split(`
|
|
3
|
-
`):[JSON.stringify(e)];if(e===void 0)return[`undefined`];try{return(JSON.stringify(e,null,2)??String(e)).split(`
|
|
4
|
-
`)}catch{return[String(e)]}}function le(e,t){let n=[];if(e.length*t.length>25e4){for(let t of e)n.push({kind:`expected`,text:t});for(let e of t)n.push({kind:`received`,text:e});return n}let r=e.length,i=t.length,a=Array.from({length:r+1},()=>new Uint32Array(i+1));for(let n=r-1;n>=0;n--)for(let r=i-1;r>=0;r--)a[n][r]=e[n]===t[r]?a[n+1][r+1]+1:Math.max(a[n+1][r],a[n][r+1]);let o=0,s=0;for(;o<r&&s<i;)e[o]===t[s]?(n.push({kind:`same`,text:e[o]}),o++,s++):a[o+1][s]>=a[o][s+1]?n.push({kind:`expected`,text:e[o++]}):n.push({kind:`received`,text:t[s++]});for(;o<r;)n.push({kind:`expected`,text:e[o++]});for(;s<i;)n.push({kind:`received`,text:t[s++]});return n}function ue(e,t){let n=Array(e.length).fill(!1);e.forEach((r,i)=>{if(r.kind!==`same`)for(let r=Math.max(0,i-t);r<=Math.min(e.length-1,i+t);r++)n[r]=!0});let r=[],i=0,a=()=>{i>0&&r.push({kind:`skip`,text:`… ${i} unchanged line${i>1?`s`:``}`}),i=0};return e.forEach((e,t)=>{n[t]?(a(),r.push(e)):i++}),a(),r}function de(e,t=3){if(e.operator===`status`){let t=typeof e.actual==`number`?`${e.actual} ${ce(e.actual)}`.trim():String(e.actual);return[{kind:`expected`,text:`status ${e.expected}`},{kind:`received`,text:`status ${t}`}]}return`expected`in e||`actual`in e?ue(le(R(e.expected),R(e.actual)),t):e.diff?e.diff.split(`
|
|
5
|
-
`).map(e=>({kind:`same`,text:e})):[]}var z=e=>typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e):String(e);function fe(e={}){return Object.entries(e).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>e!=null).map(t=>({key:e,value:z(t),enabled:!0})))}function pe(e){let t={};for(let{key:n,value:r,enabled:i}of e){if(!i||n===``)continue;let e=t[n];t[n]=e===void 0?r:[...Array.isArray(e)?e:[e],r]}return t}function me(e){return typeof e!=`object`||!e?[]:_(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var he=/[^[\]]+|\[\]/g;function ge(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?ge(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?ge(o,i,n):o===void 0?n:[...[].concat(o),n],a}function _e(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=ge(t,n.match(he)??[n],a&&v(a)?a:r));return t}var ve=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,ye=e=>new RegExp(ve.source).test(e),be=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function xe(e){let t=[],n=0;for(let r of e.matchAll(ve))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?be(r[1]):`SESSION_${be(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var Se=e=>{let t=[];for(let[n,r]of Object.entries(e??{}))for(let e of Array.isArray(r)?r:[r])t.push(`${encodeURIComponent(n)}=${Ce(e)}`);return t.length?`?${t.join(`&`)}`:``};function Ce(e){return xe(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function B(e){if(v(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var we=e=>e.name??e.file??`file`,Te=e=>`'${e.replace(/'/g,`'\\''`)}'`;function V(e){return ye(e)?`"${xe(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:Te(e)}function Ee(e){let t=e.encoding??`json`,n=[V(`${e.url}${Se(e.query)}`)],r=e.method.toUpperCase(),i={...e.headers??{}},a=e=>Object.keys(i).some(t=>t.toLowerCase()===e),o=e.body,s=[];if(o!==void 0&&o!==``&&t!==`none`){if(t===`json`||t===`graphql`){let e=JSON.stringify(typeof o==`string`&&t===`graphql`?{query:o}:o);s.push(`-d ${V(e)}`),a(`content-type`)||(i[`Content-Type`]=`application/json`)}else if(t===`form`)for(let[t,n]of _(o,e.formArrays))s.push(`--data-urlencode ${V(`${t}=${n}`)}`);else if(t===`multipart`)for(let[e,t]of Object.entries(o??{}))for(let n of Array.isArray(t)?t:[t])n!=null&&(B(n)?s.push(`-F ${V(`${e}=@${we(n)}`)}`):s.push(`-F ${V(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${V(`@${B(o)?we(o):`file`}`)}`),a(`content-type`)||(i[`Content-Type`]=B(o)&&o.type?o.type:`application/octet-stream`)):(s.push(`-d ${V(String(o))}`),a(`content-type`)||(i[`Content-Type`]=`text/plain`))}r!==(s.length?`POST`:`GET`)&&n.push(`-X ${r}`);for(let[e,t]of Object.entries(i))n.push(`-H ${V(`${e}: ${t}`)}`);return n.push(...s),`curl ${n.join(` \\
|
|
6
|
-
`)}`}var De=/^[A-Za-z_$][\w$]*$/;function H(e){return ye(e)?`\`${xe(e).map(e=>typeof e==`string`?e.replace(/[\\`]|\$\{/g,e=>`\\${e}`):`\${process.env.${e.env}}`).join(``)}\``:`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}var U=e=>De.test(e)?e:H(e);function Oe(e,t){if(e==null)return`null`;if(typeof e==`string`)return H(e);if(typeof e!=`object`)return String(e);let n=`${t} `;if(Array.isArray(e))return e.length===0?`[]`:`[\n${e.map(e=>`${n}${Oe(e,n)},`).join(`
|
|
7
|
-
`)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${U(e)}: ${Oe(t,n)},`).join(`
|
|
8
|
-
`)}\n${t}}`}function ke(e){let t=e.encoding??`json`,n=e.method.toUpperCase(),r={...e.headers??{}},i=e=>Object.keys(r).some(t=>t.toLowerCase()===e),a=e.body,o=a!==void 0&&a!==``&&t!==`none`,s=[],c,l=!1;if(o){if(t===`json`||t===`graphql`)c=`JSON.stringify(${Oe(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=_(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${Oe(Object.fromEntries(t),` `)})`:`new URLSearchParams(${Oe(t,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/x-www-form-urlencoded`)}else if(t===`multipart`){s.push(`const form = new FormData()`);for(let[e,t]of Object.entries(a??{}))for(let n of Array.isArray(t)?t:[t])if(n!=null){if(B(n)){l=!0;let t=we(n);s.push(`form.append(${H(e)}, await openAsBlob(${H(t)}), ${H(t)})`)}else s.push(`form.append(${H(e)}, ${H(typeof n==`object`?JSON.stringify(n):String(n))})`)}c=`form`}else t===`binary`?(l=!0,c=`await openAsBlob(${H(B(a)?we(a):`file`)})`,i(`content-type`)||(r[`Content-Type`]=B(a)&&a.type?a.type:`application/octet-stream`)):(c=H(String(a)),i(`content-type`)||(r[`Content-Type`]=`text/plain`))}let u=`${e.url}${Se(e.query)}`,d=[];n!==`GET`&&d.push(` method: ${H(n)},`),Object.keys(r).length&&d.push(` headers: {\n${Object.entries(r).map(([e,t])=>` ${U(e)}: ${H(t)},`).join(`
|
|
9
|
-
`)}\n },`),c&&d.push(` body: ${c},`);let f=l?[`import { openAsBlob } from 'node:fs'`,``]:[],p=d.length===0?`const res = await fetch(${H(u)})`:`const res = await fetch(${H(u)}, {\n${d.join(`
|
|
10
|
-
`)}\n})`;return[...f,...s,p,`console.log(res.status, await res.text())`].join(`
|
|
11
|
-
`)}function Ae(e,t){return e===`curl`?Ee(t):ke(t)}var je=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],W=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);function Me(e){let t=[],n=e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\uE000${t.length-1}\uE000`));return n=n.replace(/\[([^\]]+)\]\(((?:https?:\/\/|mailto:)[^)\s]+)\)/g,(e,t,n)=>`<a href="${n}" target="_blank" rel="noreferrer">${t}</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|[\s(])\*([^*\s][^*]*)\*(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`).replace(/(^|[\s(])_([^_\s][^_]*)_(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`),n.replace(/\uE000(\d+)\uE000/g,(e,n)=>t[Number(n)]??``)}function Ne(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
|
|
12
|
-
`).split(`
|
|
13
|
-
`),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${Me(W(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${Me(W(e))}</li>`).join(``)}</${i.tag}>`),i=void 0};for(let e=0;e<t.length;e++){let s=t[e];if(/^```/.test(s)){a(),o();let r=[];for(e++;e<t.length&&!/^```/.test(t[e]);)r.push(t[e++]);n.push(`<pre><code>${W(r.join(`
|
|
14
|
-
`))}</code></pre>`);continue}let c=/^(#{1,4})\s+(.*)$/.exec(s);if(c){a(),o();let e=Math.min(4,c[1].length+1);n.push(`<h${e}>${Me(W(c[2]))}</h${e}>`);continue}let l=/^>\s?(.*)$/.exec(s);if(l){a(),o();let r=[l[1]];for(;e+1<t.length&&/^>\s?/.test(t[e+1]);)r.push(t[++e].replace(/^>\s?/,``));n.push(`<blockquote>${Me(W(r.join(` `)))}</blockquote>`);continue}let u=/^\s*[-*+]\s+(.*)$/.exec(s),d=/^\s*\d+[.)]\s+(.*)$/.exec(s);if(u||d){a();let e=u?`ul`:`ol`;i&&i.tag!==e&&o(),i??={tag:e,items:[]},i.items.push((u??d)?.[1])}else s.trim()===``?(a(),o()):(o(),r.push(s.trim()))}return a(),o(),n.join(``)}function Pe(e){return e?e.replace(/```[\s\S]*?```/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,``).replace(/^>\s?/gm,``).replace(/[`*]|(^|\s)_|_(?=\s|$)/g,`$1`).replace(/\s+/g,` `).trim():``}function Fe(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function Ie(e){return e?Me(W(e)):``}function Le(e,t=300){let n=Fe(e);if(!n)return``;let r=Pe(n);return r.length>t?W(`${r.slice(0,t-1).trimEnd()}…`):Ie(n)}var G=/^\s*\{\{[^}]+\}\}\s*$/,Re=e=>typeof e==`string`&&G.test(e);function ze(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var Be=[`title`,`description`,`default`,`examples`,`deprecated`];function Ve(e,t){let n={...e};for(let e of Be)t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);return n}function K(e,t){let n=e??{};for(let e=0;e<12&&n.$ref;e++){let e=String(n.$ref).split(`/`).pop(),r=t?.$defs?.[e];if(!r)return{...n,type:void 0};n=Ve(r,n)}return n}function q(e,t,n=0){let r=K(e,t);if(n>10)return r;if(Array.isArray(r.anyOf)){let e=r.anyOf.filter(e=>!ze(e));if(e.length===1||e.length>1)return q(Ve(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return q(Ve(r.oneOf[0],r),t,n+1);if(Array.isArray(r.allOf)){let e={...r};Reflect.deleteProperty(e,`allOf`);let i={...e.properties??{}},a=new Set(e.required??[]);for(let o of r.allOf){let r=q(o,t,n+1);Object.assign(i,r.properties??{});for(let e of r.required??[])a.add(e);for(let t of Be)r[t]!==void 0&&e[t]===void 0&&(e[t]=r[t]);r.type&&!e.type&&(e.type=r.type),r.items&&!e.items&&(e.items=r.items),r.enum&&!e.enum&&(e.enum=r.enum)}e.properties=i,e.required=[...a],!e.type&&Object.keys(i).length&&(e.type=`object`),r=e}return r}function J(e){let t=Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type;return t===`object`||t===`array`||t===`string`||t===`integer`||t===`number`||t===`boolean`?t:e.properties?`object`:e.items?`array`:e.enum?typeof e.enum[0]==`number`?`number`:`string`:t===`null`?`null`:`unknown`}function He(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function Ue(e,t=120){if(!e)return;let n=e.split(/\n+/)[0],r=(n.match(/^.*?[.!?](\s|$)/)?.[0]?.trim()??n).replace(/\s+/g,` `);return r.length>t?`${r.slice(0,t-1)}…`:r}function We(e,t){let n=q(e,t),r=new Set(n.required??[]);return Object.entries(n.properties??{}).map(([e,t])=>({name:e,schema:t,required:r.has(e)}))}function Ge(e,t,n){let r=q(e,n);if(typeof t==`number`)return r.items;if(r.properties?.[t])return r.properties[t];if(r.additionalProperties&&typeof r.additionalProperties==`object`)return r.additionalProperties}var Ke=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function qe(e,t,n){let r=K(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!ze(e));if(!i?.length)return q(r,n);let a=Ke(t);return q(Ve(i.find(e=>{let t=J(q(e,n));return t===a||t===`integer`&&a===`number`||t===`number`&&a===`number`})??i[0],r),n)}function Je(e,t,n,r={},i=``,a=0){if(!t||a>12||Re(e))return[];let o=qe(t,e,n),s=[],c=i||`(root)`,l=Array.isArray(o.type)&&o.type.includes(`null`);if(e===null)return!l&&J(o)!==`null`&&J(o)!==`unknown`&&o.nullable!==!0&&s.push({path:c,kind:`type`,message:`expected ${J(o)}, got null`}),s;let u=J(o),d=Ke(e);switch(u){case`object`:{if(d!==`object`)return[{path:c,kind:`type`,message:`expected object, got ${d}`}];let t=e,l=o.properties??{};for(let e of o.required??[])e in t||s.push({path:i?`${i}.${e}`:e,kind:`required`,message:`required field is missing`});for(let[e,c]of Object.entries(t)){let t=i?`${i}.${e}`:e;l[e]?s.push(...Je(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Je(c,o.additionalProperties,n,r,t,a+1)):r.reportExtra&&o.additionalProperties!==!0&&Object.keys(l).length>0&&s.push({path:t,kind:`extra`,message:`not in the spec`})}return s}case`array`:return d===`array`?(e.forEach((e,t)=>{s.push(...Je(e,o.items,n,r,`${i}[${t}]`,a+1))}),s):[{path:c,kind:`type`,message:`expected array, got ${d}`}];case`string`:return d===`string`?(o.enum&&!o.enum.includes(e)&&s.push({path:c,kind:`enum`,message:`must be one of: ${o.enum.join(` · `)}`}),s):[{path:c,kind:`type`,message:`expected string, got ${d}`}];case`integer`:case`number`:{if(d!==`number`)return[{path:c,kind:`type`,message:`expected ${u}, got ${d}`}];let t=e;return u===`integer`&&!Number.isInteger(t)&&s.push({path:c,kind:`type`,message:`expected an integer`}),o.minimum!==void 0&&t<o.minimum&&s.push({path:c,kind:`range`,message:`must be ≥ ${o.minimum}`}),o.maximum!==void 0&&t>o.maximum&&s.push({path:c,kind:`range`,message:`must be ≤ ${o.maximum}`}),o.enum&&!o.enum.includes(t)&&s.push({path:c,kind:`enum`,message:`must be one of: ${o.enum.join(` · `)}`}),s}case`boolean`:return d===`boolean`?[]:[{path:c,kind:`type`,message:`expected boolean, got ${d}`}];default:return[]}}var Ye=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Xe(e){let t=[void 0],n=[],r=0,i=e=>{t[r]===void 0&&(t[r]=e)},a=()=>n[n.length-1],o=e=>e?e.type===`arr`?[...e.path,e.idx]:e.key===void 0?void 0:[...e.path,e.key]:[];for(let s=0;s<e.length;s++){let c=e[s];if(c===`
|
|
15
|
-
`)r++,t[r]=void 0;else if(c===`"`){let t=s+1,n=``;for(;t<e.length&&e[t]!==`"`;)e[t]===`\\`?(n+=e[t+1]??``,t+=2):n+=e[t++];let r=t+1;for(;r<e.length&&/\s/.test(e[r])&&e[r]!==`
|
|
16
|
-
`;)r++;let o=a();o?.type===`obj`&&e[r]===`:`?(o.key=n,i([...o.path,n])):o?.type===`arr`&&i([...o.path,o.idx]),s=t}else if(c===`{`||c===`[`){let e=o(a());e&&i(e),n.push({type:c===`{`?`obj`:`arr`,path:e??[],idx:0})}else if(c===`}`||c===`]`){n.pop();let e=a();e?.type===`arr`&&e.idx++}else if(c===`,`)a();else if(/[-\d]|[tfn]/.test(c)){let t=a();if(t?.type===`arr`){i([...t.path,t.idx]);let n=s;for(;n<e.length&&!/[,\]\n]/.test(e[n]);)n++;e[n]===`,`&&t.idx++,s=n-1}}}return t}function Ze(e,t,n){let r=e;for(let e of t){if(!r)return;r=Ge(r,e,n)}return r}var Qe={200:`OK`,201:`Created`,202:`Accepted`,204:`No content`,301:`Moved`,304:`Not modified`,400:`Bad request`,401:`Unauthorized`,402:`Payment required`,403:`Forbidden`,404:`Not found`,405:`Invalid input`,409:`Conflict`,410:`Gone`,412:`Precondition failed`,422:`Invalid input`,429:`Too many requests`,500:`Server error`,502:`Bad gateway`,503:`Unavailable`},$e=e=>Qe[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),et=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,tt=new Set([`path`,`query`,`headers`,`data`]),nt=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function rt(e,t){return[e,...nt(t)].join(`.`)}function it(e){let t=nt(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&tt.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var at=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);function ot(e){let t=new Map;if(!e)return{intro:e,notes:t};let n=[];for(let r of e.split(/(?=<h[1-6][ >])/)){let e=/^<h([1-6])[^>]*>\s*<code>([^<]+)<\/code>\s*<\/h\1>/.exec(r),i=e?it(at(e[2])):void 0;if(e&&i){let n=t.get(i),a=r.slice(e[0].length);t.set(i,n?n+a:a)}else n.push(r)}return{intro:n.join(``),notes:t}}var st=60;function ct(e,t){let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function lt(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of We(e,t)){let e=q(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:ct(e,t),required:a.required,description:He(e),enum:Array.isArray(e.enum)&&e.enum.length<=10?e.enum.map(String):void 0});let s=J(e)===`array`?q(e.items,t):e;J(s)===`object`&&i.push(...lt(s,t,n+1,o))}return i}function ut({schema:e,defs:n,section:r=`data`,notes:i}){let a=lt(e,n);return a.length===0?null:t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`Field`}),t(`th`,{children:`Type`}),t(`th`,{children:`Description`})]})}),t(`tbody`,{children:[a.slice(0,st).map(e=>t(`tr`,{children:[t(`td`,{style:{paddingLeft:`${e.depth*16+8}px`},children:[t(`code`,{children:e.name.split(`.`).pop()}),e.required&&t(`span`,{class:`req`,title:`required`,children:`*`})]}),t(`td`,{children:t(`span`,{class:`chip`,children:e.type})}),t(`td`,{children:[t(`span`,{class:`doc-inline wrap`,dangerouslySetInnerHTML:{__html:Le(e.description,220)}}),i?.get(rt(r,e.name))&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(rt(r,e.name))}}),e.enum&&t(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>t(`code`,{children:e}))]})]})]})),a.length>st&&t(`tr`,{children:t(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-st,` more fields in the spec`]})})]})]})}var dt={intro:``,notes:new Map,replace:!1,found:!1};function ft(e){let[t,r]=a(),[i,s]=a(!1),c=C.docs.find(t=>t.operation===e);return n(()=>{let e=!0;return r(void 0),s(!c),c?.load().then(t=>e&&r(t)).catch(()=>{}).finally(()=>e&&s(!0)),()=>{e=!1}},[e,c]),o(()=>!c||t===void 0?{...dt,loaded:i}:{...ot(t),replace:!!c.replace,found:!0,loaded:i},[t,c,i])}var pt=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],mt=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function ht(e,t,n){return Promise.all([mt(C.operationDocs[e]?.().then(e=>e.default)),mt(C.schemas[e]?.().then(e=>e.default)),mt(C.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>mt(C.docs.find(t=>t.requestFile===e)?.load())))]).then(([e,t,r,i])=>({long:e,req:t,defs:r,saved:Object.fromEntries(n.flatMap((e,t)=>i[t]?[[e,i[t]]]:[]))}))}function gt({variant:e,html:n}){return n?t(`section`,{class:`saved-note-doc`,children:[t(`h2`,{children:[`Saved request `,t(`code`,{children:e.name})]}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:n}})]}):null}function _t({service:e,op:r,variants:i=[],onTry:o}){let s=`${e}/${r.id}`,[c,u]=a(),d=i.map(e=>e.file).join(`
|
|
17
|
-
`);n(()=>{let t=!0;return u(void 0),ht(s,e,d?d.split(`
|
|
18
|
-
`):[]).then(e=>t&&u(e)),()=>{t=!1}},[s,e,d]);let f=ft(s),p=!!c&&f.loaded,{long:m,req:h,defs:g}=c??{saved:{}},_=h?q(h,g):void 0,v=e=>_?.properties?.[e],y=v(`data`);return t(`article`,{class:`doc`,"data-op":s,children:[t(`div`,{class:`doc-intro`,children:[t(`span`,{class:`method ${r.method}`,children:r.method}),` `,t(`code`,{children:r.path}),t(`span`,{class:`spacer`}),t(`button`,{type:`button`,class:`btn primary`,onClick:()=>o(),children:`Try it`})]}),p&&t(l,{children:[!(f.found&&f.replace)&&m?.description&&t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:Ne(m.description)}}),f.intro&&t(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),i.map(e=>t(gt,{variant:e,html:c?.saved[e.file]},e.file)),pt.map(([e,n])=>v(e)?t(`section`,{children:[t(`h2`,{children:[n,` parameters`]}),t(ut,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&t(`section`,{children:[t(`h2`,{children:`Request body`}),t(ut,{schema:y,defs:g,section:`data`,notes:f.notes})]}),r.statuses.length>0&&t(`section`,{children:[t(`h2`,{children:`Responses`}),t(`ul`,{class:`statuses`,children:r.statuses.map(e=>t(`li`,{children:[t(`span`,{class:`state-badge ${et(e)}`,children:e}),` `,$e(e)]}))})]}),(m?.examples.length??0)>1&&t(`section`,{children:[t(`h2`,{children:`Examples`}),t(`ul`,{class:`examples`,children:m?.examples.map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,onClick:()=>o(e.name),children:[`▶ `,e.title]})}))})]})]})]})}var vt=c(``);function yt(e){if(e.kind===`request`){let t=e.steps.find(e=>e.response)??e.steps[0];if(!t?.response)return e.status===`error`?`The request could not be sent.`:`Done.`;let n=t.assertions.filter(e=>!e.pass).length;return`${t.response.status}, ${e.durationMs} milliseconds${n?`, ${n} check${n===1?``:`s`} failed`:``}.`}return`Flow ${e.status===`pass`?`passed`:e.status===`fail`?`failed`:`could not run`}, ${e.totals.passed} of ${e.totals.steps} steps passed.`}var bt=class extends e{state={};componentDidCatch(e){console.error(`specbook: a panel could not be drawn`,e),this.setState({error:e instanceof Error?e:Error(String(e))})}render(){let{error:e}=this.state;return e?t(`div`,{class:`panel-error`,role:`alert`,children:[t(`p`,{children:[t(`strong`,{children:`This could not be shown.`}),` The run finished, but what it returned could not be drawn.`]}),t(`pre`,{children:e.message}),t(`button`,{type:`button`,class:`btn`,onClick:()=>this.setState({error:void 0}),children:`Try drawing it again`})]}):this.props.children}},xt=0,St=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Ct({title:e,subtitle:i,flush:a,modal:c=!0,variant:u=`side`,onPrev:d,onNext:f,onClose:p,children:m}){let h=s(null),g=o(()=>`sb-panel-title-${++xt}`,[]);return n(()=>()=>{vt.value=``},[]),n(()=>{let e=h.current?.getRootNode()?.activeElement;return c&&h.current?.focus(),()=>e?.focus?.()},[c]),n(()=>{let e=h.current;if(!e||typeof matchMedia>`u`)return;let t=matchMedia(`(max-width: 820px)`),n=`input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea`,r,i=[],a=t=>{for(let n=t.parentElement;n&&n!==e;n=n.parentElement){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`)return n}return null},o=e=>{let t=a(e);if(!t)return;let n=typeof visualViewport>`u`?void 0:visualViewport,r=n?.offsetTop??0,i=n?.height??innerHeight,o=e.getBoundingClientRect().top,s=e.getAttribute(`role`)===`combobox`,c=r+i*(s?.3:.2);(o>r+i*(s?.55:.4)||o<r)&&(t.scrollTop+=o-c)},s=e=>{let s=e.target;if(!t.matches||!s.matches?.(n))return;let c=a(s),l=typeof visualViewport>`u`?void 0:visualViewport,u=s.getBoundingClientRect().top>(l?.offsetTop??0)+(l?.height??innerHeight)*.55;c&&r?.box!==c&&(s.getAttribute(`role`)!==`combobox`||u)&&(r&&(r.box.style.paddingBottom=r.was),r={box:c,was:c.style.paddingBottom},c.style.paddingBottom=`70vh`);for(let e of i)clearTimeout(e);i=[0,150,400,800].map(e=>window.setTimeout(()=>o(s),e))},c=()=>{i.push(window.setTimeout(()=>{!e.getRootNode().activeElement?.matches?.(n)&&r&&(r.box.style.paddingBottom=r.was,r=void 0)},200))};return e.addEventListener(`focusin`,s),e.addEventListener(`focusout`,c),()=>{e.removeEventListener(`focusin`,s),e.removeEventListener(`focusout`,c);for(let e of i)clearTimeout(e);r&&(r.box.style.paddingBottom=r.was)}},[]),r(()=>{let e=e=>{if(e.key===`Escape`&&p(),e.key!==`Tab`||!c||!h.current)return;let t=[...h.current.querySelectorAll(St)].filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1],i=h.current.getRootNode().activeElement;n&&r&&(e.shiftKey&&(i===n||i===h.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus()))},t=c&&h.current?h.current:window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)},[p,c]),t(l,{children:[c&&t(`button`,{type:`button`,class:`panel-backdrop`,"aria-label":`Close`,onClick:p}),t(`section`,{class:`panel ${c?``:`docked`} ${u===`popover`?`popover`:``}`,part:`panel`,"aria-labelledby":g,"aria-modal":c?!0:void 0,role:c?`dialog`:`complementary`,tabIndex:-1,ref:h,children:[t(`header`,{class:`panel-head`,part:`header`,children:[t(`div`,{class:`panel-title`,children:[t(`h2`,{id:g,children:e}),i&&t(`div`,{class:`muted small`,children:i})]}),t(`span`,{class:`spacer`}),c&&E.value.length>1&&t(`label`,{class:`row`,children:[t(`span`,{class:`muted`,children:`Environment`}),t(`select`,{value:P.value,onChange:e=>P.value=e.target.value,children:E.value.map(e=>t(`option`,{value:e,title:F.value[e],children:e}))})]}),(d||f)&&t(`span`,{class:`stepper`,children:[t(`button`,{type:`button`,class:`icon`,title:`Previous`,"aria-label":`Previous`,disabled:!d,onClick:d,children:`↑`}),t(`button`,{type:`button`,class:`icon`,title:`Next`,"aria-label":`Next`,disabled:!f,onClick:f,children:`↓`})]}),t(`button`,{type:`button`,class:`icon`,"aria-label":`Close panel`,onClick:p,children:`×`})]}),t(`div`,{class:`panel-body ${a?`flush`:``}`,children:t(bt,{children:m})}),t(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:vt.value})]})]})}function wt(e,t,n,r=[]){if(!e)return;let i=[...r,...n],a=i.length===0?e:Ze(e,i,t);if(!a)return;let o=q(a,t);if(n.length===0){let e=typeof o.description==`string`?o.description.trim():``;return e?{path:typeof o.title==`string`&&o.title.trim()?o.title.trim():`body`,type:J(o),required:!1,description:e,deprecated:o.deprecated===!0||void 0}:void 0}let s=n[n.length-1],c=Ze(e,i.slice(0,-1),t),l=J(o),u=l===`array`?J(q(o.items,t)):void 0;return{path:Ye(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&We(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:He(o),parent:c?He(q(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function Tt(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function Et(e,t,n,r){let i=e&&t?.get(rt(n,r));return e&&i?{...e,note:i}:e}var Dt={},Ot=Symbol(),kt=Symbol(),At=e=>typeof e==`string`?jt[e]:e,jt={plain:Dt,plaintext:Dt,text:Dt,txt:Dt},Mt=(e,t)=>(t[kt]||Nt)(e,t),Nt=(e,t)=>{for(var n=[e],r,i=[],a=0;r=At(t[Ot]);)delete t[Ot],Object.assign(t,r);for(Bt(e,t,n,0);i[a++]=n[0],n=n[1];);return i},Pt=(e,t,n)=>e.replace(/&/g,`&`).replace(t,n),Ft=`</span>`,It=``,Lt=``,Rt=e=>{for(var t=``,n,r=0;n=e[r++];)t+=zt(n);return t},zt=e=>{if(e instanceof Vt){var{type:t,alias:n,content:r}=e,i=It,a=Lt,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;Lt+=Ft,It+=o;var s=zt(r);return It=i,Lt=a,o+s+Ft}return typeof e==`string`?(e=Pt(e,/</g,`<`),Lt&&e.includes(`
|
|
19
|
-
`)?e.replace(/\n/g,Lt+`
|
|
20
|
-
`+It):e):Rt(e)},Bt=(e,t,n,r,i)=>{for(var a in t)if(t[a])for(var o=0,s=t[a],c,l=Array.isArray(s)?s:[s];c=l[o];o++){if(i&&i[0]==a&&i[1]==o)return;for(var u=c.pattern||c,d=At(c.inside),f=c.lookbehind,p=u.global,m=c.alias,h=n,g=r;h&&(!i||g<i[2]);g+=h[0].length,h=h[1]){var _=h[0],v=0,y;if(!(_ instanceof Vt)){if(u.lastIndex=p?g:0,y=u.exec(p?e:_),!y&&p)break;if(y&&y[0]){var b=f&&y[1]?y[1].length:0,x=y.index+b,S=y[0].slice(b),C=x+S.length,w,s;if(p){for(;s=g+h[0].length,x>=s;h=h[1],g=s);if(h[0]instanceof Vt)continue;for(w=h,s=g;(s+=w[0].length)<C;w=w[1],v++);_=e.slice(g,s),x-=g,C-=g}for(var T=_.slice(C),E=g+_.length,D=new Vt(a,d?Mt(S,d):S,S,m),O=h,k=0,A;O=O[1],k++<v;);T&&(!O||O[0]instanceof Vt?O=[T,O]:O[0]=T+O[0]),g+=x,h[0]=x?_.slice(0,x):D,x?h=h[1]=[D,O]:h[1]=O,v&&(Bt(e,t,h,g,A=[a,o,E]),E=A[2]),i&&E>i[2]&&(i[2]=E)}}}}};function Vt(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var Ht=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=Yt(),m=p.firstChild,h=m.children,g=h[0],_=g.firstChild,v={language:`text`,value:o},y=new Set(n),b={},x=e=>{Object.assign(v,e);let t=o!=(o=e.value??o),n=r!=(r=v.language);d=!!v.readOnly,p.style.tabSize=v.tabSize||2,_.inputMode=d?`none`:``,_.setAttribute(`aria-readonly`,d),w(),C(),t&&(c||_.remove(),_.value=o,_.selectionEnd=0,c||g.prepend(_)),(t||n)&&S()},S=()=>{u=Mt(o=_.value,jt[r]||{}),O(`tokenize`,u,r,o);let e=Rt(u).split(`
|
|
21
|
-
`),t=0,n=f,a=f=e.length;for(;e[t]==i[t]&&t<a;)++t;for(;a&&e[--a]==i[--n];);if(t==a&&t==n)h[t+1].innerHTML=e[t]+`
|
|
22
|
-
`;else{let r=n<t?n:t-1,i=r,o=``;for(;i<a;)o+=`<div class=pce-line aria-hidden=true>${e[++i]}\n</div>`;for(i=a<t?a:t-1;i<n;i++)h[t+1].remove();o&&h[r+1].insertAdjacentHTML(`afterend`,o),p.style.setProperty(`--number-width`,(0|Math.log10(f))+1+`.001ch`)}O(`update`,o),k(!0),l&&setTimeout(setTimeout,0,()=>l=!0),i=e,l=!1},C=e=>{(e||y).forEach(t=>{typeof t==`object`?(t.update(A,v),e&&y.add(t)):(t(A,v),e||y.delete(t))})},w=([e,t]=T())=>{p.className=`prism-code-editor language-${r}${v.lineNumbers==0?``:` show-line-numbers`} pce-${v.wordWrap?``:`no`}wrap${v.rtl?` pce-rtl`:``} pce-${e<t?`has`:`no`}-selection${c?` pce-focus`:``}${d?` pce-readonly`:``}${v.class?` `+v.class:``}`},T=()=>[_.selectionStart,_.selectionEnd,_.selectionDirection],E={Escape(){_.blur()}},D={},O=(e,...t)=>{b[e]?.forEach(e=>e.apply(A,t)),v[`on`+e[0].toUpperCase()+e.slice(1)]?.(...t,A)},k=e=>{if(e||l){let e=T(),t=h[s=qt(o,0,e[e[2]<`f`?0:1])];t!=a&&(a?.classList.remove(`active-line`),t.classList.add(`active-line`),a=t),w(e),O(`selectionChange`,e,o)}},A={container:p,wrapper:m,lines:h,textarea:_,get activeLine(){return s},get value(){return o},options:v,get focused(){return c},get tokens(){return u},inputCommandMap:D,keyCommandMap:E,extensions:{},setOptions:x,update:S,getSelection:T,addExtensions(...e){C(e)},on:(e,t)=>((b[e]||=new Set).add(t),()=>b[e].delete(t)),remove(){p.remove()}};return Y(_,`keydown`,e=>{E[e.key]?.(e,T(),o)&&X(e)}),Y(_,`beforeinput`,e=>{(d||e.inputType==`insertText`&&D[e.data]?.(e,T(),o))&&X(e)}),Y(_,`input`,S),Y(_,`blur`,()=>{Xt=null,c=!1,w()}),Y(_,`focus`,()=>{Xt=k,c=!0,w()}),Y(_,`selectionchange`,e=>{k(!e.isTrusted),X(e)}),Kt(e)?.append(p),t&&x(t),A},Ut=`u`>typeof window?document:null,Wt=Ut?.createElement(`div`),Gt=(e,t)=>(Wt&&(Wt.innerHTML=e,t=Wt.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),Kt=e=>typeof e==`string`?Ut.querySelector(e):e,qt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
|
|
23
|
-
`,t)+1)&&t<=n;r++);return r},Jt={},Yt=Gt(`<div><div class=pce-wrapper><div class=pce-overlays><textarea class=pce-textarea spellcheck=false autocapitalize=off autocomplete=off>`),X=e=>{e.preventDefault(),e.stopImmediatePropagation()},Xt;Ut&&Y(Ut,`selectionchange`,()=>Xt?.());var Zt=(e,t,n=0)=>{let r=e.container.style;r.setProperty(`--_sp`,`var(--pce-scroll-padding, 2ch)`),r.scrollPaddingBlock=`calc(var(--_sp) + ${n}px) calc(var(--_sp) + ${mn&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},Qt=(e,t)=>t?e.lastIndexOf(`
|
|
24
|
-
`,t-1)+1:0,$t=(e,t)=>(t=e.indexOf(`
|
|
25
|
-
`,t))+1?t:e.length,en=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),tn=(e,t,n,r)=>en(e.textarea,t,n,r),nn=(e,t)=>parseFloat(getComputedStyle(e)[t]),rn=(e,t)=>{let n=t.getBoundingClientRect(),r=e.lines[0].getBoundingClientRect();return{top:n.y-r.y,bottom:r.bottom-n.bottom,left:n.x-r.x,right:r.right-n.right,height:n.height}},an=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var on,sn=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),cn=(e,t)=>e.slice(Qt(e,t),t),ln=(e,t,n=t)=>[e.slice(t=Qt(e,t),n=$t(e,n)).split(`
|
|
26
|
-
`),t,n],un=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[qt(a,0,i)],s=Ut.createTreeWalker(o,5),c=s.lastChild(),l=$t(a,i)+1-i-c.length;for(;-l<=r&&(c=s.previousNode());)if(!c.lastChild&&(l-=c.length||0,l<=n)){for(;c!=o;c=c.parentNode)if(c.matches?.(t))return c}},dn=(e,t)=>un(e,`[class*=language-]`,0,0,t)?.className.match(/language-(\S*)/)[1]||e.options.language,Z=(e,t,n,r,i,a)=>{if(e.options.readOnly)return;on=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=mn&&!s[r??on[1]]&&/\n$/.test(t)&&/^$|\n$/.test(s),l;e.focused||o.focus(),n!=null&&o.setSelectionRange(n,r),i!=null&&(l=e.on(`update`,()=>{o.setSelectionRange(i,a??i,on[2]),l()})),hn||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),mn||hn?(c&&(o.selectionEnd--,t=t.slice(0,-1)),hn&&(t+=`
|
|
27
|
-
`),Ut.execCommand(t?`insertHTML`:`delete`,!1,Pt(t,/</g,`<`)),c&&o.selectionStart++):Ut.execCommand(t?`insertText`:`delete`,!1,t),on=0},fn=(e,t,n=t,r)=>{let i=e.textarea,a=en(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},pn=Ut?navigator.userAgent:``,Q=Ut?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,mn=/Chrome\//.test(pn),hn=!mn&&/AppleWebKit\//.test(pn),gn=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,_n=(e,t)=>e.lines[0].append(t),vn=Gt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),yn=Gt(`<span> `),bn=Gt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),xn=(e,t,n=!0)=>{let r=bn(),i=r.style,a=r.firstChild;return r.append(t),(n?t:a).style.flexShrink=0,[t=>{let n=e.extensions.cursor?.getPosition();if(n){r.parentNode||_n(e,r),a.style.width=(e.options.rtl?n.right:n.left)+`px`;let o=n.top,s=n.bottom,c=!t==o>s&&(t?o:s)<r.clientHeight?!t:t,l=n.height+(c?s:o)+`px`;i.bottom=c?l:`auto`,i.top=c?`auto`:l}},()=>r.remove()]};window.ResizeObserver;var Sn=(e,t,n)=>{let r=e.childNodes,i=r.length-1,a=0,o=0,s=t.length;for(;o<s;)o>=i&&r[o].before(``,yn()),an(r[o],n.slice(a,a=t[o++])),an(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();an(r[s],n.slice(a))},Cn=0,wn=Gt(`<div class="pce-ac-wrapper pce-ac-top"><div class=pce-ac-tooltip><ul role=listbox></ul></div><div class=pce-ac-docs tabindex=-1><button class=pce-ac-close tabindex=-1 title=Close></button><button class=pce-ac-toggle tabindex=-1 title="Read More"></button><div class=pce-ac-content>`),Tn=Gt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),En={},Dn=(e,t)=>{e.forEach(e=>En[e]=t)},On=e=>{let t=(n,r)=>{let i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w=n.container,T=n.textarea,E=n.getSelection,D=wn(),O=vn(),[k,A]=xn(n,D),[j,M]=D.children,[ee,te,ne]=M.children,re=j.firstChild,ie=re.id=`pce-ac-`+Cn++,N=re.children,P=[],F=()=>{i&&=(A(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&M.remove(),!1)},I=()=>{f=nn(N[0],`height`)},ae=e=>{let t=o[e+d],[n,r,i]=N[e].children,a=t[4],s=a.icon||`variable`;Sn(r,t[1],a.label),an(i.firstChild.firstChild,a.detail||``),P[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${P[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),N[e].setAttribute(`aria-posinset`,e+d)},oe=()=>{I();let e=j.scrollTop,t=f*c,n=f*(c+1)-j.clientHeight;j.scrollTop=e>t?t:e<n?n:e,ce(),L()},L=()=>{let e=l;l=N[c-d],e?.removeAttribute(`aria-selected`),e?.removeAttribute(`aria-describedby`),te.remove(),l?(T.setAttribute(`aria-activedescendant`,l.id),l.setAttribute(`aria-selected`,!0),o[c][4].renderDocs?(l.append(te),b=!b,ge()):M.remove()):e&&T.removeAttribute(`aria-activedescendant`)},se=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,oe()},ce=()=>{let e=Math.min(Math.floor(j.scrollTop/f),s-13);if(e==d||e<0)return!0;d=e;for(let e=0;e<13;)ae(e++);re.style.paddingTop=d*f+`px`},R=e=>le(o[e][4],o[e][2],o[e][3]),le=t.insertCompletion=(e,t,i=t)=>{if(r.readOnly)return;let{label:a,tabStops:o=[],insert:s}=e,c=o.length;if(o=o.map(e=>e+t),s){let e=`
|
|
28
|
-
`+cn(n.value,u).match(/\s*/)[0],i=r.insertSpaces==0?` `:` `.repeat(r.tabSize||2),a=o.slice();s=s.replace(/\n| /g,(n,r)=>{let s=n==` `?i:e,l=s.length-1,u=0;for(;u<c;)a[u]>r+t&&(o[u]+=l),u++;return s})}else s=a;c%2&&(o[c]=o[c-1]),Z(n,s,t,i,o[0],o[1]),c>2?(p||_n(n,O),p=o,m=0,g=n.value.length,fe(),h=E(),ue()):n.extensions.cursor?.scrollIntoView()},ue=()=>{O.children[m/2].scrollIntoView({block:`nearest`})},de=e=>{m+=e,fn(n,p[m],p[m+1]),ue()},z=()=>{O.remove(),p=null},fe=()=>{let e=[],t=0;for(;t<p.length;)e[t/2]=[p[t++],p[t++]];e.sort((e,t)=>e[0]-t[0]),Sn(O,e.flat(),n.value)},pe=()=>{let e=w.clientWidth,t=Math.abs(w.scrollLeft),i=n.extensions.cursor.getPosition(),a=r.rtl?i.right:i.left,o=nn(w,`fontSize`);if(e>=46*o){if(a+45.5*o<t+e)return v+`-end`;if(a-20.5*o>t)return v+`-start`}return v},me=()=>{D.className=`pce-ac-wrapper pce-ac-${pe()}`},he=()=>{let e=o[c][4];e.renderDocs&&(M.parentNode||D.append(M),y!=e&&(y=e,ne.textContent=``,ne.append(...e.renderDocs(e,x,n))),l?.setAttribute(`aria-describedby`,ie+`d`))},ge=()=>{b?M.remove():he(),b=!b},_e=t.startQuery=t=>{let[a,l,p]=E(),m=dn(n,u=p<`f`?a:l),h=En[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=cn(r,u),p=r.slice(0,u),_=e.filter;if(x={before:p,lineBefore:a,language:m,explicit:!!t,pos:u},Object.assign(x,h.context?.(x,n)),o=[],h.sources.forEach(e=>{let t=e(x,n),r=t?.from;t?.options.forEach(e=>{let n=_(p.slice(e.from??r),e.label);n&&(n[0]+=e.boost||0,n.push(r,t.to??l,e),o.push(n))})}),o[0]){o.sort((e,t)=>t[0]-e[0]||e[4].label.localeCompare(t[4].label)),s=o.length,c=d=0;for(let e=0,t=s<13?s:13;e<t;)N[e].setAttribute(`aria-setsize`,s),ae(e++);if(!i){let{clientHeight:e,clientWidth:t}=w,n=g.getPosition(),r=Math.max(n.bottom,n.top);M.style.maxWidth=j.style.width=`min(25em, ${t}px - var(--padding-left) - 1em)`,D.style.maxHeight=`min(${r}px + .25em, ${e}px - 2em)`}re.style.paddingTop=``,re.style.height=f?f*s+`px`:1.4*s+`em`,j.scrollTop=0,L(),i=!0,k(e.preferAbove),v=D.parentElement.style.top==`auto`?`top`:`bottom`,me(),T.setAttribute(`aria-controls`,ie),T.setAttribute(`aria-haspopup`,`listbox`)}else F()}else F()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)re.append(Tn()),N[e].id=ie+`-`+e++;Y(j,`scroll`,()=>{I(),ce()||L()}),n.on(`update`,()=>{if(p){let e=n.value,t=g-(g=e.length),[r,i]=h,a=0,o=p.length,s=p[m],c=p[m+1];if(r<p[m]||i>c)z();else{for(_&&i++,i<=c&&(p[m+1]-=t),i<=s&&t>0&&(p[m]-=t);a<o;a+=2)a!=m&&p[a]>=c&&(p[a]=Math.max(p[a]-t,p[m+1]),p[a+1]=Math.max(p[a+1]-t,p[m+1]));fe()}_=!1,h=E()}}),n.on(`selectionChange`,([e,t])=>{if(p){if(e<p[m]||t>p[m+1]){for(let n=0;n<p.length;n+=2)if(e>=p[n]&&t<=p[n+1]){m=n;break}}(m+3>p.length||e<p[m]||t>p[m+1])&&z()}a?(a=!1,_e()):(S!=e||C!=t)&&F(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!on&&l&&!l[1]&&o[c][4].commitChars?.includes(l)&&R(c),p&&(h=E(),_=r&&n[13]==`F`&&h[0]==h[1]),a=!e.explicitOnly&&(a||s&&!on||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&F()}),Y(T,`keydown`,e=>{let t=e.key,n=gn(e),r,a,o;n==2&&t==` `||n==(Q?4:2)&&t==`i`||Q&&!i&&n==1&&t==`Escape`?(i?ge():_e(!0),X(e)):i?n||(/^Arrow[UD]/.test(t)?(se(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(R(c),F(),X(e)):t==`Escape`?(F(),X(e)):t.slice(0,4)==`Page`&&(I(),r=j.scrollTop,a=j.clientHeight,t[4]==`U`?(o=Math.ceil(r/f),c=c==o||o-1==c?Math.ceil(Math.max(0,(r-a)/f+1)):o):(r+=a+1,o=Math.ceil(r/f-2),c=c==o||o+1==c?Math.ceil(Math.min(s-1,(r+a)/f-3)):o),oe(),X(e))):p&&(!(n&7)&&t==`Tab`?n?m&&(de(-2),X(e)):(de(2),X(e)):!n&&t==`Escape`&&(z(),X(e)))},!0),Y(re,`mousedown`,e=>{e.target!=te&&(R([].indexOf.call(N,e.target.closest(`li`))+d),F()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&F()}),Y(w,`scroll`,()=>{i&&me()}),Y(ee,`click`,ge),Y(ee,`mousedown`,X),Y(te,`click`,ge),M.id=ie+`d`,te.remove(),M.remove(),n.extensions.autoComplete=t};return t.startQuery=t.insertCompletion=()=>{},t},kn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return An(e,t);let i=e.toLowerCase(),a=t.toLowerCase(),o=[],s=a.indexOf(i),c=0,l=0,u=0,d=0;for(;l<r;){let n=s>-1?l+s:a.indexOf(i[l],u),r=n>u;if(n<0)return;r&&(c-=800),(r||!d)&&(o[d]=n,d+=2),o[d-1]=u=n+1,e[l++]!=t[n]&&(c-=100)}return[r<n?c-100:c,o]},An=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;let i=t.slice(0,r),a=i==e?0:e.toLowerCase()==i.toLowerCase()?-200:null;if(a!=null)return[e?r<n?a-100:a:0,[0,r]]},jn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||Vn[e]||0;return t+`+`+r},Mn=e=>{if(!zn[48]){for(let e=48;e<91;e++)zn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)zn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=gn(e),r=zn[e.keyCode],i=Bn[e.keyCode],a=n>7,o=(Q&&n==12||t==`Dead`||t==`Unidentified`)&&(a&&i||r)||t.toLowerCase(),s=/\w\w| /.test(o.slice(0,2)),c=n&7,l=new Set([`${s||/\p{L}/u.test(o)?n:c}+${o}`]);return s||(c&&!(Q&&c==1)&&r?(l.add(n+`+`+r),a&&i&&l.add(c+`+`+i)):a&&l.add(n+`+`+o)),l},Nn=new WeakMap,Pn=(e,t,n)=>{let r=new Set,i;try{for(let a of Mn(e)){i||=a;for(let i of t[a]||[])for(let t of i||[])if(!r.has(t)){if(t(n,e,a))return X(e),!0;r.add(t)}}}finally{t.any?.forEach(t=>t?.forEach(t=>t(n,e,i)))}},Fn=e=>{let t=Nn.get(e);return t||(Nn.set(e,t={}),tn(e,`keydown`,n=>{Pn(n,t,e)})),t},In=(e,t,n,r)=>Ln(Fn(e),t,n,r),Ln=(e,t,n,r=2)=>{let i=(e[t==`any`?t:jn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},Rn=Q?4:2,zn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Bn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Vn={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},Hn=!1,Un=e=>e.search(/\S|$/),Wn=({options:{insertSpaces:e=!0,tabSize:t}})=>[e?` `:` `,e?t||2:1],$=e=>!e.options.readOnly&&!e.extensions.cursor?.scrollIntoView(),Gn=(e,t,n,r,i,a,o)=>{let s=n.join(`
|
|
29
|
-
`);if(s==t.join(`
|
|
30
|
-
`))return;let c=t.length-1,l=n[c],u=t[c],d=u.length-l.length,f=n[0].length-t[0].length,p=r+Un((f<0?n:t)[0]),m=i-u.length+Un(d>0?l:u),h=r-i+s.length+d,g=p>a?a:Math.max(p,a+f),_=o+r-i+s.length;Z(e,s,r,i,g,o<m?_+d:Math.max(m+h,_))},Kn=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=ln(e.value,n,r),[s,c]=Wn(e);return Gn(e,i,i.map(t?e=>e.slice(Un(e)?c-Un(e)%c:0):e=>e&&s.repeat(c-Un(e)%c)+e),a,o,n,r),$(e)},qn=(e,t)=>{let[n,r]=Wn(e);return Z(e,n.repeat(r-(t-Qt(e.value,t))%r)),$(e)},Jn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=$t(r,n[1]));let[i,a]=Wn(e),[o,s]=n,c=Jt[dn(e,o)]?.autoIndent,l=Math.floor(Un(cn(r,o))/a)*a,u=c?.[0]?.(n,r,e)?a:0,d=c?.[1]?.(n,r,e),f=`
|
|
31
|
-
`+i.repeat(l+u)+(d?`
|
|
32
|
-
`+i.repeat(l):``);if(f[1]||r[s])return Z(e,f,o,s,o+l+u+1),$(e)},Yn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?Qt(i,n)-1:n,o=t?r:i.indexOf(`
|
|
33
|
-
`,r)+1;if(a>-1&&o>0){let[s,c,l]=ln(i,a,o),u=s[t?`shift`:`pop`](),d=(u.length+1)*(t?-1:1);s[t?`push`:`unshift`](u),Z(e,s.join(`
|
|
34
|
-
`),c,l,n+d,r+d)}return $(e)},Xn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=ln(i,n,r),c=a.join(`
|
|
35
|
-
`),l=t?0:c.length+1;return Z(e,c+`
|
|
36
|
-
`+c,o,s,n+l,r+l),$(e)},Zn=(e,t)=>(e.container.scrollBy(0,nn(e.container,`lineHeight`)*(t?-1:1)),!0),Qn=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=ln(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=$t(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},$n=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:Qt(i,n),o=Jt[dn(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=ln(i,n,r),f=l.length-1;if(t){if(c){let[t,a]=c,o=i.slice(n,r),s=i.slice(0,n).search(sn(t)+` ?$`);s+1&&RegExp(`^ ?`+sn(a)).test(i.slice(r))?Z(e,o,s,r+(i[r]==` `)+a.length,s,s+r-n):Z(e,`${t} ${o} ${a}`,n,r,n+t.length+1,r+t.length+1)}}else if(s){let t=sn(s),a=RegExp(`^\\s*(${t} ?|$)`),o=RegExp(t+` ?`),c=!/\S/.test(i.slice(u,d));Gn(e,l,l.map(!c&&l.every(e=>a.test(e))?e=>e.replace(o,``):e=>c||/\S/.test(e)?e.replace(/(?!\s)/,s+` `):e),u,d,n,r)}else if(c){let[t,i]=c,a=l[0],o=Un(a),s=a.startsWith(t,o)&&l[f].endsWith(i);l[0]=a.replace(s?RegExp(sn(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${sn(i)}$`),``):l[f]+` `+i;let m=l.join(`
|
|
37
|
-
`),h=o+u,g=h>n?n:Math.max(n+p,h),_=h>r-(n!=r)?r:Math.min(Math.max(h,r+p),u+m.length);Z(e,m,u,d,g,Math.max(g,_))}return c||s&&!t?$(e):!1},er={Tab(e){if(!Hn){let[t,n]=e.getSelection();return t==n?qn(e,t):Kn(e)}},"8+Tab":e=>!Hn&&Kn(e,!0),"1+ArrowDown":e=>Yn(e),"1+ArrowUp":e=>Yn(e,!0),"9+ArrowDown":e=>Xn(e),"9+ArrowUp":e=>Xn(e,!0),Enter:e=>Jn(e),"8+Enter":e=>Jn(e),"Mod+Enter":e=>Jn(e,!0),"Mod+]":e=>Kn(e),"Mod+[":e=>Kn(e,!0),"8+Mod+k":Qn,"Mod+/":e=>$n(e),"9+a":e=>$n(e,!0),[Q?`10+m`:`2+m`]:()=>(Hn=!Hn,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>Zn(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>Zn(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var tr=Q?5:1;tr+``,tr+``,tr+``,tr+``;var nr=(e,t=[`""`,`''`,"``",`()`,`[]`,`{}`],n=/([^$\w'"`]["'`]|.[[({])[.,:;\])}>\s]|.[[({]`/s)=>(r,i)=>{let a,o=r.inputCommandMap,s=navigator.clipboard,c=([e,t],[i,a],o,s)=>(e<t||!s&&n.test((o[t-1]||` `)+i+(o[t]||` `)))&&!Z(r,i+o.slice(e,t)+a,null,null,e+1,t+1),l=([e,t],n,i)=>e==t&&i[t]==n&&!fn(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=cn(a,e),s=i.tabSize||2,c=t.includes(a.slice(e-1,e+1)),l=/[^ ]/.test(o)?0:(o.length-1)%s+1;if((c||l>1)&&e==n)return Z(r,``,e-(c?1:l),e+c),$(r)}};o[`<`]=(e,t,n)=>c(t,`<>`,n,!0),t.forEach(([e,t])=>{let n=e==t;o[e]=(i,a,o)=>(n&&l(a,t,o)||c(a,e+t,o))&&$(r),n||(o[t]=(e,n,i)=>l(n,t,i)&&$(r))}),o[`>`]=(e,t,n)=>{let i=Jt[dn(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},In(r,`Backspace`,u),In(r,`8+Backspace`,u);for(let t in e)In(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>tn(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=ln(r.value,n,i);e==`paste`?t.clipboardData.getData(`text/plain`)==a&&(Z(r,a+`
|
|
38
|
-
`,c,c,n+a.length+1),$(r),X(t)):(s.writeText(a=o),e==`cut`&&(Z(r,``,c,l+1),$(r)),X(t))}}))},rr=(e=999)=>{let t=0,n,r,i=!1,a,o,s,c,l,u,d=[],f=r=>{r>=e&&(r--,d.shift()),d.splice(t=r,e,[n.value,u(),u()])},p=e=>{d[e]&&(l.value=d[e][0],l.setSelectionRange(...d[e][e<t?2:1]),n.update(),n.extensions.cursor?.scrollIntoView(),t=e,r=!1)},m=(e,g)=>{e.extensions.history=m,n=e,u=e.getSelection,l||f(0),l=e.textarea,e.on(`selectionChange`,()=>{r=i,i=!1}),tn(e,`beforeinput`,e=>{let n=e.data,l=e.inputType,f=e.timeStamp;/history/.test(l)?(p(t+(l[7]==`U`?-1:1)),X(e)):(c=r&&(a==l||f-s<99&&l.slice(-4)==`Drop`)&&!on&&(n!=` `||o==n))||(d[t][2]=on||u()),i=!0,o=n,s=f,a=l}),tn(e,`input`,()=>f(t+!c)),tn(e,`keydown`,e=>{if(!g.readOnly){let n=gn(e),r=e.keyCode,i=n==Rn&&r==90,a=n==Rn+8&&r==90||!Q&&n==Rn&&r==89;i?(p(t-1),X(e)):a&&(p(t+1),X(e))}}),e.addExtensions({update(){e.value!=l.value&&h()}})},h=m.clear=()=>{f(0),r=!1};return m.has=e=>t+e in d,m.go=e=>p(t+e),m},ir=Gt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),ar=()=>{let e,t=ir(),[n,r]=t.childNodes,[i,a]=r.childNodes,o=()=>{let r=e.getSelection(),i=e.value,o=e.lines[e.activeLine],s=r[r[2]<`f`?0:1];an(n,cn(i,s)),an(a,i.slice(s,$t(i,s))+`
|
|
39
|
-
`),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),Zt(e,i)},c=t=>{e=t,t.extensions.cursor=c,tn(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),rn(e,i)),c.scrollIntoView=s,c.element=i,c};Gt(`<div class=pce-cursor>`);var or=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,sr=/\b(?:false|true)\b/,cr=/\[]|\(\)|{}/,lr=/[([{][^)\]}]*$/,ur=([e,t],n)=>cr.test(n[e-1]+n[t]),dr={line:`//`,block:[`/*`,`*/`]},fr=(e=dr,t=lr)=>({comments:e,autoIndent:[([e],n)=>t.test(cn(n,e)),ur]});Jt.json=Jt.json5=Jt.jsonp=fr(),Jt.graphql=fr({line:`#`}),jt.webmanifest=jt.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:or,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:sr,null:{pattern:/\bnull\b/,alias:`keyword`}},jt.graphql={comment:/#.*/,description:{pattern:/(?:"""(?:[^"]|"(?!""))*"""|"(?:\\.|[^\\\n"])*")(?=\s*[a-z_])/gi,alias:`string`,inside:{"language-markdown":{pattern:/("(?!")|""")[^]+(?=\1)/,lookbehind:!0,inside:`md`}}},string:/"""[^]*?"""|"(?:\\.|[^\\\n"])*"/g,number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:sr,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:`function`},"attr-name":/\b[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\\n"])*")*\))?:)/gi,"atom-input":{pattern:/\b[A-Z]\w*Input\b/,alias:`class-name`},scalar:/\b(?:Boolean|Float|ID|Int|String)\b/,constant:/\b[A-Z][A-Z_\d]*\b/,"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*|:\s*|\[)[A-Z_]\w*/,lookbehind:!0},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))(?!\d)\w+/,lookbehind:!0,alias:`function`},"definition-mutation":{pattern:/(\bmutation\s+)(?!\d)\w+/,lookbehind:!0,alias:`function`},"definition-query":{pattern:/(\bquery\s+)(?!\d)\w+/,lookbehind:!0,alias:`function`},keyword:/\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,operator:/[&|!=]|\.{3}/,"property-query":/\w+(?=\s*\()/,object:/\w+(?=\s*\{)/,punctuation:/[()[\]{},:!=]/,property:/\w+/,[kt](e,t){for(var n=Nt(e,t),r=n.filter(({type:e})=>e&&e!=`comment`&&e!=`scalar`),i=r.length,a=0,o=e=>{for(var t=0;t<e.length;t++)if(a+t==i||r[a+t].type!=e[t])return!0},s=(e,t)=>{for(var n=1,o=a;o<i;o++){var s=r[o],c=s.content;if(s.type==`punctuation`){if(e==c)n++;else if(t==c&&!--n)return o}}};a<i;){var c=r[a++];if(c.type==`keyword`&&c.content==`mutation`){var l=[];if(!o([`definition-mutation`,`punctuation`])&&r[a+1].content==`(`){a+=2;var u=s(`(`,`)`);if(!u)continue;for(;a<u;a++){var d=r[a];d.type==`variable`&&(d.alias=`variable-input`,l.push(d.content))}a=u+1}if(!o([`punctuation`,`property-query`])&&r[a].content==`{`&&(r[++a].alias=`property-mutation`,l[0])){var f=s(`{`,`}`);if(f)for(var p=a;p<f;p++){var m=r[p];m.type==`variable`&&l.indexOf(m.content)>=0&&(m.alias=`variable-input`)}}}}return n}};var pr=new WeakMap;Dn([`json`],{sources:[(e,t)=>{let n=pr.get(t)?.(t.value,e.pos);return n?{from:n.from,to:n.to,options:n.options.map(e=>({...e,renderDocs:e.doc?()=>[e.doc]:void 0}))}:null}]});function mr({value:e,language:r=`json`,readOnly:i,label:a,onChange:o,onLine:c,complete:l}){let u=s(null),d=s(void 0),f=s({onChange:o,onLine:c});f.current={onChange:o,onLine:c};let p=s(l);return p.current=l,n(()=>{let t=Ht(u.current,{value:e,language:r,readOnly:i,lineNumbers:!1,wordWrap:!0,onUpdate:e=>f.current.onChange?.(e),onSelectionChange:(e,t,n)=>f.current.onLine?.(n.activeLine-1)},nr(er),rr(),...l?[ar(),On({filter:kn})]:[]);return l&&pr.set(t,(e,t)=>p.current?.(e,t)),t.textarea.setAttribute(`aria-label`,a),d.current=t,()=>t.remove()},[]),n(()=>{let t=d.current;t&&t.value!==e&&t.setOptions({value:e})},[e]),n(()=>{d.current?.setOptions({readOnly:i,language:r})},[i,r]),t(`div`,{class:`body-editor`,part:`editor`,ref:u})}var hr=/[\w$.+-]/;function gr(e,t){let n=[],r=()=>n[n.length-1],i=0;for(;i<t;){let a=e[i];if(a===`"`){let n=i+1,a=``;for(;n<e.length&&e[n]!==`"`&&e[n]!==`
|
|
40
|
-
`;)e[n]===`\\`?(a+=e[n+1]??``,n+=2):a+=e[n++];let o=e[n]===`"`,s=r();if(t<=n||!o&&t<=e.length&&n>=t){let r=s?.t===`o`&&s.expectKey,a=o?n+1:t,l=a;for(;/\s/.test(e[l]??``);)l++;return c({mode:r?`key`:`value`,from:i,to:a,inString:!0,prefix:e.slice(i+1,t),hasColon:e[l]===`:`})}s?.t===`o`&&s.expectKey&&(s.key=a,s.keys.add(a),s.expectKey=!1),i=n+1}else{if(a===`{`)n.push({t:`o`,expectKey:!0,keys:new Set});else if(a===`[`)n.push({t:`a`,index:0});else if(a===`}`||a===`]`)n.pop();else if(a===`,`){let e=r();e?.t===`o`?(e.expectKey=!0,e.key=void 0):e?.t===`a`&&e.index++}i++}}let a=t;for(;a>0&&hr.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&hr.test(e[o]??``);)o++;let s=r();return c({mode:s?.t===`o`&&s.expectKey?`key`:`value`,from:a,to:o,inString:!1,prefix:e.slice(a,t),hasColon:!1});function c(e){if(n.length===0)return;let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=r===n.length-1;if(i.t===`o`){if(a&&e.mode===`key`)break;if(i.key===void 0)return;t.push(i.key)}else t.push(i.index)}let i=r();return{...e,path:t,existing:i?.t===`o`?i.keys:new Set}}}var _r=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),vr=(e,t)=>{let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function yr(e){let t=J(e);return t===`object`?{text:`{}`,stop:1}:t===`array`?{text:`[]`,stop:1}:t===`boolean`?{text:`false`,stop:5}:t===`number`||t===`integer`?{text:`0`,stop:1}:{text:`""`,stop:1}}function br(e,t,n,r,i){if(!e)return;let a=gr(r,i);if(!a)return;let o=Ze(e,[...n,...a.path],t);if(!o)return;let s=q(o,t);if(a.mode===`key`){if(J(s)!==`object`&&!s.properties)return;let e=We(s,t).filter(e=>!a.existing.has(e.name));if(e.length===0)return;let n=e.map(e=>{let n=q(e.schema,t),r=yr(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${vr(n,t)}${e.required?` · required`:``}`,icon:n.deprecated?`text`:`property`,insert:s,tabStops:a.hasColon?void 0:[o.length+r.stop],boost:e.required?10:0,from:a.inString?a.from+1:void 0,doc:_r(Ue(He(n),400))}});return{from:a.from,to:a.to,options:n}}let c=[],l=(e,t)=>{let n=JSON.stringify(e);c.push({label:typeof e==`string`?e:n,insert:n,icon:`enum`,detail:t,from:a.inString?a.from+1:void 0})};if(Array.isArray(s.enum))for(let e of s.enum)l(e);else if(J(s)===`boolean`)l(!0),l(!1);else return;return s.nullable===!0&&l(null,`null`),{from:a.from,to:a.to,options:c}}var xr=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function Sr(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:fe(e.path),query:fe(e.query),headers:fe(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?me(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var Cr=e=>Object.keys(e).length?e:void 0;function wr(e,t){let n;if(xr(e,t))n=_e(e.fields);else if(t===`binary`){let t=e.fields.find(e=>e.enabled);n=t?.file??t?.value}else if(e.body.trim()!==``){if(t===`text`)n=e.body;else try{n=JSON.parse(e.body)}catch(e){throw Error(`Invalid JSON: ${e.message}`)}}return{path:Cr(pe(e.path)),query:Cr(pe(e.query)),headers:Cr(pe(e.headers)),data:n}}var Tr=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function Er(e,t,n,r=``){let i=e=>e.includes(`{{`)?e:encodeURIComponent(e),a=e.replace(/\{([^}]+)\}/g,(e,n)=>{let r=t.find(e=>e.key===n&&e.enabled&&e.value!==``);return r?i(r.value):e}),o=n.filter(e=>e.enabled&&e.key!==``).map(e=>`${i(e.key)}=${i(e.value)}`).join(`&`);return`${r.replace(/\/+$/,``)}${a}${o?`?${o}`:``}`}function Dr({doc:e,hint:n}){return e?t(`div`,{class:`field-doc`,part:`field-doc`,"aria-live":`polite`,children:[t(`div`,{class:`field-doc-head`,children:[t(`code`,{children:e.path}),t(`span`,{class:`chip`,children:e.type}),e.required&&t(`span`,{class:`chip req`,children:`required`}),e.deprecated&&t(`span`,{class:`chip warn`,children:`deprecated`})]}),e.description?t(`div`,{class:`field-doc-text`,dangerouslySetInnerHTML:{__html:Ne(e.description)}}):e.note?null:t(`p`,{class:`muted`,children:[`The spec has no description for this field.`,e.parent&&t(l,{children:[` It is part of: `,e.parent]})]}),e.note&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:e.note}}),e.enum&&t(`p`,{class:`field-doc-enum`,children:[e.enum.slice(0,12).map(e=>t(`code`,{children:e})),e.enum.length>12&&t(`span`,{class:`muted`,children:[`+`,e.enum.length-12,` more`]})]})]}):t(`div`,{class:`field-doc empty`,part:`field-doc`,"aria-live":`polite`,children:n??`Put the cursor on a field to see what the API says about it.`})}function Or(e){try{let{query:t,variables:n,...r}=JSON.parse(e);return typeof t==`string`?{query:t,variables:n===void 0?``:JSON.stringify(n,null,2),rest:r}:void 0}catch{return}}function kr(e){let t;try{t=e.variables.trim()?JSON.parse(e.variables):void 0}catch{t=e.variables}return JSON.stringify({query:e.query,variables:t,...e.rest},null,2)}function Ar({value:e,options:r,onChange:i,label:o,placeholder:c,onKeyDown:l,cell:u,readOnly:d}){let[f,p]=a(!1),[m,h]=a(-1),[g,_]=a(),v=s(null),y=()=>{let e=v.current,t=e?.getBoundingClientRect();if(!e||!t)return;let n=document.createElement(`div`);n.style.cssText=`position:fixed;inset:0;visibility:hidden;pointer-events:none`,e.append(n);let r=n.getBoundingClientRect();n.remove();let i=innerHeight-t.bottom-8,a=i<160&&t.top>i;_({left:`${t.left-r.left}px`,width:`${Math.max(t.width,160)}px`,maxHeight:`${Math.min(240,(a?t.top:i)-4)}px`,...a?{bottom:`${r.bottom-t.top+2}px`}:{top:`${t.bottom+2-r.top}px`}})};n(()=>{if(!f){_(void 0);return}y();let e=e=>{if(e.target instanceof Node&&v.current?.contains(e.target))return;let t=v.current?.getBoundingClientRect();!t||t.bottom<0||t.top>innerHeight?p(!1):y()},t=()=>p(!1);return addEventListener(`scroll`,e,!0),addEventListener(`resize`,t),()=>{removeEventListener(`scroll`,e,!0),removeEventListener(`resize`,t)}},[f]),n(()=>{if(!f)return;let e=e=>{e.composedPath().includes(v.current)||p(!1)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[f]);let b=e=>{i(e),p(!1),h(-1)};return t(`div`,{class:`combo`,ref:v,children:[t(`input`,{class:`cell`,"data-cell":u,value:e,placeholder:c,"aria-label":o,"aria-expanded":f,role:`combobox`,autocomplete:`off`,readOnly:d,onFocus:()=>!d&&p(!0),onInput:e=>i(e.target.value),onKeyDown:e=>{f&&e.key===`ArrowDown`?(e.preventDefault(),h((m+1)%r.length)):f&&e.key===`ArrowUp`?(e.preventDefault(),h((m-1+r.length)%r.length)):f&&e.key===`Enter`&&m>=0?(e.preventDefault(),b(r[m])):e.key===`Escape`&&f?(e.stopPropagation(),p(!1)):((e.key===`Enter`||e.key===`Tab`)&&p(!1),l?.(e))}}),t(`button`,{type:`button`,class:`combo-toggle`,tabIndex:-1,"aria-label":`Show ${o} options`,disabled:d,onClick:()=>p(!f),children:`▾`}),f&&t(`div`,{class:`combo-list`,role:`listbox`,style:g??{top:`0px`,left:`0px`,visibility:`hidden`},children:r.map((n,r)=>t(`button`,{type:`button`,role:`option`,"aria-selected":n===e,class:`${n===e?`on`:``} ${r===m?`at`:``}`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(n),children:n}))})]})}var jr=`specbook:grid-cols`,Mr={key:26,val:34},Nr=10,Pr=c(Fr());function Fr(){try{let e=JSON.parse(L.local.getItem(jr)??`null`);if(e&&e.key>=Nr&&e.val>=Nr&&e.key+e.val<=90)return e}catch{}return Mr}function Ir(e){let t=e??Mr,n=Math.min(80,Math.max(Nr,t.key)),r=Math.min(100-n-Nr,Math.max(Nr,t.val));Pr.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?L.local.setItem(jr,JSON.stringify(Pr.value)):L.local.removeItem(jr)}catch{}}function Lr(){return t(`colgroup`,{children:[t(`col`,{style:{width:`36px`}}),t(`col`,{style:{width:`${Pr.value.key}%`}}),t(`col`,{style:{width:`${Pr.value.val}%`}}),t(`col`,{}),t(`col`,{style:{width:`60px`}})]})}function Rr({which:e,table:n}){let r=t=>{let n=Pr.value;Ir(e===`key`?{key:n.key+t,val:n.val-t}:{key:n.key,val:n.val+t})};return t(`span`,{class:`col-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${e===`key`?`Key`:`Value`} column`,"aria-valuenow":Math.round(Pr.value[e]),"aria-valuemin":Nr,"aria-valuemax":80,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault();let t=n()?.getBoundingClientRect().width??1,i=e.clientX;document.body.classList.add(`resizing`);let a=e=>{r((e.clientX-i)/t*100),i=e.clientX},o=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,a),removeEventListener(`pointerup`,o)};addEventListener(`pointermove`,a),addEventListener(`pointerup`,o)},onDblClick:()=>Ir(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),r(e.key===`ArrowLeft`?-2:2))}})}var zr=1,Br=2;function Vr(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.search(/[=\t]|:\s/);return t<0?{key:e,value:``}:{key:e.slice(0,t).trim(),value:e.slice(t+1).trim()}})}var Hr=({d:e})=>t(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{d:e,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function Ur({title:e,rows:r,onChange:i,documented:a=[],docFor:o,fixed:c,bad:u,placeholder:d,bare:f,readOnly:p}){let m=s(null),h=s(null),g=s(void 0),_=new Set(r.map(e=>e.key)),v=a.filter(e=>!_.has(e.name)).map(e=>({key:e.name,value:``,enabled:!1,virtual:!0})),y=[...r,...v],b=e=>a.find(t=>t.name===e),x=e=>b(e)?.doc??o?.(e);n(()=>{if(!g.current)return;let e=m.current?.querySelector(`[data-cell="${g.current}"]`);g.current=void 0,e&&(e.focus(),e.setSelectionRange?.(e.value.length,e.value.length))});let S=e=>!e.virtual||e.enabled||e.value!==``||e.file,C=e=>i(e.filter(S).map(({virtual:e,...t})=>t)),w=(e,t)=>C(y.map((n,r)=>r===e?{...n,...t}:n)),T=(e,t)=>m.current?.querySelector(`[data-cell="${e}:${t}"]`)?.focus(),E=(e,t)=>n=>{n.key===`Enter`||n.key===`ArrowDown`?(n.preventDefault(),T(e+(n.shiftKey?-1:1),t)):n.key===`ArrowUp`&&(n.preventDefault(),T(e-1,t))},D=e=>{let t=y[e],n=x(t.key)?.enum??[],r=new Set(y.filter(e=>e.key===t.key).map(e=>e.value)),i=n.find(e=>!r.has(e))??``,a={key:t.key,value:i,enabled:!0},o=[...y];o.splice(e+1,0,a),g.current=`${o.filter(S).indexOf(a)}:${Br}`,C(o)},O=(e,t)=>{let n=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(n.trim()))return;e.preventDefault();let a=Vr(n).map(e=>({...e,enabled:!0})),o=[...r];o.splice(t,+(t<r.length&&!r[t]?.key),...a),i(o)},k=y.length;return t(`section`,{class:`grid`,"aria-label":e,ref:m,children:[!f&&t(`h3`,{children:e}),t(`table`,{ref:h,children:[t(Lr,{}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-check`}),t(`th`,{class:`g-key`,children:[`Key`,t(Rr,{which:`key`,table:()=>h.current})]}),t(`th`,{class:`g-val`,children:[`Value`,t(Rr,{which:`val`,table:()=>h.current})]}),t(`th`,{class:`g-doc`,children:`Description`}),t(`th`,{class:`g-act`})]})}),t(`tbody`,{children:[y.map((e,n)=>{let r=x(e.key),i=b(e.key)?.file,a=c||p||e.virtual||b(e.key);return t(`tr`,{class:`${e.enabled?``:`off`} ${u===e.key?`bad`:``}`,children:[t(`td`,{class:`g-check`,children:t(`input`,{type:`checkbox`,"aria-label":`Send ${e.key}`,checked:e.enabled,disabled:c||p,onChange:e=>w(n,{enabled:e.target.checked})})}),t(`td`,{class:`g-key`,children:a?t(`span`,{class:`key`,children:[t(`code`,{children:e.key}),r?.required&&t(`span`,{class:`req`,title:`required`,children:`*`})]}):t(`input`,{class:`cell`,"data-cell":`${n}:${zr}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>w(n,{key:e.target.value}),onKeyDown:E(n,zr),onPaste:e=>O(e,n)})}),t(`td`,{class:`g-val`,children:i?t(`label`,{class:`file-cell`,children:[t(`input`,{type:`file`,disabled:p,"aria-label":`File for ${e.key}`,onChange:e=>{let t=e.target.files?.[0];t&&w(n,{file:t,value:t.name,enabled:!0})}}),t(`span`,{class:e.value?``:`muted`,children:e.value||`Choose a file…`})]}):r?.enum?t(Ar,{value:e.value,options:r.enum.map(String),label:e.key,cell:`${n}:${Br}`,readOnly:p,placeholder:`value`,onKeyDown:E(n,Br),onChange:e=>w(n,{value:e,enabled:!0})}):t(`input`,{class:`cell`,"data-cell":`${n}:${Br}`,value:e.value,readOnly:p,placeholder:d??`value`,"aria-label":`Value of ${e.key}`,onInput:e=>w(n,{value:e.target.value,enabled:!0}),onKeyDown:E(n,Br)})}),t(`td`,{class:`g-doc`,title:Pe(r?.description),children:r&&t(l,{children:[t(`span`,{class:`chip`,children:r.type}),` `,t(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:Le(r.description)}})]})}),t(`td`,{class:`g-act`,children:[!c&&!p&&e.key&&t(`button`,{type:`button`,class:`icon`,title:`Repeat this key with another value`,"aria-label":`Repeat ${e.key}`,onClick:()=>D(n),children:t(Hr,{d:`M5.5 5.5h7v7h-7zM3.5 10.5v-7h7`})}),!c&&!p&&!e.virtual&&t(`button`,{type:`button`,class:`icon`,title:`Remove`,"aria-label":`Remove ${e.key}`,onClick:()=>C(y.filter((e,t)=>t!==n)),children:t(Hr,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`})})]})]},n)}),!c&&!p&&t(`tr`,{class:`ghost`,children:[t(`td`,{class:`g-check`}),t(`td`,{class:`g-key`,children:t(`input`,{class:`cell`,"data-cell":`${k}:${zr}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{g.current=`${r.length}:${zr}`,i([...r,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:E(k,zr),onPaste:e=>O(e,r.length)})}),t(`td`,{class:`g-val`}),t(`td`,{class:`g-doc`}),t(`td`,{class:`g-act`})]},k)]})]})]})}function Wr({draft:e,onChange:r,readOnly:i}){let[o,c]=a(()=>Or(e.body)),l=s(e.body);n(()=>{if(e.body===l.current)return;let t=Or(e.body);t&&c(t),l.current=e.body},[e.body]);let u=t=>{let n={...o,...t};c(n),l.current=kr(n),r({...e,body:l.current})};return t(`section`,{class:`body`,"aria-label":`Body`,children:[t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Query`}),t(`span`,{class:`chip`,children:`graphql`})]}),t(mr,{readOnly:i,label:`GraphQL query`,language:`graphql`,value:o.query,onChange:e=>u({query:e})}),t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Variables`}),t(`span`,{class:`chip`,children:`json`})]}),t(mr,{readOnly:i,label:`GraphQL variables`,language:`json`,value:o.variables,onChange:e=>u({variables:e})})]})}var Gr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function Kr({encoding:e,draft:n,onChange:r,schema:i,defs:s,files:c=[],notes:u,readOnly:d}){let[f,p]=a(0),m=o(()=>Xe(n.body),[n.body]),h=e===`json`||e===`form`,g=o(()=>{let e=m[f];return e&&h?Et(wt(i,s,e,[`data`]),u,`data`,Ye(e)):void 0},[m,f,i,s,h,u]),_=o(()=>h&&i?(e,t)=>br(i,s,[`data`],e,t):void 0,[i,s,h]),v=e=>{if(e!==(n.formView??`grid`)){if(e===`grid`)try{r({...n,formView:`grid`,fields:me(JSON.parse(n.body||`{}`))})}catch{r({...n,formView:`grid`})}else r({...n,formView:`json`,body:JSON.stringify(_e(n.fields.filter(e=>!e.file)),null,2)})}},y=e===`form`?t(`fieldset`,{class:`seg`,"aria-label":`Body view`,children:[`json`,`grid`].map(e=>t(`button`,{type:`button`,class:`seg-btn ${(n.formView??`grid`)===e?`on`:``}`,"aria-pressed":(n.formView??`grid`)===e,onClick:()=>v(e),children:e===`json`?`JSON`:`Grid`}))}):null;if(xr(n,e)||e===`binary`){let a=t=>e===`binary`||c.includes(t.replace(/\[\d+\]/g,``)),o=e=>r({...n,fields:e}),f=(n.fields.length?n.fields.map(e=>e.key):[]).filter(a);return t(l,{children:[y&&t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Body`}),t(`span`,{class:`chip`,children:e}),t(`span`,{class:`spacer`}),y]}),t(Ur,{title:e===`binary`?`File`:`Body`,bare:!!y,rows:n.fields,readOnly:d,onChange:o,documented:[...new Set(f)].map(e=>({name:e,file:!0})),docFor:e=>Et(wt(i,s,Tt(e),[`data`]),u,`data`,e)})]})}return e===`graphql`&&Or(n.body)?t(Wr,{draft:n,onChange:r,readOnly:d}):t(`section`,{class:`body`,"aria-label":`Body`,children:[t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Body`}),t(`span`,{class:`chip`,children:e}),t(`span`,{class:`spacer`}),e!==`text`&&!d&&t(`button`,{type:`button`,class:`link`,onClick:()=>{try{r({...n,body:JSON.stringify(JSON.parse(n.body),null,2)})}catch{}},children:`Format`}),y]}),t(mr,{readOnly:d,label:`Request body`,language:Gr(e===`form`?`json`:e),value:n.body,onChange:e=>r({...n,body:e}),onLine:p,complete:_}),h&&t(Dr,{doc:g})]})}var qr=`specbook:code-lang`;function Jr(){try{let e=L.local.getItem(qr);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Yr({service:e,profile:r,secured:i,make:s,sent:c}){let[l,u]=a(Jr),d=l===`sent`?`curl`:l,[f,p]=a(!1),[m,h]=a(),[g,_]=a();n(()=>{let t=!0;return N.config(k.value).then(async n=>{let i=n.services?.[e],a=t=>N.baseUrlOf(e,t,k.value).catch(()=>void 0),o=P.value===`mock`?void 0:await a(P.value);if(o??=await a(`live`),!o&&i&&typeof i.baseUrl==`object`&&(o=Object.values(i.baseUrl)[0]),!t)return;h(o);let s=r===`service`?i?.auth:r;_(s?n.auth?.[s]?.apply:void 0)}),()=>{t=!1}},[e,r,P.value,ee.value]);let v=o(()=>{try{return{text:Ae(d,s(m??`https://api.example.com`,g))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},[s,d,m,g]),y=e=>{if(u(e),e!==`sent`)try{L.local.setItem(qr,e)}catch{}};return t(`div`,{class:`code-sample`,children:[t(`div`,{class:`code-head`,children:[t(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[je.map(e=>t(`button`,{type:`button`,"aria-pressed":l===e.id,class:`seg-btn ${l===e.id?`on`:``}`,onClick:()=>y(e.id),children:e.label})),c!==void 0&&t(`button`,{type:`button`,"aria-pressed":l===`sent`,class:`seg-btn ${l===`sent`?`on`:``}`,onClick:()=>y(`sent`),children:`Sent`})]}),t(`span`,{class:`spacer`}),l!==`sent`&&t(`button`,{type:`button`,class:`btn small`,onClick:async()=>{if(v.text)try{await navigator.clipboard.writeText(v.text),p(!0),setTimeout(()=>p(!1),1500)}catch{}},disabled:!v.text,children:f?`Copied`:`Copy`})]}),l===`sent`?c:v.error?t(`p`,{class:`muted`,children:v.error}):t(`pre`,{class:`code-block`,part:`code`,children:t(`code`,{children:v.text})}),l!==`sent`&&i&&t(`p`,{class:`muted small`,children:`Secrets are read from environment variables; set them first.`})]})}function Xr({service:e,method:n,path:r,draft:a,encoding:o,vars:s,secured:c,sent:l}){let u=i((e,t)=>{let i=wr(a,o),c={path:i.path??{},query:i.query??{},headers:i.headers??{},data:i.data},l=c;try{l=f(c,s)}catch{}let u=r.replace(/\{([^}]+)\}/g,(e,t)=>{let n=l.path[t];return n===void 0||n===``?e:encodeURIComponent(String(n))});return{method:n,url:`${e.replace(/\/+$/,``)}${u}`,query:{...t?.query??{},...l.query},headers:{...t?.headers??{},...l.headers},body:l.data,encoding:o}},[a,o,s,n,r]);return t(Yr,{service:e,profile:c?`service`:void 0,secured:c,make:u,sent:l})}function Zr({request:e,encoding:n,sent:r}){let a=i((t,r)=>({method:e.method,url:`${t.replace(/\/+$/,``)}${e.url}`,query:{...r?.query??{},...e.query},headers:{...r?.headers??{},...e.headers},body:e.body,encoding:n}),[e,n]);return t(Yr,{service:e.service,profile:e.profile,secured:!!e.profile,make:a,sent:r})}function Qr(e,t){try{let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return Object.prototype.toString.call(e)}}function $r(e){let t=typeof e==`string`?e:Qr(e);return t.length>28?`${t.slice(0,27)}…`:t}var ei=e=>typeof e==`string`?e:Qr(e,2);function ti(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))for(let e of Array.isArray(r)?r:[r])t.append(n,e);let n=t.toString();return n?`?${n}`:``}function ni({body:e,docs:n}){let[r,i]=a(0),s=ei(e),c=!!n?.schema&&typeof e==`object`&&!!e,u=o(()=>c?Xe(s):[],[c,s]),d=o(()=>{let e=u[r];return e&&n?Et(wt(n.schema,n.defs,e,[`data`]),n.notes,`data`,Ye(e)):void 0},[u,r,n]);return t(l,{children:[t(mr,{label:`Body as sent`,value:s,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:i}),c&&t(Dr,{doc:d})]})}function ri({request:e,hideBar:n,docs:r}){if(!e)return t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`Nothing sent yet`}),t(`span`,{class:`muted`,children:`The request, with every value filled in, appears here after Send.`})]});let i=Object.entries(e.headers);return t(`div`,{class:`sent-view`,children:[!n&&t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${e.method}`,children:e.method}),t(`div`,{class:`rq-url`,title:e.url,children:t(`code`,{children:[e.url,ti(e.query)]})})]}),t(`h3`,{children:`Headers`}),i.length===0?t(`p`,{class:`muted`,children:`No headers.`}):t(`table`,{class:`headers`,children:t(`tbody`,{children:i.map(([e,n])=>t(`tr`,{children:[t(`th`,{children:e}),t(`td`,{children:n})]}))})}),e.body!==void 0&&t(l,{children:[t(`h3`,{children:`Body`}),t(ni,{body:e.body,docs:r})]})]})}function ii(e){let t=e.location;if(!t)return;let n=[...C.requests,...C.sequences].map(e=>e.file).filter(e=>t.file.includes(e)).sort((e,t)=>t.length-e.length)[0];return n?`${n}:${t.line}`:void 0}var ai={expected:`−`,received:`+`,same:` `,skip:` `},oi={expected:`expected`,received:`received`,same:``,skip:``};function si({lines:e}){return t(`section`,{class:`diff`,tabIndex:0,"aria-label":`Expected and received values`,children:e.map(e=>t(`div`,{class:`diff-line diff-${e.kind}`,children:[t(`span`,{class:`diff-gutter`,"aria-hidden":`true`,children:ai[e.kind]}),oi[e.kind]&&t(`span`,{class:`visually-hidden`,children:[oi[e.kind],`: `]}),t(`span`,{class:`diff-text`,children:e.text})]}))})}function ci({a:e}){let n=de(e),r=ii(e);return t(`fieldset`,{class:`check-fail`,children:[t(`legend`,{class:`visually-hidden`,children:[`Failed check: `,e.label]}),t(`div`,{class:`check-head`,children:[t(`span`,{class:`check-mark`,"aria-hidden":`true`,children:`✗`}),t(`strong`,{children:e.label}),t(`span`,{class:`chip`,children:e.operator})]}),n.length>0&&t(l,{children:[t(`div`,{class:`diff-legend`,"aria-hidden":`true`,children:[t(`span`,{class:`diff-key diff-expected`,children:`− Expected`}),t(`span`,{class:`diff-key diff-received`,children:`+ Received`})]}),t(si,{lines:n})]}),r&&t(`div`,{class:`check-where`,children:[`at `,r]})]})}function li({assertions:e}){return t(`ul`,{class:`checks`,children:e.map(e=>e.pass?t(`li`,{class:`ok`,children:[t(`span`,{class:`tick`,children:`✓`}),` `,e.label]}):t(`li`,{class:`bad`,children:t(ci,{a:e})}))})}var ui=e=>Qr(e,2),di=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function fi({step:e,error:r,schemas:i,defs:s,hideRequest:c}){let[u,d]=a(`body`),[f,p]=a(0),m=e?.response,h=m?i?.[String(m.status)]??i?.default:void 0,g=o(()=>{try{return m&&h?Je(m.body,h,s,{reportExtra:!0}):[]}catch{return[]}},[m,h,s]),_=m===void 0||m.body===void 0||m.body===``?``:typeof m.body==`string`?m.body:ui(m.body),v=o(()=>Xe(_),[_]),y=o(()=>{let e=v[f];return e?wt(h,s,e):void 0},[v,f,h,s]),b=e?.assertions??[],x=b.filter(e=>!e.pass).length;n(()=>{e&&x>0&&d(`checks`)},[e]);let S=Object.entries(m?.headers??{}),C=!m&&!r&&!e?.error;return t(`section`,{class:`response`,"aria-label":`Response`,children:[t(`div`,{class:`rs-head`,children:[m&&t(l,{children:[t(`span`,{class:`state-badge ${et(m.status)}`,children:[m.status,` `,$e(m.status)]}),t(`span`,{class:`rs-stat`,children:[m.durationMs,` ms`]}),t(`span`,{class:`rs-stat`,children:di(new Blob([_]).size)})]}),t(`span`,{class:`spacer`}),m&&t(`span`,{class:`conf ${h?g.length?`warn`:`ok`:`none`}`,children:h?g.length?`⚠ ${g.length} difference${g.length>1?`s`:``} from spec`:`✓ Matches spec`:`No schema for this response`})]}),e?.request&&!c&&t(`p`,{class:`sent`,children:[t(`span`,{class:`method ${e.request.method}`,children:e.request.method}),` `,t(`code`,{children:[e.request.url,ti(e.request.query)]})]}),r&&t(`p`,{class:`error-text`,children:r}),e?.error&&t(`p`,{class:`error-text`,children:e.error}),C&&t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`No response yet`}),t(`span`,{class:`muted`,children:[`Press`,` `,t(`kbd`,{class:`icon-key`,children:t(w,{size:12})}),` `,`or `,t(`kbd`,{children:`⌘`}),` `,t(`kbd`,{children:`↵`})]})]}),m&&t(l,{children:[t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`body`,`Body`,0],[`headers`,`Headers`,S.length],[`checks`,`Checks`,b.length]].map(([e,n,r])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":u===e,class:`rq-tab ${u===e?`on`:``}`,onClick:()=>d(e),children:[n,r>0&&t(`span`,{class:`count ${e===`checks`&&x?`bad`:``}`,title:e===`checks`&&x?`${x} of ${r} checks failed`:void 0,children:e===`checks`&&x?x:r})]}))}),t(`div`,{class:`rs-pane`,children:[t(`div`,{hidden:u!==`body`,children:[_===``?t(`p`,{class:`muted`,children:`No content.`}):t(mr,{label:`Response body`,value:_,readOnly:!0,language:typeof m.body==`string`?`text`:`json`,onLine:p}),_!==``&&t(Dr,{doc:y}),g.length>0&&t(`details`,{class:`issues`,children:[t(`summary`,{children:`What differs`}),t(`ul`,{children:g.map(e=>t(`li`,{children:[t(`code`,{children:e.path||`(root)`}),` `,e.message]}))})]})]}),t(`div`,{hidden:u!==`headers`,children:t(`table`,{class:`headers`,children:t(`tbody`,{children:[S.map(([e,n])=>t(`tr`,{children:[t(`th`,{children:e}),t(`td`,{children:n})]})),S.length===0&&t(`tr`,{children:t(`td`,{class:`muted`,children:`No headers recorded`})})]})})}),t(`div`,{hidden:u!==`checks`,children:b.length===0?t(`p`,{class:`muted`,children:`This request has no checks.`}):t(li,{assertions:b})})]})]})]})}var pi=()=>{let e=document.querySelector(`meta[name="specbook-oauth-callback"]`)?.content.trim();if(e)try{return new URL(e,location.origin).href}catch{}return`${location.origin}${location.pathname}`};async function mi(e){let t=window.open(``,u,`popup,width=520,height=720`);if(!t)throw new ae(`The browser blocked the sign-in window. Allow pop-ups for this page and try again.`);let n=new BroadcastChannel(u),r;try{let{verifier:i,challenge:a}=await g(),o=y(),s=pi(),c=new Promise((t,i)=>{let a=setTimeout(()=>i(new ae(`Sign-in timed out. Try again.`)),e.timeoutMs??3e5),s=()=>clearTimeout(a);e.signal?.addEventListener(`abort`,()=>{s(),i(new ae(`Sign-in was cancelled.`))});let c=(e,n)=>{e?.type===`callback`&&e.state===o&&(s(),n({type:`ack`,state:o}),t(e))};n.onmessage=e=>c(e.data,e=>n.postMessage(e)),r=e=>{e.origin===location.origin&&c(e.data,t=>e.source?.postMessage(t,location.origin))},addEventListener(`message`,r)});t.location.href=x({authorizationUrl:e.authorizationUrl,clientId:e.clientId,redirectUri:s,scopes:e.scopes,state:o,challenge:a});let l=await c,{code:u}=M({state:l.state,...l.code?{code:l.code}:{},...l.error?{error:l.error}:{},...l.description?{error_description:l.description}:{}},o),d=await e.exchange(j({code:u,verifier:i,clientId:e.clientId,redirectUri:s}),e.signal);return p(d)}finally{n.close(),r&&removeEventListener(`message`,r);try{t.close()}catch{}}}var hi=`specbook.oauth.clients.v1`,gi=`specbook.oauth.expiry.v1`,_i=(e,t)=>{try{return JSON.parse(e.getItem(t)??`{}`)}catch{return{}}},vi=(e,t,n)=>{try{e.setItem(t,JSON.stringify(n))}catch{}},yi=e=>{try{return _i(L.local,hi)[e]}catch{return}},bi=(e,t)=>{try{vi(L.local,hi,{..._i(L.local,hi),[e]:t})}catch{}},xi=(e,t)=>`${e}\n${t}`,Si=(e,t,n)=>{try{let r=_i(L.session,gi);n===void 0?delete r[xi(e,t)]:r[xi(e,t)]=Date.now()+n*1e3,vi(L.session,gi,r)}catch{}},Ci=(e,t)=>{try{return _i(L.session,gi)[xi(e,t)]}catch{return}};function wi({service:e,profile:r,origin:i,secret:o,oauth:c,onSignedIn:l}){let u=h(c)?c.openIdConnectUrl:c.authorizationUrl,[d,f]=a(()=>c.clientId??yi(u)??``);n(()=>{f(c.clientId??yi(u)??``)},[u,c.clientId]);let[p,m]=a(void 0),[g,_]=a([]),[v,y]=a({kind:`idle`}),b=s(void 0),x=v.kind===`busy`,[S,C]=a(0);n(()=>{let e=!0;return m(void 0),y(e=>e.kind===`busy`?e:{kind:`idle`}),N.oauthEndpoints({env:P.value,version:k.value,profile:r}).then(t=>{e&&(m(t),_(h(c)?[`openid`]:Object.keys(t.scopes)))}).catch(t=>{e&&y({kind:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[r,P.value,k.value,S,ee.value]);let w=Object.keys(p?.scopes??{}),T=()=>{if(!p)return C(e=>e+1);let e=d.trim();if(!e)return y({kind:`error`,message:`Enter the client id registered for this page.`});let t=new AbortController;b.current=t,y({kind:`busy`}),bi(u,e),mi({authorizationUrl:p.authorizationUrl,clientId:e,scopes:g,signal:t.signal,exchange:(e,t)=>N.oauthExchange({env:P.value,version:k.value,profile:r,fields:e,signal:t})}).then(e=>{I.set(i,o,e.accessToken),Si(i,o,e.expiresIn),y({kind:`idle`}),l()}).catch(e=>y({kind:`error`,message:e instanceof Error?e.message:String(e)}))},E=!p&&v.kind===`error`,D=!x&&v.kind!==`error`&&!!p;return t(`span`,{class:`needs-var oauth-signin`,children:[t(`input`,{type:`text`,autocomplete:`off`,"aria-label":`Client id for ${e}`,placeholder:`client id`,value:d,disabled:x,onInput:e=>f(e.target.value)}),x?t(`button`,{type:`button`,class:`link`,onClick:()=>b.current?.abort(),children:`Cancel`}):t(`button`,{type:`button`,class:`btn`,disabled:!p&&!E,onClick:T,children:E?`Try again`:`Sign in`}),w.length>0&&t(`details`,{children:[t(`summary`,{class:`muted small`,children:[`Scopes (`,g.length,` of `,w.length,`)`]}),w.map(e=>t(`label`,{class:`small`,title:p?.scopes[e]||void 0,children:[t(`input`,{type:`checkbox`,checked:g.includes(e),disabled:x,onChange:t=>_(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),` `,t(`code`,{children:e})]}))]}),t(`span`,{class:`muted small oauth-status ${D?`oauth-hint`:``}`,role:`status`,"aria-live":`polite`,children:x?`Waiting for the sign-in window…`:v.kind===`error`?v.message:p?`Register this redirect URI with the provider: ${pi()}`:`Looking up the provider…`})]})}var Ti=e=>e===void 0?void 0:Math.max(0,Math.round((e-Date.now())/6e4)),Ei={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function Di({services:e,enabled:r=!0,supplied:i}){let[o,s]=a([]),[c,u]=a({}),d=i??c,[,f]=a(0),[p,h]=a(!1),g=r&&P.value!==`mock`,_=e?.join(`
|
|
41
|
-
`)??`*`;if(n(()=>{if(!g){s([]);return}let t=!0;return i||N.managedSecrets(P.value).then(e=>t&&u(e)),N.config(k.value).then(async n=>{let r=[],i=await N.addressesIn(n,P.value);for(let[t,a]of Object.entries(n.services??{})){if(e&&!e.includes(t))continue;let o=a.auth?n.auth?.[a.auth]:void 0,s=i.baseUrl(t),c=S(s?m(s,globalThis.location?.href):void 0);if(!o||!c)continue;let l=a.auth?i.oauth(a.auth):void 0,u=[...new Set([...JSON.stringify(o.apply).matchAll(O)].map(e=>e[1]))];u.length&&r.push({service:t,origin:c,title:o.title??a.auth??``,names:u,profile:a.auth,oauth:l})}t&&s(r)}),()=>{t=!1}},[g,P.value,_,k.value,ee.value]),!g||o.length===0)return null;let v=(e,t)=>I.get(e.origin,t)!==void 0||d[t]!==void 0,y=o.some(e=>e.names.some(t=>!v(e,t)));return!y&&!p?t(`div`,{class:`secrets-folded`,children:t(`button`,{type:`button`,class:`secrets-chip`,"aria-expanded":`false`,title:`Credentials are available. Tap to change or clear the ones set in this tab.`,onClick:()=>h(!0),children:[t(`span`,{"aria-hidden":`true`,children:`🔑`}),` `,o.map(e=>e.title||e.service).join(` · `),` ✓`]})}):t(`fieldset`,{class:`needs-vars ${y?``:`ok`}`,"aria-label":`Credentials for this request`,children:[o.map(e=>t(l,{children:[t(`span`,{class:`muted`,title:`Sent from this browser to ${e.origin}`,children:[e.service,` · `,e.title]}),e.names.map(n=>{let r=I.get(e.origin,n)!==void 0,i=d[n];return t(`span`,{class:`needs-var`,children:[t(`code`,{children:n}),r?t(l,{children:[t(`span`,{class:`muted`,children:[`✓ set`,e.oauth&&Ti(Ci(e.origin,n))!==void 0?` · expires in ${Ti(Ci(e.origin,n))} min`:``]}),t(`button`,{type:`button`,class:`link`,onClick:()=>{I.remove(e.origin,n),Si(e.origin,n,void 0),f(e=>e+1)},children:`Clear`})]}):t(l,{children:[i&&t(`span`,{class:`muted`,children:[`from `,Ei[i]??i]}),e.oauth&&t(wi,{service:e.service,profile:e.profile,origin:e.origin,secret:n,oauth:e.oauth,onSignedIn:()=>f(e=>e+1)}),t(`input`,{type:`password`,autocomplete:`off`,"aria-label":`${n} for ${e.service}`,placeholder:i?`use another value`:`paste value`,onChange:t=>{let r=t.target.value;r!==``&&(I.set(e.origin,n,r),f(e=>e+1))}})]})]})})]})),t(`span`,{class:`muted small secrets-note`,children:`Kept in this tab only; sent from your browser to the API.`}),!y&&t(`button`,{type:`button`,class:`link`,onClick:()=>h(!1),children:`Hide`})]})}var Oi=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),ki=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function Ai(e,t){let n=new Map;if(!e||t.length===0)return{intro:e,notes:n};let r=new Map(t.map(e=>[ki(e),e])),i=[];for(let t of e.split(/(?=<h2[ >])/)){let e=/^<h2[^>]*>([\s\S]*?)<\/h2>/.exec(t),a=e?r.get(ki(Oi(e[1]))):void 0;e&&a!==void 0?n.has(a)||n.set(a,t.slice(e[0].length)):i.push(t)}return{intro:i.join(``),notes:n}}function ji(e){let{seq:t}=e,[r,i]=a(),[s,c]=a(!1);n(()=>{let n=!0;i(void 0),c(!1);let r=C.docs.find(n=>n.sequence===t.meta.id||n.sequenceFile===e.file);if(!r)c(!0);else return r.load().then(e=>n&&i(e)).finally(()=>n&&c(!0)),()=>{n=!1}},[t.meta.id,e.file]);let l=o(()=>t.nodes.map(e=>e.name),[t]);return o(()=>({...Ai(r??Ne(t.meta.description),l),loaded:s}),[r,l,t,s])}function Mi(e){let[t,r]=a();return n(()=>{let t=!0;return r(void 0),e&&C.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&r(e)),()=>{t=!1}},[e]),t}var Ni=(e,t)=>`specbook:draft:${e}:${t}`,Pi=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Fi(e){try{let t=L.local.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var Ii=`specbook:saved-example`;function Li(e){try{let t=L.session.getItem(Ii),n=t?JSON.parse(t):void 0;return n?.key===e?(L.session.removeItem(Ii),n):void 0}catch{return}}function Ri({service:e,op:r,variants:i,initial:c,autoRun:u}){let f=`${e}/${r.id}`,p=s(null),m=s(!1),h=s(void 0),g=N.examplesOf(f),[_,v]=a(()=>Li(f)),[y,b]=a(()=>{if(c?.startsWith(`saved:`)&&i.some(e=>`saved:${e.file}`===c))return c;let e=g.find(e=>e.name===(_?.name??c));return e?`ex:${e.name}`:g[0]?`ex:${g[0].name}`:i[0]?`saved:${i[0].file}`:``}),x=y.startsWith(`saved:`)?i.find(e=>`saved:${e.file}`===y):void 0,S=Mi(x?.file),E=ft(f),[O,j]=a(),[M,F]=a(),[I,ae]=a(),[se,ce]=a({}),[R,le]=a(),[ue,de]=a(),[z,fe]=a(),[pe,me]=a(),[he,ge]=a(),[_e,ve]=a(),[ye,be]=a(!1),[xe,Se]=a(),[Ce,B]=a(),[we,Te]=a(``),[V,Ee]=a(),[De,H]=a();n(()=>{let t=!0;if(H(void 0),P.value===`mock`)Te(``);else return N.baseUrlOf(e,P.value,k.value).then(e=>t&&Te(e??``)).catch(e=>{t&&(Te(``),H(e instanceof Error?e.message:String(e)))}),()=>{t=!1}},[e,P.value,k.value,ee.value]),n(()=>{let e=!0;return Ee(void 0),N.knownVars(P.value,k.value).then(t=>e&&Ee(t)),()=>{e=!1}},[P.value]),n(()=>{let t=!0;return C.schemas[f]?.().then(e=>t&&le(e.default)),C.responseSchemas[f]?.().then(e=>t&&de(e.default)),C.definitions[e]?.().then(e=>t&&fe(e.default)),N.operationMeta(f,k.value).then(e=>{t&&j({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[f,e]);let U=O?.encoding??`json`,Oe=C.manifests[e]?.operations.find(e=>e.id===r.id)?.secured;n(()=>{if(!O)return;let e=!0;return ve(void 0),ge(void 0),(async()=>{let t=x?await N.savedExample(x.def,k.value):await N.loadExample(f,y.replace(/^ex:/,``),k.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};F(n),ae(!x&&Fi(Ni(f,y))||Sr(n,U))})().catch(t=>e&&ve(t instanceof Error?t.message:String(t))),()=>{e=!1}},[f,y,O,x]);let ke=o(()=>M?Sr(M,U):void 0,[M,U]),Ae=!!I&&!!ke&&JSON.stringify(Tr(I))!==JSON.stringify(Tr(ke)),je=e=>{if(ae(e),!x)try{let t=Ni(f,y);ke&&JSON.stringify(Tr(e))===JSON.stringify(Tr(ke))?L.local.removeItem(t):L.local.setItem(t,JSON.stringify(Tr(e)))}catch{}},W=o(()=>{let e=R?q(R,z):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=We(r,z).map(e=>({name:e.name,doc:Et(wt(R,z,[e.name],[n]),E.notes,n,e.name),repeat:q(e.schema,z).type===`array`})))}return t},[R,z,E.notes]),Me=o(()=>{if(!I)return[];try{let e=wr(I,U);return[...d([e.path,e.query,e.headers,e.data])].filter(e=>!e.startsWith(`faker.`)&&!e.startsWith(`secrets.`)&&!e.startsWith(`session.`)).map(e=>e.split(`.`)[0]).filter((e,t,n)=>n.indexOf(e)===t)}catch{return[]}},[I,U]),Ne=Object.keys(x?.def.input.init??{}),Pe=V?Me.filter(e=>!V.includes(e)&&!Ne.includes(e)):[],Fe=Pe.filter(e=>(se[e]??``)===``),Ie=async e=>{if(!I||h.current)return;ve(void 0),be(!0);let t=new AbortController;h.current=t;try{let n=x?x.def:await N.operationRequest(f,k.value,wr(I,U)),r=await N.run(n,{env:P.value,version:k.value,mockStatus:P.value===`mock`?e??pe:void 0,locale:ie.value,seed:te.value,vars:Object.fromEntries(Object.entries(se).filter(([,e])=>e!==``)),fileDir:M?.dir,signal:t.signal});ge(r),vt.value=yt(r)}catch(e){ve(e instanceof Error?e.message:String(e))}finally{h.current=void 0,be(!1),B(`response`)}};n(()=>{u&&I&&!m.current&&(m.current=!0,Ie())},[I]);let Le=async t=>{if(!I)return;let n=wr(I,U),i=Pi(t),a={name:i,title:t,source:`project`,path:n.path,query:n.query,headers:n.headers,body:typeof n.data==`object`&&n.data instanceof Blob?void 0:n.data},o=`${C.project.requestsDir}/${e}/${r.id}/${i}.example.json`,s={key:f,path:o,name:i};try{L.session.setItem(Ii,JSON.stringify(s))}catch{}await re(o,`${JSON.stringify(a,null,2)}\n`),v(s),Se(void 0)},G=he?.steps.find(e=>e.response)??he?.steps[0],Re=_e?.match(/Missing variable "\{\{([^}.]+)/)?.[1],ze=!!I&&(I.path.length>0||I.query.length>0||W.path.length>0||W.query.length>0),Be=!!I&&(I.headers.length>0||W.headers.length>0),Ve=!!I&&U!==`none`&&(I.body!==``||I.fields.length>0||!!R?.properties?.data),K=Ce??(ze?`params`:Ve?`body`:Be?`headers`:`params`),J=e=>e.filter(e=>e.enabled).length,He=I?J(I.query):0,Ue=I?J(I.path):0,Ge=I?Er(r.path,I.path,I.query,we):r.path;return n(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Ie())},t=p.current?.getRootNode()??window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)}),t(`div`,{class:`request-panel`,"data-op":f,ref:p,children:t(`div`,{class:`rq`,children:[t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${r.method}`,children:r.method}),t(`div`,{class:`rq-url`,title:Ge,children:t(`code`,{children:Ge.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?t(`mark`,{children:e}):e)})}),(G?.response||_e||G?.error)&&t(`button`,{type:`button`,class:`result-chip ${G?.response?et(G.response.status):`s5`}`,title:`Open the response`,onClick:()=>B(`response`),children:G?.response?`${G.response.status} ${$e(G.response.status)} · ${G.response.durationMs} ms`:`Failed`}),t(`button`,{type:`button`,class:`btn primary send`,title:ye?`Stop`:`Send (⌘/Ctrl + Enter)`,"aria-label":ye?`Stop`:`Send`,disabled:!ye&&!I,onClick:()=>ye?h.current?.abort():Ie(),children:t(ye?oe:w,{})})]}),De&&t(`p`,{class:`envmenu-warn`,role:`alert`,children:[De,`.`,` `,D.value.environmentSettings&&t(`button`,{type:`button`,class:`link`,onClick:()=>T.value=!0,children:`Open Environment settings`})]}),S&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this request`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:S}})]},x?.file),Pe.length>0&&t(`fieldset`,{class:`needs-vars ${Fe.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[t(`span`,{class:`muted`,children:Fe.length>0?`Needs a value for`:`Values for`}),Pe.map(e=>t(`label`,{class:`needs-var`,children:[t(`code`,{children:e}),t(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:se[e]??``,onInput:t=>ce({...se,[e]:t.target.value})})]}))]}),Oe&&t(Di,{services:[e]}),t(`div`,{class:`rq-meta`,children:[t(`div`,{class:`rq-example`,children:[t(`label`,{class:`row`,children:[t(`span`,{class:`muted`,children:`Example`}),t(`select`,{value:y,onChange:e=>b(e.target.value),children:[g.map(e=>t(`option`,{value:`ex:${e.name}`,children:[e.name,e.source===`project`?` · yours`:``]})),i.map(e=>t(`option`,{value:`saved:${e.file}`,children:[e.name,` · saved request`]}))]})]}),t(ne,{})]}),Ae&&t(`span`,{class:`edited`,children:`Edited`}),t(`span`,{class:`spacer`}),Ae&&t(`button`,{type:`button`,class:`link`,onClick:()=>ke&&je(ke),children:`↺ Reset`}),!A&&!x&&Ae&&xe===void 0&&t(`button`,{type:`button`,class:`link`,onClick:()=>Se(``),children:`Save as example…`}),P.value===`mock`&&r.statuses.length>0&&t(`label`,{class:`rq-status`,children:[t(`span`,{class:`muted`,children:`Respond with`}),t(`select`,{"aria-label":`Mock response`,value:pe===void 0?``:String(pe),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);me(n),Ie(n)},children:[t(`option`,{value:``,children:`Default`}),r.statuses.map(e=>t(`option`,{value:String(e),children:[e,` `,$e(e)]}))]})]})]}),_&&t(`p`,{class:`saved-note`,role:`status`,children:[t(`span`,{children:[`✓ Saved to `,t(`code`,{children:_.path}),`. It is a normal project file: commit it to share this example with your team.`]}),t(`button`,{type:`button`,class:`icon`,"aria-label":`Dismiss`,onClick:()=>v(void 0),children:`×`})]}),xe!==void 0&&t(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),xe.trim()&&Le(xe.trim()).catch(e=>ve(String(e)))},children:[t(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:xe,onInput:e=>Se(e.target.value)}),t(`button`,{type:`submit`,class:`btn`,children:`Save`}),t(`button`,{type:`button`,class:`link`,onClick:()=>Se(void 0),children:`Cancel`})]}),x&&t(`p`,{class:`muted lock`,children:`A saved request: its own values, checks and mock hook apply, and it is read-only here.`}),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,He+Ue],[`headers`,`Headers`,I?J(I.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,Me.length]].filter(([e])=>e===`params`?ze:e===`headers`?Be:e===`body`?Ve:Me.length>0).map(([e,n,r])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":K===e,class:`rq-tab ${K===e?`on`:``}`,onClick:()=>B(e),children:[n,r>0&&t(`span`,{class:`count`,children:r}),e===`body`&&t(`span`,{class:`chip`,children:U})]})),t(`span`,{class:`tab-gap`}),t(`button`,{type:`button`,role:`tab`,"aria-selected":K===`request`,class:`rq-tab ${K===`request`?`on`:``}`,onClick:()=>B(`request`),children:`Request`}),t(`button`,{type:`button`,role:`tab`,"aria-selected":K===`response`,class:`rq-tab ${K===`response`?`on`:``}`,onClick:()=>B(`response`),children:[`Response`,G?.response&&t(`span`,{class:`state-dot ${et(G.response.status)}`,children:G.response.status}),!G?.response&&(_e||G?.error)&&t(`span`,{class:`state-dot s5`,children:`!`})]})]}),t(`div`,{class:`rq-pane`,children:[I&&t(l,{children:[t(`div`,{class:`tab-pane`,hidden:K!==`params`,children:[(I.query.length>0||W.query.length>0)&&t(Ur,{title:`Query`,rows:I.query,documented:W.query,readOnly:!!x,onChange:e=>je({...I,query:e})}),(I.path.length>0||W.path.length>0)&&t(Ur,{title:`Path`,rows:I.path,documented:W.path,fixed:!0,readOnly:!!x,onChange:e=>je({...I,path:e})})]}),t(`div`,{class:`tab-pane`,hidden:K!==`headers`,children:Be&&t(Ur,{title:`Headers`,rows:I.headers,documented:W.headers,readOnly:!!x,onChange:e=>je({...I,headers:e})})}),t(`div`,{class:`tab-pane`,hidden:K!==`body`,children:Ve&&t(Kr,{encoding:U,draft:I,onChange:je,schema:R,defs:z,files:O?.files,notes:E.notes,readOnly:!!x})}),t(`div`,{class:`tab-pane`,hidden:K!==`vars`,children:Me.length>0&&t(Ur,{title:`Variables`,rows:Me.map(e=>({key:e,value:se[e]??``,enabled:!0})),fixed:!0,bad:Re,placeholder:`from the request's init, config or earlier steps`,onChange:e=>ce(Object.fromEntries(e.map(e=>[e.key,e.value])))})})]}),t(`div`,{class:`tab-pane`,hidden:K!==`request`,children:I&&t(Xr,{service:e,method:r.method,path:r.path,draft:I,encoding:U,vars:se,secured:Oe,sent:G?.request?t(ri,{request:G.request,docs:{schema:R,defs:z,notes:E.notes}}):void 0})}),t(`div`,{class:`tab-pane`,hidden:K!==`response`,children:t(fi,{step:G,error:_e,schemas:ue,defs:z})})]})]})})}function zi(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...Bi(e,t),...n}}function Bi(e,t){switch(e.kind){case`select`:case`multiselect`:{let n=e=>typeof t.value==`function`?t.value(e):e,r=e=>typeof t.label==`function`?t.label(e):String(n(e));return{kind:e.kind,options:t.options.map(e=>({label:r(e),value:n(e)}))}}case`object`:return{kind:`object`,shape:Object.fromEntries(Object.entries(t.shape).map(([e,t])=>[e,zi(t)]))};case`array`:return{kind:`array`,item:zi(t.item),default:t.default,min:t.min,max:t.max};default:return typeof t.default==`function`?{kind:e.kind,generate:t.default,min:t.min,max:t.max}:{kind:e.kind,default:t.default,min:t.min,max:t.max}}}function Vi(e){if(e.generate)try{return e.generate()}catch{}return Hi({...e,generate:void 0})}function Hi(e){if(e.generate)return Vi(e);switch(e.kind){case`select`:return e.options?.[0]?.value;case`multiselect`:return[];case`object`:return Object.fromEntries(Object.entries(e.shape??{}).map(([e,t])=>[e,Hi(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var Ui={step:`request`,each:`for each item`,input:`you choose`,check:`check`},Wi=e=>typeof e==`string`?e:Qr(e);function Gi({info:e}){let{seq:n}=e,{intro:r,notes:i}=ji(e),a=o(()=>Object.entries(n.meta.inputs??{}).map(([e,t])=>{let n=zi(t);return{name:e,spec:n,initial:Hi(n)}}),[n]);return t(`article`,{class:`doc`,"data-seq":n.meta.id,children:[(n.meta.tags?.length??0)>0&&t(`p`,{class:`doc-tags`,children:n.meta.tags?.map(e=>t(`span`,{class:`chip`,children:e}))}),r&&t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}}),a.length>0&&t(`section`,{children:[t(`h2`,{children:`Controls`}),t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`Name`}),t(`th`,{children:`Type`}),t(`th`,{children:`Default`}),t(`th`,{children:`Description`})]})}),t(`tbody`,{children:a.map(e=>t(`tr`,{children:[t(`td`,{children:t(`code`,{children:e.name})}),t(`td`,{children:t(`span`,{class:`chip`,children:e.spec.kind})}),t(`td`,{children:t(`code`,{children:Wi(e.initial)})}),t(`td`,{children:e.spec.description})]}))})]})]}),t(`section`,{children:[t(`h2`,{children:`Steps`}),t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`#`}),t(`th`,{children:`Step`}),t(`th`,{children:`What it does`})]})}),t(`tbody`,{children:n.nodes.map((e,n)=>{let r=(e.kind===`step`&&typeof e.def!=`function`?e.def:void 0)?.op,a=i.get(e.name);return t(l,{children:[t(`tr`,{class:a?`has-note`:``,children:[t(`td`,{children:n+1}),t(`td`,{children:e.name}),t(`td`,{children:r?t(`button`,{type:`button`,class:`link`,title:`Open this operation`,onClick:()=>b({kind:`op`,key:`${r.service}/${r.id}`}),children:[t(`span`,{class:`method ${r.method}`,children:r.method}),` `,t(`code`,{children:r.path})]}):t(`span`,{class:`muted`,children:Ui[e.kind]??e.kind})})]}),a&&t(`tr`,{class:`step-note-row`,children:[t(`td`,{}),t(`td`,{colSpan:2,children:t(`div`,{class:`doc-custom step-note`,dangerouslySetInnerHTML:{__html:a}})})]})]})})})]})]})]})}var Ki=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function qi(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function Ji({name:e,spec:n,value:r,onChange:i}){let[o,s]=a();switch(n.kind){case`number`:return t(`input`,{class:`cell`,type:`number`,"aria-label":e,value:String(r??``),min:n.min,max:n.max,onInput:e=>{let t=e.target.value;i(t===``?void 0:Number(t))}});case`boolean`:return t(Ar,{label:e,value:String(!!r),options:[`true`,`false`],onChange:e=>e===`true`||e===`false`?i(e===`true`):void 0});case`date`:return t(`input`,{class:`cell`,type:`date`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)});case`select`:{let a=n.options??[],o=a.find(e=>Ki(e.value,r));return t(Ar,{label:e,value:o?.label??String(r??``),options:a.map(e=>e.label),onChange:e=>{let t=a.find(t=>t.label===e);t&&i(t.value)}})}case`multiselect`:{let e=r??[];return t(`div`,{class:`multi-cell`,children:(n.options??[]).map(n=>t(`label`,{children:[t(`input`,{type:`checkbox`,checked:e.some(e=>Ki(e,n.value)),onChange:t=>i(t.target.checked?[...e,n.value]:e.filter(e=>!Ki(e,n.value)))}),n.label]}))})}case`object`:case`array`:return t(`input`,{class:`cell mono`,"aria-label":e,value:o??JSON.stringify(r??Hi(n)),onInput:e=>{let t=e.target.value;s(t);try{i(JSON.parse(t))}catch{}},onBlur:()=>s(void 0)});default:return t(`input`,{class:`cell`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)})}}function Yi(){return t(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,focusable:`false`,children:[t(`rect`,{x:`1.5`,y:`1.5`,width:`13`,height:`13`,rx:`3`,fill:`none`,stroke:`currentColor`}),t(`circle`,{cx:`5.2`,cy:`5.2`,r:`1.1`,fill:`currentColor`}),t(`circle`,{cx:`10.8`,cy:`10.8`,r:`1.1`,fill:`currentColor`}),t(`circle`,{cx:`8`,cy:`8`,r:`1.1`,fill:`currentColor`})]})}function Xi({title:e,specs:n,values:r,onChange:i}){let a=Object.keys(n);if(a.length===0)return null;let o=a.filter(e=>n[e]?.generate);return t(`section`,{class:`grid controls-grid`,"aria-label":e,children:[t(`h3`,{class:`controls-head`,children:[t(`span`,{children:e}),o.length>1&&t(`button`,{type:`button`,class:`btn small gen-all`,title:`Make a new value for every generated input`,onClick:()=>i({...r,...Object.fromEntries(o.map(e=>[e,Vi(n[e])]))}),children:[t(Yi,{}),` Generate all`]})]}),t(`table`,{children:[t(`colgroup`,{children:[t(`col`,{class:`c-key`}),t(`col`,{class:`c-val`}),t(`col`,{})]}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-key`,children:`Name`}),t(`th`,{class:`g-val`,children:`Value`}),t(`th`,{class:`g-doc`,children:`Description`})]})}),t(`tbody`,{children:a.map(e=>{let a=n[e];return t(`tr`,{children:[t(`td`,{class:`g-key`,children:t(`span`,{class:`key`,children:t(`code`,{children:a.label??e})})}),t(`td`,{class:`g-val`,children:t(`div`,{class:a.generate?`cell-gen`:void 0,children:[t(Ji,{name:e,spec:a,value:r[e],onChange:t=>i({...r,[e]:t})}),a.generate&&t(`button`,{type:`button`,class:`gen`,"aria-label":`Generate ${a.label??e}`,title:`Make another value`,onClick:()=>i({...r,[e]:Vi(a)}),children:t(Yi,{})})]})}),t(`td`,{class:`g-doc`,title:a.description,children:[t(`span`,{class:`chip`,children:qi(a)}),` `,a.description]})]},e)})})]})]})}function Zi({step:e,note:r}){let[i,o]=a(`response`),[s,c]=a(),[l,u]=a(),[d,f]=a(),[p,m]=a(`json`),h=e.request,g=h?.opId?`${h.service}/${h.opId}`:void 0;n(()=>{o(`response`)},[e.name]),n(()=>{let e=!0;return c(void 0),u(void 0),f(void 0),g&&h&&(C.schemas[g]?.().then(t=>e&&f(t.default)),N.operationMeta(g,k.value).then(t=>e&&m(t?.encoding??`json`)),C.responseSchemas[g]?.().then(t=>e&&c(t.default)),C.definitions[h.service]?.().then(t=>e&&u(t.default))),()=>{e=!1}},[g]);let _=e.response,v=h?`${h.url}${ti(h.query)}`:``;return t(`div`,{class:`step-exchange`,children:[h&&t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${h.method}`,children:h.method}),t(`div`,{class:`rq-url`,title:v,children:t(`code`,{children:v})}),_&&t(`span`,{class:`result-chip ${et(_.status)}`,children:[_.status,` `,$e(_.status),` · `,_.durationMs,` ms`]})]}),r&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this step`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}})]},e.name),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`request`,`Request`],[`response`,`Response`]].map(([e,n])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,class:`rq-tab ${i===e?`on`:``}`,onClick:()=>o(e),children:[n,e===`response`&&_&&t(`span`,{class:`state-dot ${et(_.status)}`,children:_.status})]}))}),t(`div`,{class:`rq-pane`,children:[t(`div`,{class:`tab-pane`,hidden:i!==`request`,children:h?t(Zr,{request:h,encoding:p,sent:t(ri,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}):t(ri,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}),t(`div`,{class:`tab-pane`,hidden:i!==`response`,children:t(fi,{step:e,schemas:s,defs:l,hideRequest:!0})})]})]})}var Qi=e=>e.replace(/ #\d+$/,``),$i={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``};function ea({info:e,preset:r,autoRun:i}){let{seq:c}=e,l=o(()=>Object.fromEntries(Object.entries(c.meta.inputs??{}).map(([e,t])=>[e,zi(t)])),[c]),u=ji(e),d=o(()=>{let e=new Set;for(let t of c.nodes)if(t.kind===`step`&&typeof t.def!=`function`)e.add(t.def.op.service);else if(t.kind===`step`||t.kind===`each`)return;return[...e]},[c]),[f,p]=a({}),[m,h]=a(),[g,_]=a({}),[v,y]=a(!1),[b,x]=a(),[S,C]=a({}),[w,T]=a(0),[E,D]=a(!1),[O,A]=a(),j=Object.values(l).some(e=>e.generate),M=Object.keys(l).length>0||c.nodes.some(e=>e.kind===`input`),ee=async()=>(j&&await N.fakerReady(k.value,ie.value,te.value).catch(()=>{}),Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Hi(t)])));n(()=>{let e=!0,t=e=>({...e,...r??{}});return p(t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Hi(t)])))),j?ee().then(n=>{e&&(p(t(n)),i&&ce({inputs:t(n),headless:!0}))}):i&&ce({inputs:t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Hi(t)]))),headless:!0}),h(void 0),_({}),x(void 0),()=>{e=!1}},[e.file]);let re=c.nodes.map(e=>e.name),F=m?m.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):re.map(e=>({name:e})),I=F[w]?.step,ae=s(void 0),[oe,L]=a(!1),se=()=>{L(!0),ae.current?.abort(),b?.resolve(S)},ce=async(e={})=>{let t=new AbortController;ae.current=t,L(!1),y(!0),h(void 0),A(void 0),_({}),T(0),D(!1);try{let n=await N.run(c,{env:P.value,version:k.value,inputs:e.inputs??f,locale:ie.value,seed:te.value,signal:t.signal,onEvent:e=>{e.type===`step:start`&&_(t=>({...t,[e.name]:`running`})),e.type===`step:end`&&_(t=>({...t,[e.name]:e.status}))},onInput:e.headless?void 0:({name:e,controls:t})=>new Promise(n=>{let r=t;_(t=>({...t,[e]:`paused`})),C(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,Hi(t)]))),x({name:e,controls:r,resolve:e=>{x(void 0),n(e)}})})});h(n),vt.value=yt(n);let r=n.steps.filter(e=>e.kind!==`auth`).findIndex(e=>e.status===`fail`||e.status===`error`);r>=0&&T(r)}catch(e){A(e instanceof Error?e.message:String(e))}finally{ae.current=void 0,y(!1),x(void 0)}},R=m?.status;return t(`div`,{class:`sequence-panel ${E&&I?`sheet-open`:``}`,"data-seq":c.meta.id,children:[t(`div`,{class:`seq-left`,children:[t(Di,{services:d}),t(Xi,{title:`Inputs`,specs:l,values:f,onChange:p}),t(`div`,{class:`seq-run`,children:[t(`button`,{type:`button`,class:`btn primary`,disabled:v,onClick:()=>ce(),children:v?`Running…`:`▶ Run`}),v&&t(`button`,{type:`button`,class:`btn`,onClick:se,children:`Stop`}),M&&t(`button`,{type:`button`,class:`btn`,disabled:v,title:`Skip every question and use each input's default, as specbook test does`,onClick:async()=>{let e=await ee();p(e),await ce({inputs:e,headless:!0})},children:`Run with defaults`}),t(ne,{}),m&&t(`span`,{class:`badge ${R}`,children:[$i[R],` `,R===`pass`?`Passed`:oe?`Stopped`:R===`fail`?`Failed`:`Error`,` `,`· `,m.totals.passed,`/`,m.totals.steps,` steps · `,m.durationMs,`ms`]})]}),O&&t(`p`,{class:`error-text`,children:O}),t(`ol`,{class:`journey`,part:`timeline`,"aria-label":`Timeline`,children:F.map((e,n)=>{let r=e.step,i=r?.status??g[e.name]??`pending`,a=r?.assertions.filter(e=>!e.pass)??[];return t(`li`,{class:`jstep ${i} ${w===n?`picked`:``}`,children:[t(`div`,{class:`jmark`,children:$i[i]||n+1}),t(`div`,{class:`jbody`,children:[t(`button`,{type:`button`,class:`jhead`,disabled:!r,onClick:e=>{let t=e.currentTarget;T(n),D(!0),requestAnimationFrame(()=>t.scrollIntoView?.({block:`start`,behavior:`smooth`}))},children:[t(`span`,{class:`jname`,children:e.name}),r?.response&&t(`span`,{class:`muted`,children:[r.response.status,` · `,r.durationMs,`ms`]}),r&&r.assertions.length>0&&t(`span`,{class:a.length?`error-text`:`muted`,children:[r.assertions.length-a.length,`/`,r.assertions.length,` checks`]})]}),r?.uses?.filter(e=>e.source===`capture`).map(e=>t(`span`,{class:`cap use`,title:`from step "${e.step}"`,children:[`← `,e.key,` `,t(`em`,{children:[`from `,e.step]})]})),r&&Object.entries(r.captured).map(([e,n])=>t(`span`,{class:`cap make`,title:Qr(n),children:[`→ `,e,` `,t(`b`,{children:$r(n)})]})),r?.error&&t(`div`,{class:`error-text`,children:r.error}),a.map(e=>t(ci,{a:e})),i===`skipped`&&t(`div`,{class:`muted`,children:oe?`Skipped: you stopped the run.`:`Skipped: an earlier step did not pass.`}),b&&g[e.name]===`paused`&&t(`div`,{class:`pause`,children:[t(`strong`,{children:[`Your turn: `,b.name]}),t(Xi,{title:`Choose`,specs:b.controls,values:S,onChange:C}),t(`button`,{type:`button`,class:`btn primary`,onClick:()=>b.resolve(S),children:`Continue ▶`})]})]})]})})})]}),t(`div`,{class:`seq-right ${E&&I?`sheet-open`:``}`,children:[I&&t(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>D(!1),children:[t(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,I.name]}),!I&&t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`Nothing run yet`}),t(`span`,{class:`muted`,children:`Press Run, then pick a step to see its request and response.`})]}),I&&t(Zi,{step:I,note:u.notes.get(Qi(I.name))})]})]})}function ta(e){let n=e.tab??`try`,r=t(`div`,{class:`rq-tabs panel-tabs`,role:`tablist`,children:[[`try`,e.kind===`seq`?`Run`:`Try`],[`docs`,`Docs`]].map(([r,i])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":n===r,class:`rq-tab ${n===r?`on`:``}`,onClick:()=>e.onNavigate({tab:r}),children:i}))});return e.kind===`seq`?t(Ct,{title:e.info.seq.meta.title,subtitle:`Sequence`,flush:!0,modal:e.modal,variant:e.variant,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:t(`div`,{class:`panel-split`,children:[r,t(`div`,{class:`panel-main ${n===`docs`?`scroll`:``}`,children:n===`docs`?t(Gi,{info:e.info}):t(ea,{info:e.info,preset:e.preset,autoRun:e.autoRun})})]})}):t(Ct,{title:e.op.summary?.replace(/\.$/,``)||e.op.path,subtitle:`${e.op.method} ${e.op.path}`,flush:!0,modal:e.modal,variant:e.variant,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:t(`div`,{class:`panel-split`,children:[r,t(`div`,{class:`panel-main ${n===`docs`?`scroll`:``}`,children:n===`docs`?t(_t,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):t(Ri,{service:e.service,op:e.op,variants:e.variants,initial:e.example,autoRun:e.autoRun},`${e.service}/${e.op.id}${e.example.startsWith(`saved:`)?`@${e.example}`:``}`)})]})})}export{ta as Host};
|