@nice2dev/ui-api 1.4.8 → 1.4.9

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/core.cjs ADDED
@@ -0,0 +1,121 @@
1
+ "use strict";var _n=Object.defineProperty;var En=(e,t,n)=>t in e?_n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ae=(e,t,n)=>En(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Un=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"],qn=["inherit","none","apiKey","bearer","basic","digest","oauth2","awsSigV4","hmac","mtls","custom"];let Fe=0;function Ee(e="r"){return Fe=(Fe+1)%1e6,`${e}${Date.now().toString(36)}${Fe.toString(36)}${Math.random().toString(36).slice(2,6)}`}function he(e={}){return{...e,kind:"request",id:e.id??Ee("r"),name:e.name??"New request",method:e.method??"GET",url:e.url??"",params:e.params??[],body:e.body??{kind:"none"}}}function ye(e={}){return{...e,kind:"folder",id:e.id??Ee("f"),name:e.name??"New folder",items:e.items??[]}}function be(e={}){return{...e,id:e.id??Ee("c"),name:e.name??"New API",items:e.items??[],variables:e.variables??[]}}function ze(e,t=[]){const n=[];for(const r of e)r.kind==="folder"?n.push(...ze(r.items,[...t,r])):n.push({request:r,folders:[...t]});return n}function It(e,t){for(const n of e){if(n.id===t)return n;if(n.kind==="folder"){const r=It(n.items,t);if(r)return r}}}function Pt(e,t,n){const r=[];for(const s of e)if(s.id===t){const o=n(s);o&&r.push(o)}else s.kind==="folder"?r.push({...s,items:Pt(s.items,t,n)}):r.push(s);return r}function I(e){return e.enabled!==!1}function In(e){const t={};for(const n of e)I(n)&&(t[n.key]=n.value);return t}function Lt(e,t){return e.params.filter(n=>n.in===t&&I(n))}function Pn(e,t){var r;const n=t.toLowerCase();return(r=Lt(e,"header").find(s=>s.key.toLowerCase()===n))==null?void 0:r.value}function Rt(e,t=[],n){const r=[e.auth,...[...t].reverse().map(s=>s.auth),n==null?void 0:n.auth];for(const s of r)if(s&&s.type!=="inherit")return s;return{type:"none"}}function ke(e){switch(e.kind){case"json":case"graphql":return"application/json";case"xml":return"application/xml";case"text":return e.contentType??"text/plain";case"form":return"application/x-www-form-urlencoded";case"multipart":return"multipart/form-data";case"binary":return e.contentType??"application/octet-stream";case"soap":return e.version==="1.2"?`application/soap+xml; charset=utf-8${e.action?`; action="${e.action}"`:""}`:"text/xml; charset=utf-8";default:return}}function se(e){var t;switch(e.kind){case"json":case"xml":case"text":return e.text;case"form":return e.fields.filter(I).map(n=>`${encodeURIComponent(n.key)}=${encodeURIComponent(n.value)}`).join("&");case"graphql":{const n={query:e.query};if((t=e.variables)!=null&&t.trim())try{n.variables=JSON.parse(e.variables)}catch{n.variables=e.variables}return e.operationName&&(n.operationName=e.operationName),JSON.stringify(n)}case"soap":return e.envelope;default:return}}function lt(e,t){const n=(t??"").toLowerCase();return n.includes("x-www-form-urlencoded")?{kind:"form",fields:ut(e)}:n.includes("soap+xml")?{kind:"soap",envelope:e,version:"1.2"}:n.includes("xml")?/<(\w+:)?Envelope[\s>]/.test(e)?{kind:"soap",envelope:e,version:"1.1"}:{kind:"xml",text:e}:n.includes("json")||!n&&/^\s*[[{]/.test(e)?Ln(e)??{kind:"json",text:e}:{kind:"text",text:e,contentType:t||void 0}}function ut(e){return e?e.split("&").map(t=>{const n=t.indexOf("="),r=s=>{try{return decodeURIComponent(s.replace(/\+/g," "))}catch{return s}};return n<0?{key:r(t),value:""}:{key:r(t.slice(0,n)),value:r(t.slice(n+1))}}):[]}function Ln(e){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.query=="string"&&/^\s*(query|mutation|subscription|\{|fragment)/.test(t.query))return{kind:"graphql",query:t.query,variables:t.variables===void 0?void 0:JSON.stringify(t.variables,null,2),operationName:typeof t.operationName=="string"?t.operationName:void 0}}catch{}return null}const Ht=/\{\{\s*([^{}]+?)\s*\}\}/g;function Dt(e){const t=new Set;for(const n of e.matchAll(Ht))t.add(n[1]);return[...t]}function Rn(e){const t=r=>Array.from({length:r},()=>Math.floor(e()*16).toString(16)).join(""),n=(8+Math.floor(e()*4)).toString(16);return`${t(8)}-${t(4)}-4${t(3)}-${n}${t(3)}-${t(12)}`}function ft(e,t,n={}){const r=typeof t=="function"?t:c=>t[c],s=n.random??Math.random,o=n.now??(()=>new Date),i=c=>{var l;if(c.startsWith("secret:"))return(l=n.resolveSecret)==null?void 0:l.call(n,c.slice(7).trim());switch(c){case"$guid":case"$randomUUID":return Rn(s);case"$timestamp":return String(Math.floor(o().getTime()/1e3));case"$isoTimestamp":return o().toISOString();case"$randomInt":return String(Math.floor(s()*1001));default:return r(c)}};let a=e;for(let c=0;c<5&&a.includes("{{");c++){const l=a.replace(Ht,(f,u)=>i(u)??f);if(l===a)break;a=l}return a}function Hn(e,t,n={}){return Dt(ft(e,t,n))}function Dn(e,t,n){const r={},s=o=>{for(const i of o??[])I(i)&&i.key&&(r[i.key]=i.value)};return s(e==null?void 0:e.variables),s(t==null?void 0:t.values),{...r,...n}}function ce(e){let t=e.trim(),n="";const r=t.indexOf("#");r>=0&&(n=t.slice(r),t=t.slice(0,r));const s=t.indexOf("?");return s<0?{base:t,query:[],hash:n}:{base:t.slice(0,s),query:ut(t.slice(s+1)),hash:n}}function Mt(e){const t=ce(e).base,n=[],r=t.replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,"").replace(/^\{\{[^}]+\}\}/,"");for(const s of r.matchAll(new RegExp("(?<!\\{)\\{([A-Za-z_][\\w.-]*)\\}(?!\\})|(?:^|\\/):([A-Za-z_][\\w-]*)","g"))){const o=s[1]??s[2];n.includes(o)||n.push(o)}return n}function zt(e){const t=Mt(e.url),n=e.params.filter(s=>s.in!=="path");return[...t.map(s=>e.params.find(o=>o.in==="path"&&o.key===s)??{key:s,value:"",in:"path",required:!0}),...n]}function Wt(e,t){const{base:n,query:r,hash:s}=ce(t),o={...e,url:n+s,params:[...e.params.filter(i=>i.in!=="query"),...r.map(i=>({...i,in:"query"}))]};return{...o,params:zt(o)}}function Mn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xt(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}function $e(e,t=n=>n){const{base:n,query:r,hash:s}=ce(e.url);let o=t(n);for(const a of e.params){if(a.in!=="path"||!I(a))continue;const c=encodeURIComponent(t(a.value)),l=new RegExp(`(^|/):${Mn(a.key)}(?=/|$)`);o=o.split(`{${a.key}}`).join(c).replace(l,(f,u)=>u+c)}const i=[...r,...e.params.filter(a=>a.in==="query"&&I(a))].map(a=>{const c=xt(t(a.key)),l=t(a.value);return l===""&&!("in"in a)?c:`${c}=${xt(l)}`});return o+(i.length?`?${i.join("&")}`:"")+t(s)}function zn(e,t){return e?t?`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`:e:t}function Bt(e){return/^\s*(?:\$\s*)?curl(?:\.exe)?(?:\s|$)/i.test(e)}function Wn(e){return/\^\r?\n/.test(e)||/\^"/.test(e)?"cmd":/`\r?\n/.test(e)||/^\s*curl\.exe\b/i.test(e)?"powershell":"bash"}function Ft(e,t=Wn(e)){var c;let n=e.replace(/\r\n?/g,`
2
+ `);t==="cmd"?n=n.replace(/\^\n/g," ").replace(/\^([\s\S])/g,"$1"):t==="powershell"?n=n.replace(/`\n/g," "):n=n.replace(/\\\n/g," ");const r=[];let s="",o=!1,i=0;const a=()=>{o&&r.push(s),s="",o=!1};for(;i<n.length;){const l=n[i];if(l===" "||l===" "||l===`
3
+ `){a(),i++;continue}if(l==="#"&&!o&&t==="bash"){for(;i<n.length&&n[i]!==`
4
+ `;)i++;continue}if(o=!0,l==="'"&&t!=="cmd"){for(i++;i<n.length;){if(n[i]==="'"){if(t==="powershell"&&n[i+1]==="'"){s+="'",i+=2;continue}break}s+=n[i++]}i++;continue}if(l==="$"&&n[i+1]==="'"&&t==="bash"){for(i+=2;i<n.length&&n[i]!=="'";){if(n[i]==="\\"&&i+1<n.length){const f=n[i+1],u={n:`
5
+ `,t:" ",r:"\r","\\":"\\","'":"'",'"':'"',0:"\0"};if(f==="x"){const d=((c=/^[0-9a-fA-F]{1,2}/.exec(n.slice(i+2)))==null?void 0:c[0])??"";s+=String.fromCharCode(parseInt(d||"0",16)),i+=2+d.length;continue}s+=u[f]??`\\${f}`,i+=2;continue}s+=n[i++]}i++;continue}if(l==='"'){for(i++;i<n.length;){const f=n[i];if(f==='"'){if(t==="powershell"&&n[i+1]==='"'){s+='"',i+=2;continue}break}if(t==="powershell"){if(f==="`"&&i+1<n.length){s+=n[i+1],i+=2;continue}}else if(f==="\\"&&i+1<n.length&&'"\\$`'.includes(n[i+1])){s+=n[i+1],i+=2;continue}s+=f,i++}i++;continue}if(l==="\\"&&t==="bash"&&i+1<n.length){s+=n[i+1],i+=2;continue}s+=l,i++}return a(),r}const Bn=new Set("XHdFubAemoxwTEKrUzCcDYyQt".split("")),Fn=new Set(["request","header","data","data-ascii","data-raw","data-binary","data-urlencode","json","form","form-string","user","cookie","user-agent","referer","max-time","url","url-query","oauth2-bearer","aws-sigv4","output","proxy","proxy-user","write-out","connect-timeout","retry","retry-delay","retry-max-time","cacert","capath","cert","cert-type","key","key-type","pass","resolve","connect-to","interface","limit-rate","upload-file","range","cookie-jar","dump-header","config","max-redirs","unix-socket","request-target","expect100-timeout","keepalive-time","local-port","dns-servers","socks4","socks5","socks5-hostname","preproxy","netrc-file","trace","trace-ascii","stderr","variable","ciphers","speed-limit","speed-time","time-cond","quote","hostpubmd5","pubkey","login-options","sasl-authzid","tls-max"]),St={X:"request",H:"header",d:"data",F:"form",u:"user",b:"cookie",A:"user-agent",e:"referer",m:"max-time",G:"get",k:"insecure",L:"location",I:"head",T:"upload-file",E:"cert"};function dt(e){try{const t=Uint8Array.from(atob(e.trim()),n=>n.charCodeAt(0));return new TextDecoder().decode(t)}catch{return""}}function We(e){const t=new TextEncoder().encode(e);let n="";for(const r of t)n+=String.fromCharCode(r);return btoa(n)}function Vn(e){const t=e.indexOf("@"),n=e.indexOf("=");if(t>=0&&(n<0||t<n))return e;if(n<0)return encodeURIComponent(e);const r=e.slice(0,n),s=encodeURIComponent(e.slice(n+1));return r?`${r}=${s}`:s}function Kn(e,t){const n=e.indexOf("="),r=n<0?e:e.slice(0,n);let s=n<0?"":e.slice(n+1);if(!t&&(s.startsWith("@")||s.startsWith("<"))){const[o,...i]=s.slice(1).split(";"),a={key:r,value:"",type:"file",fileName:o};for(const c of i){const[l,f]=c.split("=");l==="type"&&(a.contentType=f),l==="filename"&&(a.fileName=f)}return a}if(!t){const o=s.indexOf(";type=");if(o>=0){const i={key:r,value:s.slice(0,o),type:"text"};return i.contentType=s.slice(o+6),i}}return s=s.replace(/^"(.*)"$/,"$1"),{key:r,value:s,type:"text"}}function Vt(e){const t=Ft(e.trim());if(t[0]==="$"&&t.shift(),!t.length||!/^curl(\.exe)?$/i.test(t[0]))throw new Error("Not a curl command");let n,r="";const s=[],o=[],i=[],a=[];let c;const l=[];let f,u=!1,d,p,b=!1,$=!1,h=!1;const A={},k=(N,T)=>{switch(N){case"request":n=T==null?void 0:T.toUpperCase();break;case"url":r=T??r;break;case"url-query":T&&i.push(...Nt(T));break;case"header":{if(!T)break;const U=T.indexOf(":");U>0?s.push({key:T.slice(0,U).trim(),value:T.slice(U+1).trim()}):T.endsWith(";")&&s.push({key:T.slice(0,-1).trim(),value:""});break}case"user-agent":s.push({key:"User-Agent",value:T??""});break;case"referer":s.push({key:"Referer",value:T??""});break;case"cookie":if(T!=null&&T.includes("="))for(const U of T.split(";")){const H=U.indexOf("=");H>0&&o.push({key:U.slice(0,H).trim(),value:U.slice(H+1).trim()})}break;case"data":case"data-ascii":case"data-binary":case"data-raw":case"json":if(T===void 0)break;N==="json"&&(h=!0),N!=="data-raw"&&T.startsWith("@")?c=T.slice(1):a.push(N==="data"||N==="data-ascii"?T.replace(/[\r\n]/g,""):T);break;case"data-urlencode":T!==void 0&&a.push(Vn(T));break;case"form":case"form-string":T!==void 0&&l.push(Kn(T,N==="form-string"));break;case"user":f=T;break;case"oauth2-bearer":d=T;break;case"aws-sigv4":p=T;break;case"digest":u=!0;break;case"get":b=!0;break;case"head":$=!0;break;case"insecure":A.insecure=!0;break;case"location":A.followRedirects=!0;break;case"max-time":T&&Number.isFinite(Number(T))&&(A.timeoutMs=Number(T)*1e3);break;case"upload-file":T&&(c=T),n??(n="PUT");break}};for(let N=1;N<t.length;N++){const T=t[N];if(T.startsWith("--")&&T.length>2){const U=T.slice(2),H=Fn.has(U)?t[++N]:void 0;k(U,H)}else if(T.startsWith("-")&&T.length>1)for(let U=1;U<T.length;U++){const H=T[U];if(Bn.has(H)){const y=T.slice(U+1)||t[++N];k(St[H]??H,y);break}k(St[H]??H,void 0)}else r||(r=T)}let x;const g=s.findIndex(N=>N.key.toLowerCase()==="authorization");if(g>=0){const N=s[g].value,T=/^Bearer\s+(.+)$/i.exec(N),U=/^Basic\s+(.+)$/i.exec(N);if(T)x={type:"bearer",token:T[1].trim()},s.splice(g,1);else if(U){const H=dt(U[1]),m=H.indexOf(":");m>=0&&(x={type:"basic",username:H.slice(0,m),password:H.slice(m+1)},s.splice(g,1))}}if(f!==void 0){const N=f.indexOf(":"),T=N<0?f:f.slice(0,N),U=N<0?"":f.slice(N+1);if(p){const[,,H="",m=""]=p.split(":");x={type:"awsSigV4",accessKeyId:T,secretAccessKey:U,region:H,service:m}}else x=u?{type:"digest",username:T,password:U}:{type:"basic",username:T,password:U}}d!==void 0&&(x={type:"bearer",token:d});const S=s.findIndex(N=>N.key.toLowerCase()==="content-type"),w=S>=0?s[S].value:void 0;h&&(S<0&&s.push({key:"Content-Type",value:"application/json"}),s.some(N=>N.key.toLowerCase()==="accept")||s.push({key:"Accept",value:"application/json"}));let O={kind:"none"};if(b&&a.length)i.push(...Nt(a.join("&")));else if(l.length)O={kind:"multipart",parts:l};else if(a.length){const N=a.join(h?"":"&"),T=/^\s*[[{]/.test(N);O=lt(N,w??(h||T?"application/json":"application/x-www-form-urlencoded"))}else c!==void 0&&(O={kind:"binary",fileName:c,contentType:w});const L=n??($?"HEAD":b?"GET":O.kind!=="none"?"POST":"GET"),R=[...s.map(N=>({...N,in:"header"})),...o.map(N=>({...N,in:"cookie"}))];let M=he({name:mt(L,r),method:L,params:R,body:O,auth:x,settings:Object.keys(A).length?A:void 0});return M=Wt(M,r),i.length&&(M={...M,params:[...M.params,...i.map(N=>({...N,in:"query"}))]}),M}function Nt(e){return e.split("&").filter(Boolean).map(t=>{const n=t.indexOf("="),r=s=>{try{return decodeURIComponent(s.replace(/\+/g," "))}catch{return s}};return n<0?{key:r(t),value:""}:{key:r(t.slice(0,n)),value:r(t.slice(n+1))}})}function mt(e,t){const n=t.replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,"").replace(/^\{\{[^}]+\}\}/,"").split("?")[0];return`${e} ${n||"/"}`}function Jn(e){return e==="powershell"?t=>`'${t.replace(/'/g,"''")}'`:e==="cmd"?t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t=>/^[\w./:@%+=,-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function Gn(e,t){const n=[],r=[],s=[];switch(e==null?void 0:e.type){case"basic":n.push(["-u",`${t(e.username)}:${t(e.password)}`]);break;case"digest":n.push(["--digest"],["-u",`${t(e.username)}:${t(e.password)}`]);break;case"bearer":n.push(["-H",`Authorization: ${e.prefix??"Bearer"} ${t(e.token)}`]);break;case"oauth2":e.accessToken&&n.push(["-H",`Authorization: ${e.tokenType??"Bearer"} ${t(e.accessToken)}`]);break;case"apiKey":e.in==="header"?n.push(["-H",`${t(e.key)}: ${t(e.value)}`]):e.in==="query"?r.push({key:e.key,value:e.value}):s.push({key:e.key,value:e.value});break;case"awsSigV4":n.push(["--aws-sigv4",`aws:amz:${t(e.region)}:${t(e.service)}`],["-u",`${t(e.accessKeyId)}:${t(e.secretAccessKey)}`]),e.sessionToken&&n.push(["-H",`x-amz-security-token: ${t(e.sessionToken)}`]);break;case"custom":for(const o of e.headers.filter(I))n.push(["-H",`${t(o.key)}: ${t(o.value)}`]);break;case"mtls":e.certificate&&n.push(["--cert",t(e.certificate)]),e.key&&n.push(["--key",t(e.key)]);break}return{options:n,query:r,cookies:s}}function Ie(e,t={}){var x,g,S;const n=t.shell??"bash",r=t.transform??(w=>w),s=Jn(n),o=Gn(t.auth??e.auth,r),i={...e,params:[...e.params,...o.query.map(w=>({...w,in:"query"}))]},a=$e(i,r),c=[],l=e.method.toUpperCase(),f=e.body.kind!=="none";l==="HEAD"?c.push(["-I"]):!(l==="GET"&&!f)&&!(l==="POST"&&f)&&c.push(["-X",l]);const u=e.params.filter(w=>w.in==="header"&&I(w));for(const w of u)c.push(["-H",`${r(w.key)}: ${r(w.value)}`]);c.push(...o.options);const d=ke(e.body),p=u.some(w=>w.key.toLowerCase()==="content-type"),b=[...e.params.filter(w=>w.in==="cookie"&&I(w)),...o.cookies];b.length&&c.push(["-b",b.map(w=>`${r(w.key)}=${r(w.value)}`).join("; ")]);const $=e.body;switch($.kind){case"none":break;case"form":for(const w of $.fields.filter(I))c.push(["--data-urlencode",`${r(w.key)}=${r(w.value)}`]);break;case"multipart":for(const w of $.parts.filter(I))w.type==="file"?c.push(["-F",`${r(w.key)}=@${w.fileName??w.value}${w.contentType?`;type=${w.contentType}`:""}`]):c.push(["-F",`${r(w.key)}=${r(w.value)}${w.contentType?`;type=${w.contentType}`:""}`]);break;case"binary":!p&&d&&c.push(["-H",`Content-Type: ${d}`]),c.push(["--data-binary",`@${$.fileName??"file"}`]);break;default:{!p&&d&&c.push(["-H",`Content-Type: ${d}`]),$.kind==="soap"&&$.version==="1.1"&&$.action!==void 0&&(u.some(w=>w.key.toLowerCase()==="soapaction")||c.push(["-H",`SOAPAction: "${r($.action)}"`])),c.push(["--data-raw",r(se($)??"")]);break}}(x=e.settings)!=null&&x.followRedirects&&c.push(["-L"]),(g=e.settings)!=null&&g.insecure&&c.push(["-k"]),(S=e.settings)!=null&&S.timeoutMs&&c.push(["-m",String(e.settings.timeoutMs/1e3)]);const A=[`${n==="powershell"?"curl.exe":"curl"} ${s(a)}`,...c.map(([w,O])=>O===void 0?w:`${w} ${s(O)}`)];if(t.multiline===!1)return A.join(" ");const k=n==="cmd"?` ^
6
+ `:n==="powershell"?" `\n ":` \\
7
+ `;return A.join(k)}const Kt=[{id:"curl",label:"cURL (bash)",syntax:"shell"},{id:"curl-cmd",label:"cURL (cmd)",syntax:"bat"},{id:"curl-powershell",label:"cURL (PowerShell)",syntax:"powershell"},{id:"fetch",label:"JavaScript fetch",syntax:"javascript"},{id:"csharp",label:"C# HttpClient",syntax:"csharp"},{id:"powershell",label:"PowerShell",syntax:"powershell"},{id:"python",label:"Python requests",syntax:"python"}];function qe(e,t){var d;const n=t.transform??(p=>p),r=t.auth??e.auth,s=e.params.filter(p=>p.in==="header"&&I(p)).map(p=>[n(p.key),n(p.value)]),o=[],i=e.params.filter(p=>p.in==="cookie"&&I(p)).map(p=>`${n(p.key)}=${n(p.value)}`);let a;switch(r==null?void 0:r.type){case"basic":s.push(["Authorization",`Basic ${We(`${n(r.username)}:${n(r.password)}`)}`]);break;case"bearer":s.push(["Authorization",`${r.prefix??"Bearer"} ${n(r.token)}`]);break;case"oauth2":r.accessToken?s.push(["Authorization",`${r.tokenType??"Bearer"} ${n(r.accessToken)}`]):a="OAuth 2: obtain a token first and send it as Authorization: Bearer <token>.";break;case"apiKey":r.in==="header"?s.push([n(r.key),n(r.value)]):r.in==="query"?o.push({key:r.key,value:r.value,in:"query"}):i.push(`${n(r.key)}=${n(r.value)}`);break;case"custom":for(const p of r.headers.filter(I))s.push([n(p.key),n(p.value)]);break;case"digest":a="Digest auth: the signature is computed per call from the server challenge.";break;case"awsSigV4":a="AWS Signature V4: sign each call (an AWS SDK or a SigV4 signer).";break;case"hmac":a=`HMAC: compute the ${r.header} header per call.`;break;case"mtls":a="Mutual TLS: attach the client certificate in the HTTP client.";break}i.length&&s.push(["Cookie",i.join("; ")]);const c=$e({...e,params:[...e.params,...o]},n),l=e.body,f=((d=s.find(([p])=>p.toLowerCase()==="content-type"))==null?void 0:d[1])??ke(l);l.kind==="soap"&&l.version==="1.1"&&l.action!==void 0&&(s.some(([p])=>p.toLowerCase()==="soapaction")||s.push(["SOAPAction",`"${n(l.action)}"`]));const u=Qn(l,n);return{method:e.method.toUpperCase(),url:c,headers:s,body:u,contentType:f,note:a}}function Qn(e,t){switch(e.kind){case"json":case"xml":return{...e,text:t(e.text)};case"text":return{...e,text:t(e.text)};case"form":return{...e,fields:e.fields.filter(I).map(n=>({...n,key:t(n.key),value:t(n.value)}))};case"multipart":return{...e,parts:e.parts.filter(I).map(n=>({...n,key:t(n.key),value:t(n.value)}))};case"graphql":return{...e,query:t(e.query),variables:e.variables===void 0?void 0:t(e.variables)};case"soap":return{...e,envelope:t(e.envelope)};default:return e}}const re=e=>JSON.stringify(e),F=e=>`@"${e.replace(/"/g,'""')}"`,te=e=>`'${e.replace(/'/g,"''")}'`,X=e=>JSON.stringify(e);function Jt(e,t){return e.split(`
8
+ `).map((n,r)=>r===0?n:t+n).join(`
9
+ `)}function Gt(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return}}function Yn(e){const t=[];e.note&&t.push(`// ${e.note}`);let n="",r;const s=[...e.headers],o=s.some(([a])=>a.toLowerCase()==="content-type");switch(e.body.kind){case"json":{const a=Gt(e.body.text);r=a?`JSON.stringify(${Jt(a," ")})`:re(e.body.text),o||s.push(["Content-Type","application/json"]);break}case"form":n=`const body = new URLSearchParams();
10
+ ${e.body.fields.map(a=>`body.append(${re(a.key)}, ${re(a.value)});`).join(`
11
+ `)}
12
+
13
+ `,r="body";break;case"multipart":n=`const body = new FormData();
14
+ ${e.body.parts.map(a=>a.type==="file"?`body.append(${re(a.key)}, fileInput.files[0]); // ${a.fileName??"file"}`:`body.append(${re(a.key)}, ${re(a.value)});`).join(`
15
+ `)}
16
+
17
+ `,r="body";for(let a=s.length-1;a>=0;a--)s[a][0].toLowerCase()==="content-type"&&s.splice(a,1);break;case"binary":r=`file // ${e.body.fileName??"a File or Blob"}`,!o&&e.contentType&&s.push(["Content-Type",e.contentType]);break;case"none":break;default:r=re(se(e.body)??""),!o&&e.contentType&&s.push(["Content-Type",e.contentType])}n&&t.push(n.trimEnd(),"");const i=[` method: ${re(e.method)},`];return s.length&&i.push(` headers: {
18
+ ${s.map(([a,c])=>` ${re(a)}: ${re(c)},`).join(`
19
+ `)}
20
+ },`),r&&i.push(` body: ${r},`),t.push(`const response = await fetch(${re(e.url)}, {
21
+ ${i.join(`
22
+ `)}
23
+ });`),t.push("const data = await response.text();"),t.join(`
24
+ `)}const Xn=new Set(["content-type","content-length","content-encoding","content-language","content-disposition"]);function Zn(e){const t=[];e.note&&t.push(`// ${e.note}`),t.push("using System.Net.Http;","using System.Text;",""),t.push("using var client = new HttpClient();");const r=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"].includes(e.method)?`HttpMethod.${e.method[0]}${e.method.slice(1).toLowerCase()}`:`new HttpMethod(${F(e.method)})`;t.push(`using var request = new HttpRequestMessage(${r}, ${F(e.url)});`);for(const[o,i]of e.headers)Xn.has(o.toLowerCase())||t.push(`request.Headers.TryAddWithoutValidation(${F(o)}, ${F(i)});`);const s=(e.contentType??"text/plain").split(";")[0].trim();switch(e.body.kind){case"none":break;case"form":t.push("request.Content = new FormUrlEncodedContent(new Dictionary<string, string>","{",...e.body.fields.map(o=>` [${F(o.key)}] = ${F(o.value)},`),"});");break;case"multipart":t.push("var form = new MultipartFormDataContent();");for(const o of e.body.parts)t.push(o.type==="file"?`form.Add(new StreamContent(File.OpenRead(${F(o.fileName??"file")})), ${F(o.key)}, ${F(o.fileName??"file")});`:`form.Add(new StringContent(${F(o.value)}), ${F(o.key)});`);t.push("request.Content = form;");break;case"binary":t.push(`request.Content = new StreamContent(File.OpenRead(${F(e.body.fileName??"file")}));`),t.push(`request.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(${F(s)});`);break;default:t.push(`request.Content = new StringContent(${F(se(e.body)??"")}, Encoding.UTF8, ${F(s)});`)}return t.push("","using var response = await client.SendAsync(request);","response.EnsureSuccessStatusCode();","var body = await response.Content.ReadAsStringAsync();"),t.join(`
25
+ `)}function er(e){const t=[];e.note&&t.push(`# ${e.note}`);const n=e.headers.filter(([s])=>s.toLowerCase()!=="content-type");n.length&&t.push("$headers = @{",...n.map(([s,o])=>` ${te(s)} = ${te(o)}`),"}");const r=[`-Uri ${te(e.url)}`,`-Method ${e.method[0]}${e.method.slice(1).toLowerCase()}`];switch(n.length&&r.push("-Headers $headers"),e.body.kind){case"none":break;case"form":t.push("$body = @{",...e.body.fields.map(s=>` ${te(s.key)} = ${te(s.value)}`),"}"),r.push("-Body $body");break;case"multipart":t.push("$form = @{",...e.body.parts.map(s=>s.type==="file"?` ${te(s.key)} = Get-Item ${te(s.fileName??"file")}`:` ${te(s.key)} = ${te(s.value)}`),"}"),r.push("-Form $form");break;case"binary":r.push(`-InFile ${te(e.body.fileName??"file")}`),e.contentType&&r.push(`-ContentType ${te(e.contentType)}`);break;default:t.push(`$body = @'
26
+ ${se(e.body)??""}
27
+ '@`),r.push("-Body $body"),e.contentType&&r.push(`-ContentType ${te(e.contentType)}`)}return t.push(`$response = Invoke-RestMethod ${r.join(" ")}`),t.join(`
28
+ `)}function tr(e){const t=[];e.note&&t.push(`# ${e.note}`),t.push("import requests","");const n=[` ${X(e.method)},`,` ${X(e.url)},`],r=[...e.headers];switch(e.body.kind){case"none":break;case"json":{const s=Gt(e.body.text);if(s){const o=s.replace(/\btrue\b/g,"True").replace(/\bfalse\b/g,"False").replace(/\bnull\b/g,"None");n.push(` json=${Jt(o," ")},`);for(let i=r.length-1;i>=0;i--)r[i][0].toLowerCase()==="content-type"&&r.splice(i,1)}else n.push(` data=${X(e.body.text)},`);break}case"form":n.push(` data={${e.body.fields.map(s=>`${X(s.key)}: ${X(s.value)}`).join(", ")}},`);break;case"multipart":{const s=e.body.parts.filter(i=>i.type==="file"),o=e.body.parts.filter(i=>i.type!=="file");o.length&&n.push(` data={${o.map(i=>`${X(i.key)}: ${X(i.value)}`).join(", ")}},`),s.length&&n.push(` files={${s.map(i=>`${X(i.key)}: open(${X(i.fileName??"file")}, "rb")`).join(", ")}},`);for(let i=r.length-1;i>=0;i--)r[i][0].toLowerCase()==="content-type"&&r.splice(i,1);break}case"binary":n.push(` data=open(${X(e.body.fileName??"file")}, "rb"),`);break;default:n.push(` data=${X(se(e.body)??"")},`),e.contentType&&!r.some(([s])=>s.toLowerCase()==="content-type")&&r.push(["Content-Type",e.contentType])}return r.length&&n.splice(2,0,` headers={
29
+ ${r.map(([s,o])=>` ${X(s)}: ${X(o)},`).join(`
30
+ `)}
31
+ },`),t.push(`response = requests.request(
32
+ ${n.join(`
33
+ `)}
34
+ )`,"print(response.status_code, response.text)"),t.join(`
35
+ `)}function Qt(e,t,n={}){switch(t){case"curl":return Ie(e,{...n,shell:"bash"});case"curl-cmd":return Ie(e,{...n,shell:"cmd"});case"curl-powershell":return Ie(e,{...n,shell:"powershell"});case"fetch":return Yn(qe(e,n));case"csharp":return Zn(qe(e,n));case"powershell":return er(qe(e,n));case"python":return tr(qe(e,n));default:return""}}class Q extends Error{constructor(t,n){super(`${t} (line ${n})`),this.line=n,this.name="NiceYamlError"}}function Ot(e){let t=null;for(let n=0;n<e.length;n++){const r=e[n];if(t){if(r===t){if(t==="'"&&e[n+1]==="'"){n++;continue}t=null}else r==="\\"&&t==='"'&&n++;continue}if((r==='"'||r==="'")&&(n===0||/[\s:[{,-]/.test(e[n-1])))t=r;else if(r==="#"&&(n===0||/\s/.test(e[n-1])))return e.slice(0,n).trimEnd()}return e.trimEnd()}const nr=new Set(["","~","null","Null","NULL"]);function Be(e){if(nr.has(e))return null;if(/^(true|True|TRUE)$/.test(e))return!0;if(/^(false|False|FALSE)$/.test(e))return!1;if(/^[-+]?[0-9]+$/.test(e)){const t=Number(e);return Number.isSafeInteger(t)?t:e}return/^0x[0-9a-fA-F]+$/.test(e)?parseInt(e.slice(2),16):/^0o[0-7]+$/.test(e)?parseInt(e.slice(2),8):/^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$/.test(e)?Number(e):/^[-+]?\.(inf|Inf|INF)$/.test(e)?e.startsWith("-")?-1/0:1/0:/^\.(nan|NaN|NAN)$/.test(e)?NaN:e}function Ze(e,t){let n="";for(let r=0;r<e.length;r++){const s=e[r];if(s!=="\\"){n+=s;continue}const o=e[++r],i={n:`
36
+ `,t:" ",r:"\r",0:"\0",'"':'"',"\\":"\\","/":"/"," ":" ",b:"\b",f:"\f",e:"\x1B",a:"\x07",v:"\v",N:"…",_:" "};if(o in i)n+=i[o];else if(o==="x"||o==="u"||o==="U"){const a=o==="x"?2:o==="u"?4:8,c=e.slice(r+1,r+1+a);if(!/^[0-9a-fA-F]+$/.test(c)||c.length!==a)throw new Q("Bad escape",t);n+=String.fromCodePoint(parseInt(c,16)),r+=a}else if(o!==`
37
+ `)throw new Q(`Unknown escape \\${o}`,t)}return n}function Ve(e){let t="",n=0;return e.forEach((r,s)=>{const o=s===0?r.trimEnd():s===e.length-1?r.trimStart():r.trim();if(s>0&&o===""&&s<e.length-1){n++;return}s>0&&(t+=n?`
38
+ `.repeat(n):" "),n=0,t+=o}),t}class rr{constructor(t){Ae(this,"lines");Ae(this,"i",0);Ae(this,"anchors",new Map);this.lines=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
39
+ `).split(`
40
+ `).map((n,r)=>{const s=n.length-n.replace(/^ +/,"").length,o=n.slice(s);if(o.startsWith(" "))throw new Q("Tabs cannot indent YAML",r+1);return{indent:s,raw:o,text:Ot(o),num:r+1}})}skipBlank(){for(;this.i<this.lines.length&&this.lines[this.i].text==="";)this.i++}current(){return this.skipBlank(),this.lines[this.i]}parseDocument(){let t=this.current();for(;t&&(t.text.startsWith("%")||t.text==="---"||t.text.startsWith("--- "));){if(t.text.startsWith("--- ")){this.lines[this.i]={...t,raw:t.raw.slice(4),text:t.text.slice(4),indent:t.indent+4};break}this.i++,t=this.current()}if(!t||t.text==="...")return null;const n=this.parseBlock(-1),r=this.current();if(r&&r.text!=="..."&&r.text!=="---")throw new Q(`Unexpected text: ${r.text.slice(0,40)}`,r.num);return n}parseBlock(t){const n=this.current();return!n||n.indent<=t?null:n.text==="-"||n.text.startsWith("- ")?this.parseSequence(n.indent):this.splitKey(n.text)?this.parseMapping(n.indent):(this.i++,this.parseValue(n.text,t,n))}splitKey(t){if(t.startsWith('"')||t.startsWith("'")){const s=t[0];let o=1;for(;o<t.length;){if(t[o]==="\\"&&s==='"'){o+=2;continue}if(t[o]===s){if(s==="'"&&t[o+1]==="'"){o+=2;continue}break}o++}const i=t.slice(o+1),a=/^\s*:(\s|$)/.exec(i);if(!a)return null;const c=t.slice(1,o);return{key:s==='"'?Ze(c,0):c.replace(/''/g,"'"),rest:i.slice(a[0].length).trim()}}if(/^[[{]/.test(t)||/^\?\s+(.*)$/.exec(t))return null;const r=/^(.*?)\s*:(?:\s+|$)/.exec(t);return!r||r[1]===""||r[1].includes(" #")?null:{key:r[1],rest:t.slice(r[0].length).trim()}}parseMapping(t){const n={};for(let s=this.current();s&&s.indent===t;s=this.current()){const o=this.splitKey(s.text);if(!o){if(s.text==="-"||s.text.startsWith("- "))break;throw new Q(`Expected "key: value": ${s.text.slice(0,40)}`,s.num)}this.i++;const i=this.parseValue(o.rest,t,s,!0);if(o.key==="<<"){const a=Array.isArray(i)?i:[i];for(const c of a)if(c&&typeof c=="object"&&!Array.isArray(c))for(const[l,f]of Object.entries(c))l in n||(n[l]=f)}else n[o.key]=i}const r=this.current();if(r&&r.indent>t)throw new Q("Bad indentation",r.num);return n}parseSequence(t){const n=[];for(let r=this.current();r&&r.indent===t&&(r.text==="-"||r.text.startsWith("- "));r=this.current()){const s=r.text==="-"?"":r.text.slice(2).trimStart(),o=t+(r.text.length-s.length);if(s===""){this.i++,n.push(this.parseNested(t));continue}if(!this.takeAnchor(s).anchor&&(s==="-"||s.startsWith("- ")||this.splitKey(s))){this.lines[this.i]={...r,indent:o,raw:r.raw.slice(o-r.indent),text:s},n.push(s==="-"||s.startsWith("- ")?this.parseSequence(o):this.parseMapping(o));continue}this.i++,n.push(this.parseValue(s,t,r))}return n}takeAnchor(t){let n=t,r;for(;;){const s=/^&([^\s[\]{},]+)\s*/.exec(n);if(s){r=s[1],n=n.slice(s[0].length);continue}const o=/^!!?[^\s]*\s*/.exec(n);if(o&&n.startsWith("!")){n=n.slice(o[0].length);continue}return{anchor:r,rest:n}}}parseNested(t,n=!1){const r=this.current();return r?r.indent>t?this.parseBlock(t):n&&r.indent===t&&(r.text==="-"||r.text.startsWith("- "))?this.parseSequence(t):null:null}parseValue(t,n,r,s=!1){const{anchor:o,rest:i}=this.takeAnchor(t);let a;if(i==="")a=this.parseNested(n,s);else if(i.startsWith("*")){const c=i.slice(1).trim();if(!this.anchors.has(c))throw new Q(`Unknown alias *${c}`,r.num);a=this.anchors.get(c)}else/^[|>]/.test(i)?a=this.parseBlockScalar(i,n,r):i.startsWith("[")||i.startsWith("{")?a=this.parseFlowLines(i,r):i.startsWith('"')||i.startsWith("'")?a=this.parseQuotedLines(i,r):a=this.parsePlainLines(i,n);return o&&this.anchors.set(o,a),a}parseBlockScalar(t,n,r){const s=/^([|>])([1-9])?([-+])?([1-9])?\s*$/.exec(t);if(!s)throw new Q(`Bad block scalar header ${t}`,r.num);const o=s[1]===">",i=s[3]??"",a=Number(s[2]??s[4]??0),c=[];let l=a?n+a:-1;for(;this.i<this.lines.length;){const d=this.lines[this.i],p=d.raw.trim()==="";if(!p){if(l<0){if(d.indent<=n)break;l=d.indent}if(d.indent<l)break}c.push(p?"":" ".repeat(d.indent-l)+d.raw),this.i++}let f=0;for(;c.length&&c[c.length-1]==="";)c.pop(),f++;let u;return o?(u="",c.forEach((d,p)=>{if(p===0){u=d;return}const b=c[p-1],$=d.startsWith(" ")||b.startsWith(" ");d===""?u+=`
41
+ `:b===""||$?u+=(b===""?"":`
42
+ `)+d:u+=` ${d}`})):u=c.join(`
43
+ `),c.length?i==="-"?u:i==="+"?`${u}
44
+ ${`
45
+ `.repeat(f)}`:`${u}
46
+ `:i==="+"?`
47
+ `.repeat(f):""}parseQuotedLines(t,n){const r=t[0],s=[];let o=t.slice(1),i=n.num;for(;;){const a=this.findClosingQuote(o,r);if(a>=0){s.push(o.slice(0,a));const l=Ot(o.slice(a+1)).trim();if(l)throw new Q(`Text after a quoted scalar: ${l.slice(0,20)}`,i);break}if(s.push(o),this.i>=this.lines.length)throw new Q("Unclosed quote",n.num);const c=this.lines[this.i++];o=c.raw,i=c.num}if(r==='"'){const a=[];for(const c of s)a.length&&a[a.length-1].endsWith("\\")&&!a[a.length-1].endsWith("\\\\")?a[a.length-1]=a[a.length-1].slice(0,-1)+c.trimStart():a.push(c);return Ze(Ve(a),n.num)}return Ve(s).replace(/''/g,"'")}findClosingQuote(t,n){for(let r=0;r<t.length;r++){if(n==='"'&&t[r]==="\\"){r++;continue}if(t[r]===n){if(n==="'"&&t[r+1]==="'"){r++;continue}return r}}return-1}parsePlainLines(t,n){const r=[t];for(;this.i<this.lines.length;){const s=this.lines[this.i];if(s.text===""){let o=this.i;for(;o<this.lines.length&&this.lines[o].text==="";)o++;const i=this.lines[o];if(i&&i.indent>n&&!this.splitKey(i.text)&&!i.text.startsWith("- ")){r.push(...Array.from({length:o-this.i},()=>"")),this.i=o;continue}break}if(s.indent<=n||this.splitKey(s.text)||s.text.startsWith("- "))break;r.push(s.text),this.i++}return r.length===1?Be(t):Ve(r)}parseFlowLines(t,n){let r=t;for(;!sr(r);){if(this.i>=this.lines.length)throw new Q("Unclosed flow collection",n.num);r+=` ${this.lines[this.i++].text}`}const s=new ir(r,n.num,this.anchors),o=s.parseValue();if(s.skipSpace(),!s.atEnd())throw new Q("Text after a flow collection",n.num);return o}}function sr(e){let t=0,n=null;for(let r=0;r<e.length;r++){const s=e[r];if(n){s==="\\"&&n==='"'?r++:s===n&&(n=null);continue}s==='"'||s==="'"?n=s:s==="["||s==="{"?t++:(s==="]"||s==="}")&&t--}return t<=0&&!n}class ir{constructor(t,n,r){Ae(this,"pos",0);this.text=t,this.line=n,this.anchors=r}atEnd(){return this.pos>=this.text.length}skipSpace(){for(;this.pos<this.text.length&&/\s/.test(this.text[this.pos]);)this.pos++}fail(t){throw new Q(t,this.line)}parseValue(){this.skipSpace();const t=this.text[this.pos];if(t==="[")return this.parseSeq();if(t==="{")return this.parseMap();if(t==='"'||t==="'")return this.parseQuoted();if(t==="*"){this.pos++;const n=/^[^\s,\]}]+/.exec(this.text.slice(this.pos));return this.pos+=(n==null?void 0:n[0].length)??0,this.anchors.get((n==null?void 0:n[0])??"")}return Be(this.parsePlain(!1))}parseQuoted(){const t=this.text[this.pos++];let n="";for(;this.pos<this.text.length;){const r=this.text[this.pos];if(t==='"'&&r==="\\"){n+=r+this.text[this.pos+1],this.pos+=2;continue}if(r===t){if(t==="'"&&this.text[this.pos+1]==="'"){n+="'",this.pos+=2;continue}return this.pos++,t==='"'?Ze(n,this.line):n}n+=r,this.pos++}return this.fail("Unclosed quote")}parsePlain(t){const n=this.pos;for(;this.pos<this.text.length;){const r=this.text[this.pos];if(r===","||r==="]"||r==="}"||r===":"&&(t||/[\s,\]}]/.test(this.text[this.pos+1]??" ")))break;this.pos++}return this.text.slice(n,this.pos).trim()}parseSeq(){this.pos++;const t=[];for(;;){if(this.skipSpace(),this.text[this.pos]==="]")return this.pos++,t;t.push(this.parseValue()),this.skipSpace(),this.text[this.pos]===","?this.pos++:this.text[this.pos]!=="]"&&this.fail("Expected , or ]")}}parseMap(){this.pos++;const t={};for(;;){if(this.skipSpace(),this.text[this.pos]==="}")return this.pos++,t;const n=this.text[this.pos],r=n==='"'||n==="'"?this.parseQuoted():this.parsePlain(!0);this.skipSpace();let s=null;this.text[this.pos]===":"&&(this.pos++,this.skipSpace(),s=this.text[this.pos]===","||this.text[this.pos]==="}"?null:this.parseValue()),t[String(r)]=s,this.skipSpace(),this.text[this.pos]===","?this.pos++:this.text[this.pos]!=="}"&&this.fail("Expected , or }")}}}function Yt(e){return new rr(e).parseDocument()}function Xt(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<32&&n!==9&&n!==10&&n!==13)return!0}return!1}const or=/^[-?:,[\]{}#&*!|>'"%@`]/;function Zt(e){return e===""||e!==e.trim()||or.test(e)||/: |:$| #|[\t\n\r]/.test(e)||Xt(e)||typeof Be(e)!="string"}function ar(e){if(e==null)return"null";if(typeof e=="number")return Number.isNaN(e)?".nan":Number.isFinite(e)?String(e):e>0?".inf":"-.inf";if(typeof e=="boolean")return String(e);const t=String(e);return Zt(t)?JSON.stringify(t):t}function cr(e){return Zt(e)?JSON.stringify(e):e}function jt(e){return Array.isArray(e)?e.length>0:!!e&&typeof e=="object"&&Object.keys(e).length>0}function et(e,t,n,r){const s=" ".repeat(t);if(Array.isArray(e)){if(!e.length){n.push(`${r}[]`);return}r&&n.push(r.trimEnd());for(const o of e)if(jt(o)){const i=[];et(o,t+2,i,""),n.push(`${s}- ${i[0].trimStart()}`,...i.slice(1))}else Ke(o,t,n,`${s}- `);return}if(e&&typeof e=="object"){const o=Object.entries(e).filter(([,i])=>i!==void 0);if(!o.length){n.push(`${r}{}`);return}r&&n.push(r.trimEnd());for(const[i,a]of o){const c=`${s}${cr(i)}:`;jt(a)?et(a,Array.isArray(a)?t:t+2,n,c):Ke(a,t,n,`${c} `)}return}Ke(e,t,n,r)}function Ke(e,t,n,r){if(Array.isArray(e)){n.push(`${r}[]`);return}if(e&&typeof e=="object"){n.push(`${r}{}`);return}if(typeof e=="string"&&e.includes(`
48
+ `)&&!Xt(e)){const s=e.endsWith(`
49
+ `),o=(s?e.slice(0,-1):e).split(`
50
+ `),i=o[0].startsWith(" "),a=" ".repeat(t+2),c=s?e.endsWith(`
51
+
52
+ `)?"+":"":"-";n.push(`${r}|${i?"2":""}${c}`);for(const l of o)n.push(l?a+l:"");return}n.push(r+ar(e))}function en(e){const t=[];return et(e,0,t,""),`${t.join(`
53
+ `)}
54
+ `}function Re(e,t=Yt){const n=e.trimStart();if(n.startsWith("{")||n.startsWith("["))try{return JSON.parse(n)}catch{}return t(e)}function ht(e){return t=>{var r;const n=(r=/^#\/(?:components\/schemas|definitions)\/(.+)$/.exec(t))==null?void 0:r[1];return n?e==null?void 0:e[decodeURIComponent(n.replace(/~1/g,"/").replace(/~0/g,"~"))]:void 0}}function pr(e){if(Array.isArray(e.type))return e.type.find(t=>t!=="null")??e.type[0];if(e.type)return e.type;if(e.properties||e.additionalProperties)return"object";if(e.items)return"array"}function lr(e,t){switch(e.format){case"email":return"user@example.com";case"date":return t().toISOString().slice(0,10);case"date-time":return t().toISOString();case"time":return t().toISOString().slice(11,19);case"uuid":return"3fa85f64-5717-4562-b3fc-2c963f66afa6";case"uri":case"url":return"https://example.com";case"hostname":return"example.com";case"ipv4":return"192.168.0.1";case"ipv6":return"::1";case"byte":return"U3dhZ2dlciByb2Nrcw==";case"binary":return"";case"password":return"********";default:{const n=e.title??"string";return e.minLength&&n.length<e.minLength?n.padEnd(e.minLength,"x"):e.maxLength&&n.length>e.maxLength?n.slice(0,e.maxLength):n}}}function yt(e,t={}){const n=t.maxDepth??6,r=t.arrayItems??1,s=t.now??(()=>new Date),o=(i,a,c)=>{var f,u,d,p,b,$;if(!i)return null;if(i.$ref){if(c.has(i.$ref)||a>n)return null;const h=(f=t.resolveRef)==null?void 0:f.call(t,i.$ref);return h?o(h,a,new Set([...c,i.$ref])):null}if(i.example!==void 0)return i.example;if((u=i.examples)!=null&&u.length)return i.examples[0];if(i.const!==void 0)return i.const;if(i.default!==void 0)return i.default;if((d=i.enum)!=null&&d.length)return i.enum[0];if((p=i.allOf)!=null&&p.length){const h={};let A;for(const k of i.allOf){const x=o(k,a,c);x&&typeof x=="object"&&!Array.isArray(x)?Object.assign(h,x):x!=null&&(A=x)}return i.properties&&Object.assign(h,o({...i,allOf:void 0},a,c)),Object.keys(h).length?h:A??null}const l=((b=i.oneOf)==null?void 0:b[0])??(($=i.anyOf)==null?void 0:$[0]);if(l)return o(l,a,c);switch(pr(i)){case"string":return lr(i,s);case"integer":return i.minimum??0;case"number":return i.minimum??0;case"boolean":return!0;case"array":return a>=n?[]:Array.from({length:r},()=>o(i.items,a+1,c));case"object":{if(a>=n)return{};const h={};for(const[A,k]of Object.entries(i.properties??{}))t.usage==="request"&&k.readOnly||t.usage==="response"&&k.writeOnly||(h[A]=o(k,a+1,c));return!i.properties&&i.additionalProperties&&typeof i.additionalProperties=="object"&&(h.key=o(i.additionalProperties,a+1,c)),h}case"null":return null;default:return null}};return o(e,0,new Set)}function He(e){if(e===null)return{type:"null"};if(Array.isArray(e))return e.length?{type:"array",items:He(e[0])}:{type:"array"};switch(typeof e){case"string":return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(e)?{type:"string",format:"date-time"}:/^\d{4}-\d{2}-\d{2}$/.test(e)?{type:"string",format:"date"}:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?{type:"string",format:"uuid"}:/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)?{type:"string",format:"email"}:{type:"string"};case"number":return{type:Number.isInteger(e)?"integer":"number"};case"boolean":return{type:"boolean"};case"object":{const t={};for(const[n,r]of Object.entries(e))t[n]=He(r);return{type:"object",properties:t}}default:return{}}}function ur(e,t){var l;const n=(l=e.examples)==null?void 0:l[0];if(n){const f={};for(const u of n.headers??[])f[u.key]=u.value;return{status:n.status,headers:f,body:n.body??""}}const r=Object.entries(e.responses??{}),[s,o]=r.find(([f])=>/^2\d\d$/.test(f))??r.find(([f])=>f==="default")??["200",void 0],i=/^\d{3}$/.test(s)?Number(s):200;if(!o)return{status:i,headers:{},body:""};const a=o.contentType??"application/json";let c=o.example??"";if(!c&&o.schema){const f=yt(o.schema,{resolveRef:ht(t==null?void 0:t.schemas),usage:"response"});c=typeof f=="string"?f:JSON.stringify(f,null,2)}return{status:i,headers:{"Content-Type":a},body:c}}const j=e=>!!e&&typeof e=="object"&&!Array.isArray(e),z=e=>typeof e=="string"?e:void 0,tn=["get","put","post","delete","options","head","patch","trace"],fr=["query","path","header","cookie"];function tt(e,t){const n=t.indexOf("#"),r=n>=0?t.slice(n+1):"";if(!r||r==="/")return e;let s=e;for(const o of r.split("/").slice(1)){const i=decodeURIComponent(o).replace(/~1/g,"/").replace(/~0/g,"~");if(j(s))s=s[i];else if(Array.isArray(s))s=s[Number(i)];else return}return s}function ue(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function Je(e){const t=Object.keys(e),n=[r=>r==="application/json",r=>/\+json$|\/json/.test(r),r=>r==="application/x-www-form-urlencoded",r=>r==="multipart/form-data",r=>/xml/.test(r),r=>r.startsWith("text/"),()=>!0];for(const r of n){const s=t.find(r);if(s)return[s,j(e[s])?e[s]:{}]}}function nn(e,t={}){var T,U,H;let n=typeof e=="string"?Re(e,t.parseYaml):e;if(!j(n))throw new Error("Not an OpenAPI document");if(typeof n.swagger=="string")n=rn(n);else if(typeof n.openapi!="string")throw new Error('Not an OpenAPI document: no "openapi" or "swagger" version');const r=n,s=t.baseUrlVariable??"baseUrl",o=new Map,i=m=>{var v;if(m.startsWith("#"))return tt(r,m);const y=m.split("#")[0];if(!o.has(y)){const _=(v=t.resolveRef)==null?void 0:v.call(t,y);o.set(y,typeof _=="string"?Re(_,t.parseYaml):_)}return tt(o.get(y),m)},a=m=>{let y=m;for(let v=0;v<20&&j(y)&&typeof y.$ref=="string";v++)y=i(y.$ref);return y},c=(m,y=0)=>{if(!j(m))return;if(typeof m.$ref=="string")return/^#\/components\/schemas\//.test(m.$ref)?{$ref:m.$ref}:y>12?{}:c(i(m.$ref),y+1);const v={...m};if(j(m.properties)){v.properties={};for(const[_,C]of Object.entries(m.properties))v.properties[_]=c(C,y+1)??{}}m.items!==void 0&&(v.items=c(m.items,y+1)),j(m.additionalProperties)&&(v.additionalProperties=c(m.additionalProperties,y+1));for(const _ of["allOf","oneOf","anyOf"]){const C=m[_];Array.isArray(C)&&(v[_]=C.map(q=>c(q,y+1)??{}))}return v},l=j(r.components)?r.components:{},f={};if(j(l.schemas))for(const[m,y]of Object.entries(l.schemas))f[m]=c(y)??{};const u=ht(f),d=m=>{if(!j(m))return;const y=Object.values(m)[0],v=a(y);return j(v)?v.value:void 0},p=new Map,b=(m,y=!1)=>(p.has(m)||p.set(m,{key:m,value:"",secret:y||void 0}),`{{${m}}}`),$=j(l.securitySchemes)?l.securitySchemes:{},h=(m,y)=>{const v=a($[m]);if(!j(v))return;const _=m.replace(/[^\w.-]/g,"_");switch(v.type){case"apiKey":{const C=v.in==="query"||v.in==="cookie"?v.in:"header";return{type:"apiKey",key:z(v.name)??"X-API-Key",value:b(_,!0),in:C}}case"http":{const C=(z(v.scheme)??"").toLowerCase();return C==="basic"?{type:"basic",username:b("username"),password:b("password",!0)}:C==="digest"?{type:"digest",username:b("username"),password:b("password",!0)}:C==="bearer"?{type:"bearer",token:b(_,!0)}:{type:"custom",headers:[{key:"Authorization",value:`${z(v.scheme)??""} ${b(_,!0)}`}]}}case"oauth2":{const C=j(v.flows)?v.flows:{},P=["authorizationCode","clientCredentials","password","implicit"].find(ie=>j(C[ie]))??"clientCredentials",D=C[P]??{},B=Array.isArray(y)&&y.length?y.join(" "):void 0;return{type:"oauth2",grant:P,tokenUrl:z(D.tokenUrl),authUrl:z(D.authorizationUrl),clientId:b("clientId"),clientSecret:P==="implicit"?void 0:b("clientSecret",!0),scope:B,usePkce:P==="authorizationCode"||void 0,username:P==="password"?b("username"):void 0,password:P==="password"?b("password",!0):void 0}}case"openIdConnect":return{type:"oauth2",grant:"authorizationCode",authUrl:z(v.openIdConnectUrl),clientId:b("clientId"),usePkce:!0,scope:Array.isArray(y)&&y.length?y.join(" "):"openid"};case"mutualTLS":return{type:"mtls"};default:return}},A=m=>{if(Array.isArray(m)){if(!m.length)return{type:"none"};for(const y of m){if(!j(y))continue;const v=Object.keys(y);if(!v.length)return{type:"none"};const _=h(v[0],y[v[0]]);if(_)return _}}},k=m=>{var B,ie;const y=a(m);if(!j(y)||typeof y.name!="string")return null;const v=fr.find(oe=>oe===y.in);if(!v||v==="header"&&/^(accept|content-type|authorization)$/i.test(y.name))return null;const _=c(y.schema)??(j(y.content)?c((B=Je(y.content))==null?void 0:B[1].schema):void 0),C=_!=null&&_.$ref?u(_.$ref):_,q=y.example??d(y.examples)??(C==null?void 0:C.example)??(C==null?void 0:C.default)??((ie=C==null?void 0:C.enum)==null?void 0:ie[0]),P=v==="path"||y.required===!0,D={key:y.name,value:ue(q),in:v};return P&&(D.required=!0),!P&&q===void 0&&(D.enabled=!1),typeof y.description=="string"&&(D.description=y.description),_&&(D.schema=_),typeof y.style=="string"&&(D.style=y.style),typeof y.explode=="boolean"&&(D.explode=y.explode),D},x=(m,y)=>{const v=c(y.schema),_=y.example??d(y.examples),C=_!==void 0?_:yt(v,{resolveRef:u,usage:"request"}),q=P=>{const D=P!=null&&P.$ref?u(P.$ref):P;return(D==null?void 0:D.properties)??{}};if(m==="application/x-www-form-urlencoded"){const P=j(C)?C:{};return{kind:"form",fields:(Object.keys(P).length?Object.keys(P):Object.keys(q(v))).map(B=>({key:B,value:ue(P[B])}))}}if(m.startsWith("multipart/")){const P=j(C)?C:{};return{kind:"multipart",parts:Object.entries(q(v)).map(([D,B])=>{var oe;return B.format==="binary"||B.format==="base64"||B.contentMediaType!==void 0||B.type==="array"&&((oe=B.items)==null?void 0:oe.format)==="binary"?{key:D,value:"",type:"file"}:{key:D,value:ue(P[D]),type:"text"}})}}return/json/.test(m)?{kind:"json",text:typeof C=="string"?C:JSON.stringify(C??{},null,2)}:m==="application/graphql"?{kind:"graphql",query:ue(C)}:/xml/.test(m)?{kind:"xml",text:typeof C=="string"?C:""}:m.startsWith("text/")?{kind:"text",text:ue(C),contentType:m==="text/plain"?void 0:m}:{kind:"binary",contentType:m}},g=m=>{const y=a(m);if(!j(y))return{};const v={};typeof y.description=="string"&&(v.description=y.description);const _=j(y.content)?Je(y.content):void 0;if(_){const[C,q]=_;v.contentType=C;const P=c(q.schema);P&&(v.schema=P);const D=q.example??d(q.examples);D!==void 0&&(v.example=typeof D=="string"?D:JSON.stringify(D,null,2))}return j(y.headers)&&(v.headers=Object.entries(y.headers).map(([C,q])=>{const P=a(q);return{key:C,value:"",description:j(P)?z(P.description):void 0}})),v},S=A(r.security),w=[],O=j(r.paths)?r.paths:{};for(const[m,y]of Object.entries(O)){const v=a(y);if(!j(v))continue;const _=Array.isArray(v.parameters)?v.parameters:[];for(const C of tn){const q=v[C];if(!j(q))continue;const P=[];for(const Y of[..._,...Array.isArray(q.parameters)?q.parameters:[]]){const pe=k(Y);if(!pe)continue;const vt=P.findIndex(Tt=>Tt.key===pe.key&&Tt.in===pe.in);vt>=0?P[vt]=pe:P.push(pe)}let D={kind:"none"};const B=a(q.requestBody);if(j(B)&&j(B.content)){const Y=Je(B.content);Y&&(D=x(Y[0],Y[1]),((T=ke(D))==null?void 0:T.split(";")[0])!==Y[0]&&D.kind!=="multipart"&&P.push({key:"Content-Type",value:Y[0],in:"header"}))}const ie={};if(j(q.responses))for(const[Y,pe]of Object.entries(q.responses))ie[Y]=g(pe);const oe=(U=Object.entries(ie).find(([Y])=>/^2/.test(Y)))==null?void 0:U[1];oe!=null&&oe.contentType&&oe.contentType!=="*/*"&&P.push({key:"Accept",value:oe.contentType,in:"header"});let Ue=A(q.security);Ue&&S&&JSON.stringify(Ue)===JSON.stringify(S)&&(Ue=void 0);const le=Array.isArray(q.tags)?q.tags.filter(Y=>typeof Y=="string"):void 0,Cn=he({name:z(q.summary)??z(q.operationId)??`${C.toUpperCase()} ${m}`,method:C.toUpperCase(),url:`{{${s}}}${m}`,params:P,body:D,auth:Ue,description:z(q.description),operationId:z(q.operationId),tags:le!=null&&le.length?le:void 0,deprecated:q.deprecated===!0||void 0,responses:Object.keys(ie).length?ie:void 0});w.push({request:Cn,tag:le==null?void 0:le[0],segment:m.split("/").filter(Boolean)[0]})}}const L=[],R=t.groupBy??"tag";if(R==="none")L.push(...w.map(m=>m.request));else{const m=new Map,y=Array.isArray(r.tags)?r.tags.filter(j):[];if(R==="tag")for(const v of y)typeof v.name=="string"&&m.set(v.name,ye({name:v.name,description:z(v.description)}));for(const{request:v,tag:_,segment:C}of w){const q=R==="tag"?_:C;if(!q){L.push(v);continue}m.has(q)||m.set(q,ye({name:q})),m.get(q).items.push(v)}L.unshift(...[...m.values()].filter(v=>v.items.length))}const M=(Array.isArray(r.servers)?r.servers.filter(j):[]).map(m=>{let y=z(m.url)??"";if(j(m.variables))for(const[v,_]of Object.entries(m.variables))j(_)&&(y=y.split(`{${v}}`).join(ue(_.default)));return{url:y,description:z(m.description)}}),N=j(r.info)?r.info:{};return be({name:z(N.title)??"API",description:z(N.description),version:N.version===void 0?void 0:ue(N.version),items:L,variables:[{key:s,value:((H=M[0])==null?void 0:H.url)??""},...p.values()],auth:S,servers:M.length?M:void 0,schemas:Object.keys(f).length?f:void 0})}function rn(e){const t=h=>{if(Array.isArray(h))return h.map(t);if(!j(h))return h;const A={};for(const[k,x]of Object.entries(h))A[k]=k==="$ref"&&typeof x=="string"?x.replace("#/definitions/","#/components/schemas/").replace("#/responses/","#/components/responses/"):t(x);return A},n=t(e),r=Array.isArray(n.consumes)?n.consumes:["application/json"],s=Array.isArray(n.produces)?n.produces:["application/json"],o=j(n.parameters)?n.parameters:{},i=h=>{if(j(h)){if(typeof h.$ref=="string"&&h.$ref.startsWith("#/parameters/")){const A=o[h.$ref.slice(13)];return j(A)?A:void 0}return h}},a=h=>{const A={};for(const k of["type","format","items","enum","default","minimum","maximum","pattern","minLength","maxLength"])h[k]!==void 0&&(A[k]=h[k]);return A.type==="file"&&(A.type="string",A.format="binary"),A},c=(h,A)=>{if(!j(h)||typeof h.$ref=="string")return h;const k={description:h.description??""};if(h.schema!==void 0){const x=j(h.examples)?h.examples:{};k.content=Object.fromEntries(A.map(g=>[g,x[g]!==void 0?{schema:h.schema,example:x[g]}:{schema:h.schema}]))}return j(h.headers)&&(k.headers=Object.fromEntries(Object.entries(h.headers).map(([x,g])=>[x,j(g)?{description:g.description,schema:a(g)}:g]))),k},l=(h,A)=>{const k=Array.isArray(h.consumes)?h.consumes:r,x={...h};delete x.consumes,delete x.produces,delete x.schemes;const g=[],S=[];for(const w of[...A,...Array.isArray(h.parameters)?h.parameters:[]]){const O=i(w);if(O)if(O.in==="body")x.requestBody={description:O.description,required:O.required,content:Object.fromEntries(k.map(L=>[L,{schema:O.schema}]))};else if(O.in==="formData")S.push(O);else{const L={name:O.name,in:O.in,description:O.description,required:O.required,schema:a(O)};O["x-example"]!==void 0&&(L.example=O["x-example"]),g.push(L)}}if(S.length){const O=k.includes("multipart/form-data")||S.some(R=>R.type==="file")?"multipart/form-data":"application/x-www-form-urlencoded",L=S.filter(R=>R.required).map(R=>String(R.name));x.requestBody={content:{[O]:{schema:{type:"object",properties:Object.fromEntries(S.map(R=>[String(R.name),{...a(R),description:R.description}])),...L.length?{required:L}:{}}}}}}if(x.parameters=g,j(h.responses)){const w=Array.isArray(h.produces)?h.produces:s;x.responses=Object.fromEntries(Object.entries(h.responses).map(([O,L])=>[O,c(L,w)]))}return x},f={};if(j(n.paths))for(const[h,A]of Object.entries(n.paths)){if(!j(A))continue;const k=Array.isArray(A.parameters)?A.parameters:[],x={};for(const[g,S]of Object.entries(A))tn.includes(g)&&j(S)?x[g]=l(S,k):g!=="parameters"&&(x[g]=S);f[h]=x}const u={};if(j(n.securityDefinitions)){const h={implicit:"implicit",password:"password",application:"clientCredentials",accessCode:"authorizationCode"};for(const[A,k]of Object.entries(n.securityDefinitions))j(k)&&(k.type==="basic"?u[A]={type:"http",scheme:"basic",description:k.description}:k.type==="apiKey"?u[A]={type:"apiKey",name:k.name,in:k.in,description:k.description}:k.type==="oauth2"&&(u[A]={type:"oauth2",description:k.description,flows:{[h[String(k.flow)]??"clientCredentials"]:{authorizationUrl:k.authorizationUrl,tokenUrl:k.tokenUrl,scopes:k.scopes??{}}}}))}const d={};if(j(n.responses))for(const[h,A]of Object.entries(n.responses))d[h]=c(A,s);const p=z(n.host),b=z(n.basePath)??"",$=Array.isArray(n.schemes)&&typeof n.schemes[0]=="string"?n.schemes[0]:"https";return{openapi:"3.0.3",info:n.info,servers:p?[{url:`${$}://${p}${b}`}]:b?[{url:b}]:void 0,tags:n.tags,security:n.security,paths:f,components:{schemas:n.definitions,responses:d,securitySchemes:u}}}function dr(e){switch(e.type){case"bearer":return{name:"bearerAuth",scheme:{type:"http",scheme:"bearer"},scopes:[]};case"basic":return{name:"basicAuth",scheme:{type:"http",scheme:"basic"},scopes:[]};case"digest":return{name:"digestAuth",scheme:{type:"http",scheme:"digest"},scopes:[]};case"apiKey":return{name:`${e.key.replace(/[^\w.-]/g,"_")}Auth`,scheme:{type:"apiKey",in:e.in,name:e.key},scopes:[]};case"oauth2":{const t=(e.scope??"").split(/\s+/).filter(Boolean),n=e.grant==="deviceCode"?"clientCredentials":e.grant,r={scopes:Object.fromEntries(t.map(s=>[s,""]))};return e.tokenUrl&&(r.tokenUrl=e.tokenUrl),e.authUrl&&(r.authorizationUrl=e.authUrl),{name:"oauth2",scheme:{type:"oauth2",flows:{[n]:r}},scopes:t}}case"mtls":return{name:"mutualTLS",scheme:{type:"mutualTLS"},scopes:[]};case"awsSigV4":return{name:"awsSigV4",scheme:{type:"apiKey",in:"header",name:"Authorization","x-amazon-apigateway-authtype":"awsSigv4"},scopes:[]};case"hmac":return{name:"hmacAuth",scheme:{type:"apiKey",in:"header",name:e.header},scopes:[]};case"custom":{const t=e.headers.find(I);return t?{name:`${t.key.replace(/[^\w.-]/g,"_")}Auth`,scheme:{type:"apiKey",in:"header",name:t.key},scopes:[]}:void 0}default:return}}function De(e){if(e!==void 0)try{return JSON.parse(e)}catch{return e}}function mr(e,t){let n=e.split("?")[0].split("#")[0];for(const r of t)if(r&&n.startsWith(r)){n=n.slice(r.length);break}return n=n.replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,"").replace(/^\{\{[^}]+\}\}/,""),n=n.replace(/(^|\/):([A-Za-z_][\w-]*)/g,"$1{$2}"),n.startsWith("/")?n:`/${n}`}function hr(e,t){const n=t==null?void 0:t.split(";")[0].trim();switch(e.kind){case"none":return;case"json":{const r=De(e.text);return{content:{[n??"application/json"]:{schema:He(r),example:r}}}}case"xml":return{content:{[n??"application/xml"]:{schema:{type:"string"},example:e.text}}};case"text":return{content:{[n??e.contentType??"text/plain"]:{schema:{type:"string"},example:e.text}}};case"form":return{content:{"application/x-www-form-urlencoded":{schema:{type:"object",properties:Object.fromEntries(e.fields.filter(I).map(r=>[r.key,{type:"string",example:r.value||void 0}]))}}}};case"multipart":return{content:{"multipart/form-data":{schema:{type:"object",properties:Object.fromEntries(e.parts.filter(I).map(r=>[r.key,r.type==="file"?{type:"string",format:"binary"}:{type:"string",example:r.value||void 0}]))}}}};case"binary":return{content:{[n??e.contentType??"application/octet-stream"]:{schema:{type:"string",format:"binary"}}}};case"graphql":return{content:{"application/json":{schema:{type:"object",properties:{query:{type:"string"},variables:{type:"object"},operationName:{type:"string"}},required:["query"]},example:De(se(e))}}};case"soap":return{content:{[n??"text/xml"]:{schema:{type:"string"},example:e.envelope}}};default:return}}function sn(e,t={}){var p,b,$,h,A,k,x;const n=t.baseUrlVariable??"baseUrl",r=(p=e.variables.find(g=>g.key===n))==null?void 0:p.value,s=(b=e.servers)!=null&&b.length?e.servers:r?[{url:r}]:void 0,o=[`{{${n}}}`,...(s??[]).map(g=>g.url)],i={},a=g=>{if(!g||g.type==="inherit")return;if(g.type==="none")return e.auth&&e.auth.type!=="none"?[]:void 0;const S=dr(g);if(S)return i[S.name]=S.scheme,[{[S.name]:S.scopes}]},c=a(e.auth),l={},f=new Map;for(const{request:g,folders:S}of ze(e.items)){const w=mr(g.url,o),O=g.method.toLowerCase();if(l[w]??(l[w]={}),l[w][O])continue;for(const m of S)f.set(m.name,m.description);const L=($=g.tags)!=null&&$.length?g.tags:S.length?[S[S.length-1].name]:void 0,R=g.params.filter(m=>!(m.in==="header"&&/^(accept|content-type|authorization)$/i.test(m.key))).map(m=>{const y={name:m.key,in:m.in};return m.description&&(y.description=m.description),(m.in==="path"||m.required)&&(y.required=!0),y.schema=m.schema??{type:"string"},m.value&&(y.example=m.value),m.style&&(y.style=m.style),m.explode!==void 0&&(y.explode=m.explode),y}),M=(h=g.params.find(m=>m.in==="header"&&/^content-type$/i.test(m.key)))==null?void 0:h.value,N={summary:g.name};g.operationId&&(N.operationId=g.operationId),g.description&&(N.description=g.description),L&&(N.tags=L),g.deprecated&&(N.deprecated=!0),R.length&&(N.parameters=R);const T=hr(g.body,M);T&&(N.requestBody=T);const U={};for(const[m,y]of Object.entries(g.responses??{})){const v={description:y.description??""};if(y.contentType){const _={};y.schema&&(_.schema=y.schema),y.example!==void 0&&(_.example=/json/.test(y.contentType)?De(y.example):y.example),v.content={[y.contentType]:_}}U[m]=v}for(const m of g.examples??[]){const y=String(m.status);if(U[y])continue;const v=((x=(k=(A=m.headers)==null?void 0:A.find(_=>/^content-type$/i.test(_.key)))==null?void 0:k.value)==null?void 0:x.split(";")[0])??"application/json";U[y]={description:m.name,content:{[v]:{example:/json/.test(v)?De(m.body):m.body}}}}N.responses=Object.keys(U).length?U:{200:{description:"OK"}};const H=a(g.auth);H&&(N.security=H),l[w][O]=N}const u={openapi:"3.1.0",info:{title:e.name,version:e.version??"1.0.0",...e.description?{description:e.description}:{}}};s&&(u.servers=s.map(g=>g.description?g:{url:g.url})),f.size&&(u.tags=[...f].map(([g,S])=>S?{name:g,description:S}:{name:g})),c&&(u.security=c),u.paths=l;const d={};return e.schemas&&Object.keys(e.schemas).length&&(d.schemas=e.schemas),Object.keys(i).length&&(d.securitySchemes=i),Object.keys(d).length&&(u.components=d),u}function yr(e,t={}){return en(sn(e,t))}const W=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=e=>typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):void 0,we=e=>Array.isArray(e)?e.filter(W):[],on="https://schema.getpostman.com/json/collection/v2.1.0/collection.json";function gt(e){return W(e)&&W(e.info)&&Array.isArray(e.item)}function ge(e){if(typeof e=="string")return e||void 0;if(W(e))return E(e.content)}function Oe(e){return we(e).map(t=>{const n={key:E(t.key)??"",value:E(t.value)??""};t.disabled===!0&&(n.enabled=!1);const r=ge(t.description);return r&&(n.description=r),n})}function bt(e){if(!W(e)||typeof e.type!="string")return;const t=e[e.type],n=r=>{var s;if(Array.isArray(t))return E((s=t.filter(W).find(o=>o.key===r))==null?void 0:s.value);if(W(t))return E(t[r])};switch(e.type){case"noauth":return{type:"none"};case"bearer":return{type:"bearer",token:n("token")??""};case"basic":return{type:"basic",username:n("username")??"",password:n("password")??""};case"digest":return{type:"digest",username:n("username")??"",password:n("password")??"",realm:n("realm"),nonce:n("nonce"),qop:n("qop"),algorithm:n("algorithm"),opaque:n("opaque")};case"apikey":{const r=n("in");return{type:"apiKey",key:n("key")??"X-API-Key",value:n("value")??"",in:r==="query"?"query":"header"}}case"oauth2":{const r=n("grant_type")??"authorization_code";return{type:"oauth2",grant:r==="client_credentials"?"clientCredentials":r==="password_credentials"||r==="password"?"password":r==="implicit"?"implicit":"authorizationCode",tokenUrl:n("accessTokenUrl"),authUrl:n("authUrl"),clientId:n("clientId")??"",clientSecret:n("clientSecret"),scope:n("scope"),username:n("username"),password:n("password"),redirectUri:n("redirect_uri"),usePkce:r==="authorization_code_with_pkce"||void 0,clientAuth:n("client_authentication")==="body"?"body":void 0,accessToken:n("accessToken"),tokenType:n("tokenType")}}case"awsv4":return{type:"awsSigV4",accessKeyId:n("accessKey")??"",secretAccessKey:n("secretKey")??"",region:n("region")??"",service:n("service")??"",sessionToken:n("sessionToken")};default:return}}function gr(e){if(typeof e=="string"){const{base:o,query:i,hash:a}=ce(e);return{url:o+a,params:i.map(c=>({...c,in:"query"}))}}if(!W(e))return{url:"",params:[]};const t=E(e.raw);let n;if(t!==void 0)n=ce(t).base;else{const o=E(e.protocol),i=Array.isArray(e.host)?e.host.join("."):E(e.host)??"",a=E(e.port),c=Array.isArray(e.path)?e.path.map(l=>(W(l)?E(l.value):E(l))??"").join("/"):E(e.path)??"";n=`${o?`${o}://`:""}${i}${a?`:${a}`:""}${c?`/${c.replace(/^\//,"")}`:""}`}const r=Array.isArray(e.query)?Oe(e.query).map(o=>({...o,in:"query"})):t!==void 0?ce(t).query.map(o=>({...o,in:"query"})):[],s=Oe(e.variable).map(o=>({...o,in:"path",required:!0}));return{url:n,params:[...s,...r]}}function br(e){if(!W(e))return{kind:"none"};switch(e.mode){case"raw":{const t=E(e.raw)??"",n=W(e.options)&&W(e.options.raw)?E(e.options.raw.language):void 0;return n==="json"?{kind:"json",text:t}:n==="xml"?/<(\w+:)?Envelope[\s>]/.test(t)?{kind:"soap",envelope:t,version:"1.1"}:{kind:"xml",text:t}:n==="html"?{kind:"text",text:t,contentType:"text/html"}:n==="javascript"?{kind:"text",text:t,contentType:"application/javascript"}:!n&&/^\s*[[{]/.test(t)?{kind:"json",text:t}:{kind:"text",text:t}}case"urlencoded":return{kind:"form",fields:Oe(e.urlencoded)};case"formdata":return{kind:"multipart",parts:we(e.formdata).map(t=>{const n=t.type==="file",r=Array.isArray(t.src)?E(t.src[0]):E(t.src),s={key:E(t.key)??"",value:n?"":E(t.value)??"",type:n?"file":"text",...n&&r?{fileName:r}:{},...E(t.contentType)?{contentType:E(t.contentType)}:{}};return t.disabled===!0?{...s,enabled:!1}:s})};case"file":return{kind:"binary",fileName:W(e.file)?E(e.file.src):void 0};case"graphql":{const t=W(e.graphql)?e.graphql:{};return{kind:"graphql",query:E(t.query)??"",variables:E(t.variables)}}default:return{kind:"none"}}}function an(e){const t={};for(const n of we(e)){const r=W(n.script)?n.script:{},s=Array.isArray(r.exec)?r.exec.map(o=>E(o)??"").join(`
55
+ `):E(r.exec)??"";s.trim()&&(n.listen==="prerequest"&&(t.preRequest=s),n.listen==="test"&&(t.test=s))}return t.preRequest||t.test?t:void 0}function kr(e){const t=W(e.request)?e.request:typeof e.request=="string"?{url:e.request}:{},{url:n,params:r}=gr(t.url),s=Oe(t.header).map(i=>({...i,in:"header"})),o=we(e.response).map(i=>({name:E(i.name)??"Example",status:Number(i.code??200)||200,headers:Oe(i.header),body:E(i.body)}));return he({id:E(e.id)??void 0,name:E(e.name)??"Request",method:(E(t.method)??"GET").toUpperCase(),url:n,params:[...r,...s],body:br(t.body),auth:bt(t.auth),description:ge(t.description)??ge(e.description),scripts:an(e.event),examples:o.length?o:void 0})}function cn(e){return we(e).map(t=>Array.isArray(t.item)?ye({id:E(t.id)??void 0,name:E(t.name)??"Folder",description:ge(t.description),items:cn(t.item),auth:bt(t.auth)}):kr(t))}function pn(e){return we(e).map(t=>{const n={key:E(t.key)??"",value:E(t.value)??""};t.type==="secret"&&(n.secret=!0),(t.disabled===!0||t.enabled===!1)&&(n.enabled=!1);const r=ge(t.description);return r&&(n.description=r),n})}function ln(e){const t=typeof e=="string"?JSON.parse(e):e;if(!gt(t))throw new Error("Not a Postman collection");const n=t,r=n.info,s=an(n.event),o=be({id:E(r._postman_id)??void 0,name:E(r.name)??"Postman collection",description:ge(r.description),version:W(r.version)?E(r.version.raw):E(r.version),items:cn(n.item),variables:pn(n.variable),auth:bt(n.auth)});if(s){const i=a=>a.map(c=>c.kind==="folder"?{...c,items:i(c.items)}:c.scripts?c:{...c,scripts:s});o.items=i(o.items)}return o}function un(e){const t=typeof e=="string"?JSON.parse(e):e;if(!W(t)||!Array.isArray(t.values))throw new Error("Not a Postman environment");return{id:E(t.id)??Ee("e"),name:E(t.name)??"Environment",values:pn(t.values)}}const V=(e,t)=>({key:e,value:t??"",type:"string"});function nt(e){switch(e==null?void 0:e.type){case void 0:case"inherit":return;case"none":return{type:"noauth"};case"bearer":return{type:"bearer",bearer:[V("token",e.token)]};case"basic":return{type:"basic",basic:[V("username",e.username),V("password",e.password)]};case"digest":return{type:"digest",digest:[V("username",e.username),V("password",e.password),...["realm","nonce","qop","algorithm","opaque"].filter(t=>e[t]).map(t=>V(t,e[t]))]};case"apiKey":return{type:"apikey",apikey:[V("key",e.key),V("value",e.value),V("in",e.in==="query"?"query":"header")]};case"oauth2":return{type:"oauth2",oauth2:[["grant_type",e.grant==="clientCredentials"?"client_credentials":e.grant==="password"?"password_credentials":e.grant==="implicit"?"implicit":e.usePkce?"authorization_code_with_pkce":"authorization_code"],["accessTokenUrl",e.tokenUrl],["authUrl",e.authUrl],["clientId",e.clientId],["clientSecret",e.clientSecret],["scope",e.scope],["username",e.username],["password",e.password],["redirect_uri",e.redirectUri],["client_authentication",e.clientAuth],["accessToken",e.accessToken],["tokenType",e.tokenType]].filter(([,r])=>r!==void 0).map(([r,s])=>V(r,s))};case"awsSigV4":return{type:"awsv4",awsv4:[V("accessKey",e.accessKeyId),V("secretKey",e.secretAccessKey),V("region",e.region),V("service",e.service),...e.sessionToken?[V("sessionToken",e.sessionToken)]:[]]};default:return}}const je=e=>{const t={key:e.key,value:e.value};return I(e)||(t.disabled=!0),e.description&&(t.description=e.description),t};function $r(e){const t=e.params.filter(u=>u.in==="query"),n=$e({...e,params:e.params.filter(u=>u.in==="query"&&I(u))}).replace(/%7B%7B(.*?)%7D%7D/g,"{{$1}}").replace(new RegExp("(?<!\\{)\\{([A-Za-z_][\\w.-]*)\\}(?!\\})","g"),":$1"),r=ce(e.url).base,s=/^([a-z][\w+.-]*):\/\//i.exec(r),o=s?r.slice(s[0].length):r,i=o.indexOf("/"),a=i<0?o:o.slice(0,i),c=i<0?[]:o.slice(i+1).split("/"),l={raw:n,host:a?a.startsWith("{{")?[a]:a.split("."):[],path:c.map(u=>u.replace(/^\{([A-Za-z_][\w.-]*)\}$/,":$1"))};s&&(l.protocol=s[1]),t.length&&(l.query=t.map(je));const f=e.params.filter(u=>u.in==="path");return f.length&&(l.variable=f.map(je)),l}function wr(e){switch(e.kind){case"none":return;case"json":return{mode:"raw",raw:e.text,options:{raw:{language:"json"}}};case"xml":return{mode:"raw",raw:e.text,options:{raw:{language:"xml"}}};case"soap":return{mode:"raw",raw:e.envelope,options:{raw:{language:"xml"}}};case"text":return{mode:"raw",raw:e.text,options:{raw:{language:e.contentType==="text/html"?"html":"text"}}};case"form":return{mode:"urlencoded",urlencoded:e.fields.map(je)};case"multipart":return{mode:"formdata",formdata:e.parts.map(t=>{const n=t.type==="file"?{key:t.key,type:"file",src:t.fileName??""}:{key:t.key,value:t.value,type:"text"};return t.contentType&&(n.contentType=t.contentType),I(t)||(n.disabled=!0),n})};case"binary":return{mode:"file",file:{src:e.fileName??""}};case"graphql":return{mode:"graphql",graphql:{query:e.query,variables:e.variables??""}};default:return}}function Ar(e){const t=[];return e!=null&&e.preRequest&&t.push({listen:"prerequest",script:{type:"text/javascript",exec:e.preRequest.split(`
56
+ `)}}),e!=null&&e.test&&t.push({listen:"test",script:{type:"text/javascript",exec:e.test.split(`
57
+ `)}}),t.length?t:void 0}function fn(e){if(e.kind==="folder"){const a={name:e.name,item:e.items.map(fn)};e.description&&(a.description=e.description);const c=nt(e.auth);return c&&(a.auth=c),a}const t={method:e.method,header:e.params.filter(a=>a.in==="header").map(je),url:$r(e)},n=wr(e.body);n&&(t.body=n);const r=nt(e.auth);r&&(t.auth=r),e.description&&(t.description=e.description);const s=e.params.filter(a=>a.in==="cookie"&&I(a));s.length&&t.header.push({key:"Cookie",value:s.map(a=>`${a.key}=${a.value}`).join("; ")});const o={name:e.name,request:t},i=Ar(e.scripts);return i&&(o.event=i),o.response=(e.examples??[]).map(a=>({name:a.name,code:a.status,header:(a.headers??[]).map(je),body:a.body??""})),o}function vr(e){const t={info:{_postman_id:e.id,name:e.name,...e.description?{description:e.description}:{},schema:on},item:e.items.map(fn)};e.variables.length&&(t.variable=e.variables.map(r=>{const s={key:r.key,value:r.value,type:r.secret?"secret":"string"};return r.enabled===!1&&(s.disabled=!0),s}));const n=nt(e.auth);return n&&(t.auth=n),t}function Tr(e){return{id:e.id,name:e.name,values:e.values.map(t=>({key:t.key,value:t.value,type:t.secret?"secret":"default",enabled:t.enabled!==!1})),_postman_variable_scope:"environment"}}const de=e=>!!e&&typeof e=="object"&&!Array.isArray(e),K=e=>typeof e=="string"?e:void 0,rt=e=>Array.isArray(e)?e.filter(de):[],xr=/^(image|font|audio|video)\/|^text\/css|javascript|^application\/(x-)?font|wasm/;function ve(e){return rt(e).map(t=>({key:K(t.name)??"",value:K(t.value)??""}))}function kt(e){return de(e)&&de(e.log)&&Array.isArray(e.log.entries)}function dn(e,t={}){const n=typeof e=="string"?JSON.parse(e):e;if(!kt(n))throw new Error("Not a HAR log");const r=rt(n.log.entries),s=t.skipStatic??!0,o=[];for(const i of r){if(t.filter&&!t.filter(i))continue;const a=de(i.request)?i.request:{},c=de(i.response)?i.response:{},l=de(c.content)?c.content:{},f=(K(l.mimeType)??"").toLowerCase();if(s&&xr.test(f))continue;const{base:u,query:d}=ce(K(a.url)??""),p=Array.isArray(a.queryString)?ve(a.queryString):d,b=ve(a.cookies),$=ve(a.headers).filter(w=>!w.key.startsWith(":")&&!/^(content-length|host|connection)$/i.test(w.key)&&!(b.length&&/^cookie$/i.test(w.key))),h=[...p.map(w=>({...w,in:"query"})),...$.map(w=>({...w,in:"header"})),...b.map(w=>({...w,in:"cookie"}))];let A={kind:"none"};const k=de(a.postData)?a.postData:void 0;if(k){const w=K(k.mimeType)??"",O=rt(k.params);O.length&&w.includes("multipart")?A={kind:"multipart",parts:O.map(L=>L.fileName!==void 0?{key:K(L.name)??"",value:"",type:"file",fileName:K(L.fileName),contentType:K(L.contentType)}:{key:K(L.name)??"",value:K(L.value)??"",type:"text"})}:O.length?A={kind:"form",fields:ve(O)}:K(k.text)!==void 0&&(A=lt(K(k.text)??"",w||void 0))}const x=(K(a.method)??"GET").toUpperCase(),g=[],S=Number(c.status);if(Number.isFinite(S)&&S>0){let w=K(l.text);w!==void 0&&l.encoding==="base64"&&/json|xml|text|javascript/.test(f)&&(w=dt(w)),g.push({name:`${S} ${K(c.statusText)??""}`.trim(),status:S,headers:ve(c.headers).filter(O=>!O.key.startsWith(":")),body:w})}o.push(he({name:mt(x,u),method:x,url:u,params:h,body:A,examples:g.length?g:void 0}))}return be({name:t.name??"HAR import",items:o})}const Ge=e=>({name:e.key,value:e.value});function Sr(e,t={}){const n=Array.isArray(e)?e:ze(e.items).map(i=>i.request),r=t.transform??(i=>i),s=(t.now??(()=>new Date))().toISOString(),o=n.map(i=>{var $,h,A,k,x;const a=$e(i,r),c=i.params.filter(g=>g.in==="header"&&I(g)).map(g=>({key:r(g.key),value:r(g.value)})),l=i.params.filter(g=>g.in==="cookie"&&I(g)).map(g=>({key:r(g.key),value:r(g.value)})),f=(($=c.find(g=>/^content-type$/i.test(g.key)))==null?void 0:$.value)??ke(i.body),u={method:i.method.toUpperCase(),url:a,httpVersion:"HTTP/1.1",headers:c.map(Ge),queryString:i.params.filter(g=>g.in==="query"&&I(g)).map(g=>({name:r(g.key),value:r(g.value)})),cookies:l.map(Ge),headersSize:-1,bodySize:-1},d=i.body;d.kind==="form"?u.postData={mimeType:f,params:d.fields.filter(I).map(g=>({name:r(g.key),value:r(g.value)})),text:r(se(d)??"")}:d.kind==="multipart"?u.postData={mimeType:f,params:d.parts.filter(I).map(g=>g.type==="file"?{name:r(g.key),fileName:g.fileName??"",contentType:g.contentType}:{name:r(g.key),value:r(g.value)})}:d.kind!=="none"&&d.kind!=="binary"&&(u.postData={mimeType:f,text:r(se(d)??"")});const p=(h=i.examples)==null?void 0:h[0],b=((k=(A=p==null?void 0:p.headers)==null?void 0:A.find(g=>/^content-type$/i.test(g.key)))==null?void 0:k.value)??"";return{startedDateTime:s,time:0,request:u,response:{status:(p==null?void 0:p.status)??0,statusText:p?p.name.replace(new RegExp(`^${p.status}\\s*`),""):"",httpVersion:"HTTP/1.1",headers:((p==null?void 0:p.headers)??[]).map(Ge),cookies:[],content:{size:((x=p==null?void 0:p.body)==null?void 0:x.length)??0,mimeType:b,...(p==null?void 0:p.body)!==void 0?{text:p.body}:{}},redirectURL:"",headersSize:-1,bodySize:-1},cache:{},timings:{send:0,wait:0,receive:0}}});return{log:{version:"1.2",creator:{name:t.creator??"Nice2Dev",version:"1"},entries:o}}}const Nr=`query IntrospectionQuery {
58
+ __schema {
59
+ queryType { name }
60
+ mutationType { name }
61
+ subscriptionType { name }
62
+ types { ...FullType }
63
+ }
64
+ }
65
+ fragment FullType on __Type {
66
+ kind
67
+ name
68
+ description
69
+ fields(includeDeprecated: true) {
70
+ name
71
+ description
72
+ args { ...InputValue }
73
+ type { ...TypeRef }
74
+ isDeprecated
75
+ deprecationReason
76
+ }
77
+ inputFields { ...InputValue }
78
+ interfaces { ...TypeRef }
79
+ enumValues(includeDeprecated: true) { name description isDeprecated }
80
+ possibleTypes { ...TypeRef }
81
+ }
82
+ fragment InputValue on __InputValue {
83
+ name
84
+ description
85
+ type { ...TypeRef }
86
+ defaultValue
87
+ }
88
+ fragment TypeRef on __Type {
89
+ kind
90
+ name
91
+ ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } }
92
+ }`;function mn(e){var o,i,a,c;const n=typeof e=="string"?JSON.parse(e):e,r=((o=n==null?void 0:n.data)==null?void 0:o.__schema)??(n==null?void 0:n.__schema)??(Array.isArray(n==null?void 0:n.types)?n:void 0);if(!r||!Array.isArray(r.types))throw new Error("Not a GraphQL introspection result");const s={};for(const l of r.types)l!=null&&l.name&&(s[l.name]=l);return{queryType:((i=r.queryType)==null?void 0:i.name)??void 0,mutationType:((a=r.mutationType)==null?void 0:a.name)??void 0,subscriptionType:((c=r.subscriptionType)==null?void 0:c.name)??void 0,types:s}}function Me(e){return e?e.kind==="NON_NULL"?`${Me(e.ofType)}!`:e.kind==="LIST"?`[${Me(e.ofType)}]`:e.name??"":""}function $t(e){let t=e;for(;t&&(t.kind==="NON_NULL"||t.kind==="LIST");)t=t.ofType;return(t==null?void 0:t.name)??void 0}function hn(e){const t=[],n=[["query",e.queryType],["mutation",e.mutationType],["subscription",e.subscriptionType]];for(const[r,s]of n){const o=s?e.types[s]:void 0;for(const i of(o==null?void 0:o.fields)??[])i.name.startsWith("__")||t.push({kind:r,field:i})}return t}function yn(e,t){var r;const n=(r=e.types[$t(t)??""])==null?void 0:r.kind;return n==="SCALAR"||n==="ENUM"||n===void 0}function Or(e){var t;return((t=e.args)==null?void 0:t.some(n=>n.type.kind==="NON_NULL"&&n.defaultValue==null))??!1}function st(e,t,n,r){const s=e.types[$t(t)??""];if(!s||s.kind==="SCALAR"||s.kind==="ENUM")return"";const o=[];if(s.kind==="UNION"||s.kind==="INTERFACE"&&!(s.fields??[]).length){o.push(`${r} __typename`);for(const i of s.possibleTypes??[]){const a=st(e,i,Math.max(n-1,0),`${r} `);a&&o.push(`${r} ... on ${i.name} ${a}`)}return`{
93
+ ${o.join(`
94
+ `)}
95
+ ${r}}`}for(const i of s.fields??[])if(!(i.isDeprecated||Or(i))){if(yn(e,i.type))o.push(`${r} ${i.name}`);else if(n>0){const a=st(e,i.type,n-1,`${r} `);a&&o.push(`${r} ${i.name} ${a}`)}}return o.length||o.push(`${r} __typename`),`{
96
+ ${o.join(`
97
+ `)}
98
+ ${r}}`}function Se(e,t,n=0){var s,o;if(t.kind==="NON_NULL"&&t.ofType)return Se(e,t.ofType,n);if(t.kind==="LIST"&&t.ofType)return[Se(e,t.ofType,n)];const r=e.types[t.name??""];switch((r==null?void 0:r.kind)??"SCALAR"){case"ENUM":return((o=(s=r==null?void 0:r.enumValues)==null?void 0:s[0])==null?void 0:o.name)??"";case"INPUT_OBJECT":{if(n>4)return{};const i={};for(const a of(r==null?void 0:r.inputFields)??[])(a.type.kind==="NON_NULL"||n===0)&&(i[a.name]=Se(e,a.type,n+1));return i}default:switch(t.name){case"Int":case"Float":return 0;case"Boolean":return!1;default:return""}}}function jr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function gn(e,t,n={}){const{kind:r,field:s}=t,o=n.depth??2,i=jr(s.name),a=s.args??[],c=a.length?`(${a.map(p=>`$${p.name}: ${Me(p.type)}`).join(", ")})`:"",l=a.length?`(${a.map(p=>`${p.name}: $${p.name}`).join(", ")})`:"",f=yn(e,s.type)?"":` ${st(e,s.type,o-1," ")}`,u=`${r} ${i}${c} {
99
+ ${s.name}${l}${f}
100
+ }`,d={};for(const p of a)p.defaultValue==null&&(d[p.name]=Se(e,p.type));return{query:u,variables:d,operationName:i}}function bn(e,t={}){const n=typeof e=="object"&&e&&"types"in e&&!Array.isArray(e.types)?e:mn(e),r={query:"Queries",mutation:"Mutations",subscription:"Subscriptions",...t.folderNames},s=new Map;for(const o of hn(n)){const i=gn(n,o,{depth:t.depth}),a=he({name:o.field.name,method:"POST",url:"{{graphqlUrl}}",body:{kind:"graphql",query:i.query,variables:Object.keys(i.variables).length?JSON.stringify(i.variables,null,2):void 0,operationName:i.operationName},description:o.field.description??void 0,deprecated:o.field.isDeprecated||void 0});s.has(o.kind)||s.set(o.kind,[]),s.get(o.kind).push(a)}return be({name:t.name??"GraphQL API",items:[...s].map(([o,i])=>ye({name:r[o],items:i})),variables:[{key:"graphqlUrl",value:t.endpoint??""}]})}const G="http://schemas.xmlsoap.org/wsdl/",Qe="http://schemas.xmlsoap.org/wsdl/soap/",Ye="http://schemas.xmlsoap.org/wsdl/soap12/",me="http://www.w3.org/2001/XMLSchema",Cr="http://schemas.xmlsoap.org/soap/envelope/",_r="http://www.w3.org/2003/05/soap-envelope",ee=(e,t)=>`{${e??""}}${t}`;function Z(e,t,n){return Array.from(e.childNodes).filter(r=>r.nodeType===1&&r.localName===n&&(t===null||r.namespaceURI===t))}function ne(e,t,n){return Z(e,t,n)[0]}function ae(e,t){if(!t)return;const n=t.indexOf(":"),r=n<0?null:t.slice(0,n),s=n<0?t:t.slice(n+1);return{namespace:e.lookupNamespaceURI(r)??void 0,name:s}}function Ct(e){var r;const t=ne(e,G,"documentation");return((r=t==null?void 0:t.textContent)==null?void 0:r.trim())||void 0}function Er(){const e=globalThis.DOMParser;if(!e)throw new Error("No DOMParser: pass one (xmldom, jsdom) in Node");return new e}function kn(e,t=Er()){const r=t.parseFromString(e,"text/xml").documentElement;if(!r||r.localName!=="definitions"||r.namespaceURI!==G)throw new Error("Not a WSDL 1.1 document");const s=r.getAttribute("targetNamespace")??void 0,o={elements:new Map,types:new Map,qualified:new Map},i=ne(r,G,"types");for(const u of i?Z(i,me,"schema"):[]){const d=u.getAttribute("targetNamespace")??void 0;o.qualified.set(d??"",u.getAttribute("elementFormDefault")==="qualified");for(const p of Z(u,me,"element")){const b=p.getAttribute("name");b&&o.elements.set(ee(d,b),p)}for(const p of[...Z(u,me,"complexType"),...Z(u,me,"simpleType")]){const b=p.getAttribute("name");b&&o.types.set(ee(d,b),p)}}const a=new Map;for(const u of Z(r,G,"message")){const d=Z(u,G,"part").map(p=>({name:p.getAttribute("name")??"",element:ae(p,p.getAttribute("element")),type:ae(p,p.getAttribute("type"))}));a.set(ee(s,u.getAttribute("name")??""),d)}const c=new Map;for(const u of Z(r,G,"portType")){const d=new Map;for(const p of Z(u,G,"operation")){const b=ne(p,G,"input"),$=ne(p,G,"output"),h=b?ae(b,b.getAttribute("message")):void 0,A=$?ae($,$.getAttribute("message")):void 0;d.set(p.getAttribute("name")??"",{doc:Ct(p),input:h?ee(h.namespace,h.name):void 0,output:A?ee(A.namespace,A.name):void 0})}c.set(ee(s,u.getAttribute("name")??""),d)}const l=new Map;for(const u of Z(r,G,"binding")){const d=ne(u,Qe,"binding"),p=ne(u,Ye,"binding"),b=d??p,$=ee(s,u.getAttribute("name")??"");if(!b){l.set($,null);continue}const h=d?Qe:Ye,A=ae(u,u.getAttribute("type")),k=A?c.get(ee(A.namespace,A.name)):void 0,x=b.getAttribute("style")==="rpc"?"rpc":"document",g=Z(u,G,"operation").map(S=>{const w=S.getAttribute("name")??"",O=ne(S,h,"operation"),L=((O==null?void 0:O.getAttribute("style"))??x)==="rpc"?"rpc":"document",R=k==null?void 0:k.get(w),M=R!=null&&R.input?a.get(R.input):void 0,N=R!=null&&R.output?a.get(R.output):void 0,T=ne(S,G,"input"),U=T?ne(T,h,"body"):void 0,H={name:w,soapAction:(O==null?void 0:O.getAttribute("soapAction"))??void 0,style:L,documentation:R==null?void 0:R.doc};if(L==="rpc")H.inputElement={namespace:(U==null?void 0:U.getAttribute("namespace"))??s,name:w},H.inputParts=(M??[]).map(y=>({name:y.name,type:y.type}));else{const y=(M==null?void 0:M.find(v=>v.element))??(M==null?void 0:M[0]);y!=null&&y.element&&(H.inputElement=y.element)}const m=N==null?void 0:N.find(y=>y.element);return m!=null&&m.element&&(H.outputElement=m.element),H});l.set($,{version:d?"1.1":"1.2",operations:g})}const f=Z(r,G,"service").map(u=>({name:u.getAttribute("name")??"Service",documentation:Ct(u),ports:Z(u,G,"port").flatMap(d=>{const p=ae(d,d.getAttribute("binding")),b=p?l.get(ee(p.namespace,p.name)):void 0;if(!b)return[];const $=ne(d,Qe,"address")??ne(d,Ye,"address");return[{name:d.getAttribute("name")??"",binding:(p==null?void 0:p.name)??"",version:b.version,address:($==null?void 0:$.getAttribute("location"))??"",operations:b.operations}]})}));return{targetNamespace:s,services:f,schema:o}}function $n(e,t,n,r,s,o,i){const a=t.getAttribute("name")??t.getAttribute("ref")??"element";let c=t,l=n;if(t.getAttribute("ref")){const k=ae(t,t.getAttribute("ref")),x=k?e.schema.elements.get(ee(k.namespace,k.name)):void 0;x&&(c=x,l=k==null?void 0:k.namespace)}const f=c.getAttribute("name")??a.split(":").pop()??a,u=s&&l?it(l,r):"",d=u?`${u}:${f}`:f,b=c.getAttribute("minOccurs")==="0"||t.getAttribute("minOccurs")==="0"?`${o}<!--Optional:-->
101
+ `:"";let $=ne(c,me,"complexType");const h=ae(c,c.getAttribute("type"));if(!$&&h&&h.namespace!==me){const k=e.schema.types.get(ee(h.namespace,h.name));(k==null?void 0:k.localName)==="complexType"&&($=k)}if(!$||i>6)return`${b}${o}<${d}>?</${d}>`;const A=Ur(e,$,l,r,o,i);return A?`${b}${o}<${d}>
102
+ ${A}
103
+ ${o}</${d}>`:`${b}${o}<${d}/>`}function Ur(e,t,n,r,s,o){const i=e.schema.qualified.get(n??"")??!1,a=[],c=l=>{for(const f of Array.from(l.childNodes)){if(f.nodeType!==1)continue;const u=f;if(u.namespaceURI===me){if(u.localName==="element")a.push($n(e,u,n,r,i,`${s} `,o+1));else if(["sequence","all","choice","complexContent","extension"].includes(u.localName)){if(u.localName==="extension"){const d=ae(u,u.getAttribute("base")),p=d?e.schema.types.get(ee(d.namespace,d.name)):void 0;p&&c(p)}c(u)}}}};return c(t),a.join(`
104
+ `)}function it(e,t){return t.has(e)||t.set(e,t.size?`ns${t.size}`:"tns"),t.get(e)}function wn(e,t,n="1.1"){const r=new Map,s=n==="1.2"?"soap":"soapenv";let o;const i=t.inputElement;if(t.style==="rpc"){const l=i==null?void 0:i.namespace,f=l?it(l,r):"",u=f?`${f}:${t.name}`:t.name,d=(t.inputParts??[]).map(p=>` <${p.name}>?</${p.name}>`);o=d.length?` <${u}>
105
+ ${d.join(`
106
+ `)}
107
+ </${u}>`:` <${u}/>`}else if(i){const l=e.schema.elements.get(ee(i.namespace,i.name));if(l)o=$n(e,l,i.namespace,r,!0," ",0);else{const f=i.namespace?it(i.namespace,r):"",u=f?`${f}:${i.name}`:i.name;o=` <${u}>?</${u}>`}}else o="";const c=[`xmlns:${s}="${n==="1.2"?_r:Cr}"`,...[...r].map(([l,f])=>`xmlns:${f}="${l}"`)].join(" ");return[`<${s}:Envelope ${c}>`,` <${s}:Header/>`,` <${s}:Body>`,...o?[o]:[],` </${s}:Body>`,`</${s}:Envelope>`].join(`
108
+ `)}function An(e,t={}){var s;const n=kn(e,t.parser),r=n.services.flatMap(o=>o.ports.map(i=>ye({name:n.services.length>1||o.ports.length>1?`${o.name} — ${i.name}`:o.name,description:o.documentation,items:i.operations.map(a=>he({name:a.name,method:"POST",url:i.address,body:{kind:"soap",envelope:wn(n,a,i.version),action:a.soapAction??"",version:i.version},description:a.documentation}))})));return be({name:t.name??((s=n.services[0])==null?void 0:s.name)??"SOAP service",items:r.length===1?r[0].items:r})}const _t=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],qr=Array.from({length:64},(e,t)=>Math.floor(Math.abs(Math.sin(t+1))*2**32)>>>0);function wt(e){const t=typeof e=="string"?new TextEncoder().encode(e):e,n=t.length*8,r=new Uint8Array(((t.length+8>>6)+1)*64);r.set(t),r[t.length]=128;const s=new DataView(r.buffer);s.setUint32(r.length-8,n>>>0,!0),s.setUint32(r.length-4,Math.floor(n/2**32),!0);let o=1732584193,i=4023233417,a=2562383102,c=271733878;const l=new Uint32Array(16);for(let u=0;u<r.length;u+=64){for(let h=0;h<16;h++)l[h]=s.getUint32(u+h*4,!0);let d=o,p=i,b=a,$=c;for(let h=0;h<64;h++){let A,k;h<16?(A=p&b|~p&$,k=h):h<32?(A=$&p|~$&b,k=(5*h+1)%16):h<48?(A=p^b^$,k=(3*h+5)%16):(A=b^(p|~$),k=7*h%16);const x=d+A+qr[h]+l[k]>>>0;d=$,$=b,b=p,p=p+(x<<_t[h]|x>>>32-_t[h])>>>0}o=o+d>>>0,i=i+p>>>0,a=a+b>>>0,c=c+$>>>0}const f=new DataView(new ArrayBuffer(16));return[o,i,a,c].forEach((u,d)=>f.setUint32(d*4,u,!0)),Array.from(new Uint8Array(f.buffer),u=>u.toString(16).padStart(2,"0")).join("")}function ot(e,t){if(typeof e=="string")return t(e);if(Array.isArray(e))return e.map(n=>ot(n,t));if(e&&typeof e=="object"){const n={};for(const[r,s]of Object.entries(e))n[r]=ot(s,t);return n}return e}const Ir=new TextEncoder;function at(){const e=globalThis.crypto;if(!(e!=null&&e.subtle))throw new Error("Web Crypto is not available");return e.subtle}function Ne(e){return Array.from(new Uint8Array(e),t=>t.toString(16).padStart(2,"0")).join("")}function At(e){let t="";for(const n of e instanceof Uint8Array?e:new Uint8Array(e))t+=String.fromCharCode(n);return btoa(t)}function Pe(e){const t=typeof e=="string"?Ir.encode(e):e;return new Uint8Array(t)}async function Ce(e,t){return at().digest(e,Pe(t))}async function fe(e,t,n){const r=t instanceof ArrayBuffer?new Uint8Array(t):Pe(t),s=await at().importKey("raw",Pe(r),{name:"HMAC",hash:e},!1,["sign"]);return at().sign("HMAC",s,Pe(n))}function Xe(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}function J(e,t,n){const r=t.toLowerCase(),s=e.findIndex(([o])=>o.toLowerCase()===r);s>=0?e[s]=[e[s][0],n]:e.push([t,n])}function Le(e,t){var r;const n=t.toLowerCase();return(r=e.find(([s])=>s.toLowerCase()===n))==null?void 0:r[1]}function vn(e){const t=/Digest\s+(.*)$/i.exec(e);if(!t)return;const n={};for(const r of t[1].matchAll(/(\w+)=(?:"([^"]*)"|([^\s,]+))/g))n[r[1].toLowerCase()]=r[2]??r[3];return n}async function Te(e,t){return/sha-?256/i.test(e)?Ne(await Ce("SHA-256",t)):wt(t)}async function Tn(e,t,n,r={}){var p;if(!e.realm||!e.nonce)return;const s=e.algorithm??"MD5",o=n.replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,"")||"/",i=(p=e.qop)!=null&&p.split(",").map(b=>b.trim()).includes("auth")?"auth":e.qop?e.qop.split(",")[0].trim():void 0,a=r.cnonce??wt(String(Math.random())).slice(0,16),c=(r.nc??1).toString(16).padStart(8,"0");let l=await Te(s,`${e.username}:${e.realm}:${e.password}`);/-sess$/i.test(s)&&(l=await Te(s,`${l}:${e.nonce}:${a}`));const f=await Te(s,`${t}:${o}`),u=i?await Te(s,`${l}:${e.nonce}:${c}:${a}:${i}:${f}`):await Te(s,`${l}:${e.nonce}:${f}`),d=[`username="${e.username}"`,`realm="${e.realm}"`,`nonce="${e.nonce}"`,`uri="${o}"`,`algorithm=${s}`,`response="${u}"`];return i&&d.push(`qop=${i}`,`nc=${c}`,`cnonce="${a}"`),e.opaque&&d.push(`opaque="${e.opaque}"`),`Digest ${d.join(", ")}`}async function xn(e,t,n=new Date){var g;const r=new URL(e.url),s=n.toISOString().replace(/[:-]|\.\d{3}/g,""),o=s.slice(0,8);let i="";typeof e.body=="string"?i=e.body:((g=e.body)==null?void 0:g.kind)==="binary"&&e.body.data&&(i=Uint8Array.from(atob(e.body.data),S=>S.charCodeAt(0)));const a=e.body&&typeof e.body!="string"&&e.body.kind==="multipart"?"UNSIGNED-PAYLOAD":Ne(await Ce("SHA-256",i)),c=t.service==="s3";J(e.headers,"X-Amz-Date",s),c&&J(e.headers,"X-Amz-Content-Sha256",a),t.sessionToken&&J(e.headers,"X-Amz-Security-Token",t.sessionToken);const l=r.pathname.split("/").map(S=>c?S:Xe(S)).join("/")||"/",f=[...r.searchParams.entries()].map(([S,w])=>[Xe(S),Xe(w)]).sort(([S,w],[O,L])=>S===O?w<L?-1:w>L?1:0:S<O?-1:1).map(([S,w])=>`${S}=${w}`).join("&"),u=new Map([["host",r.host]]);for(const[S,w]of e.headers){const O=S.toLowerCase();(O.startsWith("x-amz-")||O==="content-type")&&u.set(O,w.trim().replace(/\s+/g," "))}const d=[...u.keys()].sort(),p=d.map(S=>`${S}:${u.get(S)}
109
+ `).join(""),b=d.join(";"),$=[e.method.toUpperCase(),l,f,p,b,a].join(`
110
+ `),h=`${o}/${t.region}/${t.service}/aws4_request`,A=["AWS4-HMAC-SHA256",s,h,Ne(await Ce("SHA-256",$))].join(`
111
+ `);let k=await fe("SHA-256",`AWS4${t.secretAccessKey}`,o);k=await fe("SHA-256",k,t.region),k=await fe("SHA-256",k,t.service),k=await fe("SHA-256",k,"aws4_request");const x=Ne(await fe("SHA-256",k,A));J(e.headers,"Authorization",`AWS4-HMAC-SHA256 Credential=${t.accessKeyId}/${h}, SignedHeaders=${b}, Signature=${x}`)}async function Sn(e,t,n=new Date){const r=/^[a-z][\w+.-]*:\/\//i.test(e.url)?new URL(e.url):new URL(e.url,"http://localhost"),s=t.template??`{method}
112
+ {path}
113
+ {timestamp}
114
+ {body}`,o=String(Math.floor(n.getTime()/1e3)),i=s.replace(/\\n/g,`
115
+ `).replace(/\{method\}/g,e.method.toUpperCase()).replace(/\{path\}/g,r.pathname+r.search).replace(/\{query\}/g,r.search.replace(/^\?/,"")).replace(/\{timestamp\}/g,o).replace(/\{body\}/g,typeof e.body=="string"?e.body:""),a=await fe(t.algorithm,t.secret,i),c=t.encoding==="base64"?At(a):Ne(a);J(e.headers,t.header,`${t.prefix??""}${c}`),s.includes("{timestamp}")&&J(e.headers,t.timestampHeader??"X-Timestamp",o)}async function ct(e,t={}){var b;const n=$=>ft($,t.variables??{},t),r=t.auth??e.auth,s=!r||r.type==="inherit"?{type:"none"}:ot(r,n),o=[],i=e.params.filter($=>$.in==="header"&&I($)).map($=>[n($.key),n($.value)]),a=e.params.filter($=>$.in==="cookie"&&I($)).map($=>`${n($.key)}=${n($.value)}`);switch(s.type){case"basic":J(i,"Authorization",`Basic ${We(`${s.username}:${s.password}`)}`);break;case"bearer":s.token&&J(i,"Authorization",`${s.prefix??"Bearer"} ${s.token}`);break;case"oauth2":s.accessToken&&J(i,"Authorization",`${s.tokenType??"Bearer"} ${s.accessToken}`);break;case"apiKey":s.in==="header"?J(i,s.key,s.value):s.in==="query"?o.push({key:s.key,value:s.value,in:"query"}):a.push(`${s.key}=${s.value}`);break;case"custom":for(const $ of s.headers.filter(I))J(i,$.key,$.value);break}a.length&&J(i,"Cookie",[Le(i,"Cookie"),...a].filter(Boolean).join("; "));const c=$e({...e,params:[...e.params,...o]},n);let l;const f=e.body;f.kind==="multipart"?l={kind:"multipart",parts:f.parts.filter(I).map($=>({...$,key:n($.key),value:n($.value)}))}:f.kind==="binary"?l={kind:"binary",fileName:f.fileName,contentType:f.contentType,data:f.data}:f.kind!=="none"&&(l=n(se(f)??""));const u=ke(f);u&&f.kind!=="multipart"&&!Le(i,"Content-Type")&&J(i,"Content-Type",u),f.kind==="soap"&&f.version==="1.1"&&f.action!==void 0&&!Le(i,"SOAPAction")&&J(i,"SOAPAction",`"${n(f.action)}"`);const d={method:e.method.toUpperCase(),url:c,headers:i,body:l,settings:{...e.settings}},p=((b=t.now)==null?void 0:b.call(t))??new Date;if(s.type==="digest"){const $=await Tn(s,d.method,c);$&&J(d.headers,"Authorization",$)}else s.type==="awsSigV4"?await xn(d,s,p):s.type==="hmac"&&await Sn(d,s,p);return d}async function Pr(e,t,n={},r){let s=await ct(e,n),o=await t(s,r);const i=n.auth??e.auth;if(o.status===401&&(i==null?void 0:i.type)==="digest"&&!i.nonce){const a=vn(Le(o.headers,"WWW-Authenticate")??"");if(a!=null&&a.nonce){const c={...i,realm:a.realm,nonce:a.nonce,qop:a.qop,algorithm:a.algorithm,opaque:a.opaque};return s=await ct(e,{...n,auth:c}),o=await t(s,r),{response:o,sent:s,auth:c}}}return{response:o,sent:s,auth:i}}const Lr=/^text\/|json|xml|javascript|ecmascript|x-www-form-urlencoded|graphql|yaml|csv|html/i;function Et(e,t){const n=Uint8Array.from(atob(e),r=>r.charCodeAt(0));return new Blob([n],t?{type:t}:void 0)}function Rr(e=(...t)=>fetch(...t)){return async(t,n)=>{var l,f,u;const r=new Headers;for(const[d,p]of t.headers)r.append(d,p);let s;if(typeof t.body=="string")s=t.body;else if(((l=t.body)==null?void 0:l.kind)==="multipart"){const d=new FormData;for(const p of t.body.parts)if(p.type==="file"){const b=(f=t.body.files)==null?void 0:f[p.key];d.append(p.key,b?Et(b,p.contentType):new Blob([]),p.fileName??p.key)}else d.append(p.key,p.value);s=d,r.delete("Content-Type")}else((u=t.body)==null?void 0:u.kind)==="binary"&&t.body.data&&(s=Et(t.body.data,t.body.contentType));const o=new AbortController,i=()=>o.abort();n==null||n.addEventListener("abort",i);const a=t.settings.timeoutMs?setTimeout(i,t.settings.timeoutMs):void 0,c=Date.now();try{const d=await e(t.url,{method:t.method,headers:r,body:t.method==="GET"||t.method==="HEAD"?void 0:s,redirect:t.settings.followRedirects===!1?"manual":"follow",signal:o.signal}),p=await d.arrayBuffer(),b=d.headers.get("content-type")??"",$=!b||Lr.test(b),h=[];return d.headers.forEach((A,k)=>h.push([k,A])),{status:d.status,statusText:d.statusText,headers:h,body:$?new TextDecoder().decode(p):"",bodyBase64:$?void 0:At(p),timeMs:Date.now()-c,size:p.byteLength,url:d.url||t.url}}finally{a&&clearTimeout(a),n==null||n.removeEventListener("abort",i)}}}function Ut(e){return At(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Hr(){const e=new Uint8Array(32);globalThis.crypto.getRandomValues(e);const t=Ut(e),n=Ut(await Ce("SHA-256",t));return{verifier:t,challenge:n}}function Dr(e,t={}){const n=new URLSearchParams;n.set("response_type",e.grant==="implicit"?"token":"code"),n.set("client_id",e.clientId),e.redirectUri&&n.set("redirect_uri",e.redirectUri),e.scope&&n.set("scope",e.scope),e.audience&&n.set("audience",e.audience),t.state&&n.set("state",t.state),t.challenge&&(n.set("code_challenge",t.challenge),n.set("code_challenge_method","S256"));const r=e.authUrl??"";return`${r}${r.includes("?")?"&":"?"}${n.toString()}`}async function _e(e,t,n){if(!e.tokenUrl)throw new Error("OAuth 2: no token URL");const r=[["Content-Type","application/x-www-form-urlencoded"],["Accept","application/json"]],s=new URLSearchParams(t);e.clientAuth==="body"||!e.clientSecret?(s.set("client_id",e.clientId),e.clientSecret&&s.set("client_secret",e.clientSecret)):r.push(["Authorization",`Basic ${We(`${encodeURIComponent(e.clientId)}:${encodeURIComponent(e.clientSecret)}`)}`]),e.scope&&!s.has("scope")&&t.grant_type!=="authorization_code"&&t.grant_type!=="refresh_token"&&s.set("scope",e.scope),e.audience&&s.set("audience",e.audience);const o=await n({method:"POST",url:e.tokenUrl,headers:r,body:s.toString(),settings:{}});let i={};try{i=JSON.parse(o.body)}catch{i=Object.fromEntries(new URLSearchParams(o.body))}if(o.status>=400||typeof i.access_token!="string"){const c=typeof i.error=="string"?i.error:`HTTP ${o.status}`,l=typeof i.error_description=="string"?`: ${i.error_description}`:"";throw new Error(`OAuth 2 token request failed — ${c}${l}`)}const a=Number(i.expires_in);return{accessToken:i.access_token,tokenType:typeof i.token_type=="string"?i.token_type.replace(/^bearer$/i,"Bearer"):"Bearer",refreshToken:typeof i.refresh_token=="string"?i.refresh_token:void 0,expiresAt:Number.isFinite(a)&&a>0?Date.now()+a*1e3:void 0,scope:typeof i.scope=="string"?i.scope:void 0,idToken:typeof i.id_token=="string"?i.id_token:void 0}}async function Mr(e,t){if(e.grant==="clientCredentials")return _e(e,{grant_type:"client_credentials"},t);if(e.grant==="password")return _e(e,{grant_type:"password",username:e.username??"",password:e.password??""},t);throw new Error(`OAuth 2: the ${e.grant} grant needs the user — use buildAuthorizationUrl / startDeviceAuthorization`)}async function zr(e,t,n,r){const s={grant_type:"authorization_code",code:t};return e.redirectUri&&(s.redirect_uri=e.redirectUri),r&&(s.code_verifier=r),_e(e,s,n)}async function Wr(e,t,n){return _e(e,{grant_type:"refresh_token",refresh_token:t},n)}async function Br(e,t){if(!e.deviceUrl)throw new Error("OAuth 2: no device authorization URL");const n=new URLSearchParams({client_id:e.clientId});e.scope&&n.set("scope",e.scope),e.audience&&n.set("audience",e.audience);const r=await t({method:"POST",url:e.deviceUrl,headers:[["Content-Type","application/x-www-form-urlencoded"],["Accept","application/json"]],body:n.toString(),settings:{}}),s=JSON.parse(r.body);if(typeof s.device_code!="string")throw new Error(`OAuth 2 device authorization failed — HTTP ${r.status}`);return{deviceCode:s.device_code,userCode:String(s.user_code??""),verificationUri:String(s.verification_uri_complete??s.verification_uri??""),interval:Number(s.interval??5),expiresIn:s.expires_in===void 0?void 0:Number(s.expires_in)}}async function Fr(e,t,n){try{return await _e(e,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t},n)}catch(r){const s=r instanceof Error?r.message:"";if(s.includes("authorization_pending"))return"pending";if(s.includes("slow_down"))return"slow_down";throw r}}const Nn={version:"Version",servers:"Servers",authentication:"Authentication",parameters:"Parameters",name:"Name",location:"In",required:"Required",type:"Type",description:"Description",yes:"Yes",no:"No",requestBody:"Request body",responses:"Responses",status:"Status",example:"Example",deprecated:"Deprecated",noAuth:"None"},xe=e=>(e??"").replace(/\|/g,"\\|").replace(/\r?\n/g," ");function pt(e){if(!e)return"string";if(e.$ref)return e.$ref.split("/").pop()??"object";const t=Array.isArray(e.type)?e.type.join(" | "):e.type;return t==="array"?`${pt(e.items)}[]`:[t??"object",e.format?`(${e.format})`:""].filter(Boolean).join(" ")}function Vr(e,t){switch(e.type){case"none":case"inherit":return t.noAuth;case"apiKey":return`API key \`${e.key}\` (${e.in})`;case"bearer":return"Bearer token";case"basic":return"HTTP Basic";case"digest":return"HTTP Digest";case"oauth2":return`OAuth 2 (${e.grant}${e.scope?`, scope: ${e.scope}`:""})`;case"awsSigV4":return`AWS Signature V4 (${e.service}, ${e.region})`;case"hmac":return`HMAC ${e.algorithm} (\`${e.header}\`)`;case"mtls":return"Mutual TLS";case"custom":return e.headers.map(n=>`\`${n.key}\``).join(", ");default:return""}}function qt(e,t){const n=e.includes("```")?"````":"```";return`${n}${t}
116
+ ${e}
117
+ ${n}`}function Kr(e,t,n,r,s,o){var d;const i="#".repeat(o),a=[],c=e.url.replace(/^\{\{[^}]+\}\}/,"")||"/";a.push(`${i} \`${e.method}\` ${c}${e.name&&e.name!==`${e.method} ${c}`?` — ${e.name}`:""}`,""),e.deprecated&&a.push(`> **${r.deprecated}**`,""),e.description&&a.push(e.description,"");const l=e.params.filter(I);l.length&&a.push(`${i}# ${r.parameters}`,"",`| ${r.name} | ${r.location} | ${r.required} | ${r.type} | ${r.description} |`,"|---|---|---|---|---|",...l.map(p=>`| \`${xe(p.key)}\` | ${p.in} | ${p.required||p.in==="path"?r.yes:r.no} | ${xe(pt(p.schema))} | ${xe(p.description)} |`),"");const f=e.body;if(f.kind!=="none")if(a.push(`${i}# ${r.requestBody}`,""),f.kind==="form"||f.kind==="multipart"){const p=f.kind==="form"?f.fields:f.parts;a.push(...p.filter(I).map(b=>`- \`${b.key}\`${"type"in b&&b.type==="file"?" (file)":b.value?`: ${b.value}`:""}`),"")}else if(f.kind==="binary")a.push(`${f.contentType??"application/octet-stream"}${f.fileName?` — ${f.fileName}`:""}`,"");else{const p=f.kind==="json"||f.kind==="graphql"?"json":f.kind==="text"?"":"xml";a.push(qt(se(f)??"",p),"")}const u=Object.entries(e.responses??{});if(u.length&&a.push(`${i}# ${r.responses}`,"",`| ${r.status} | ${r.description} | ${r.type} |`,"|---|---|---|",...u.map(([p,b])=>`| ${p} | ${xe(b.description)} | ${xe(b.schema?pt(b.schema):b.contentType)} |`),""),s.codeLanguage!==!1){const p=n.filter(A=>A.kind==="folder"),b=s.codeLanguage??"curl",$=Qt(e,b,{auth:Rt(e,p,t)}),h=((d=Kt.find(A=>A.id===b))==null?void 0:d.syntax)??"shell";a.push(`${i}# ${r.example}`,"",qt($,h),"")}return a}function Jr(e,t={}){var o;const n={...Nn,...t.labels},r=[`# ${e.name}`,""];e.description&&r.push(e.description,""),e.version&&r.push(`**${n.version}:** ${e.version}`,""),(o=e.servers)!=null&&o.length&&r.push(`## ${n.servers}`,"",...e.servers.map(i=>`- \`${i.url}\`${i.description?` — ${i.description}`:""}`),""),e.auth&&e.auth.type!=="none"&&e.auth.type!=="inherit"&&r.push(`## ${n.authentication}`,"",Vr(e.auth,n),"");const s=(i,a,c)=>{for(const l of i)l.kind==="folder"?(r.push(`${"#".repeat(Math.min(a,6))} ${l.name}`,""),l.description&&r.push(l.description,""),s(l.items,a+1,[...c,l])):r.push(...Kr(l,e,c,n,t,Math.min(a,5)))};return s(e.items,2,[]),`${r.join(`
118
+ `).replace(/\n{3,}/g,`
119
+
120
+ `).trimEnd()}
121
+ `}function On(e,t){try{return Re(e,t)}catch{return}}function jn(e,t={}){const n=e.trim();if(!n)return;if(Bt(n))return"curl";if(n.startsWith("<"))return/<(\w+:)?definitions[\s>]/.test(n)&&/schemas\.xmlsoap\.org\/wsdl/.test(n)?"wsdl":void 0;const r=On(n,t.parseYaml);if(!r||typeof r!="object")return;const s=r;if(typeof s.openapi=="string"||typeof s.swagger=="string")return"openapi";if(gt(s))return"postman";if(Array.isArray(s.values)&&(s._postman_variable_scope!==void 0||typeof s.name=="string"))return"postman-environment";if(kt(s))return"har";const o=s.data;if(s.__schema||o!=null&&o.__schema)return"graphql"}function Gr(e,t={}){const n=jn(e,t),r=()=>On(e.trim(),t.parseYaml);switch(n){case"curl":return{kind:n,request:Vt(e)};case"openapi":return{kind:n,collection:nn(r(),t)};case"postman":return{kind:n,collection:ln(r())};case"postman-environment":return{kind:n,environment:un(r())};case"har":return{kind:n,collection:dn(r())};case"graphql":return{kind:n,collection:bn(r())};case"wsdl":return{kind:n,collection:An(e,{parser:t.xmlParser})};default:throw new Error("Unknown API document: expected curl, OpenAPI, Swagger, Postman, HAR, GraphQL introspection or WSDL")}}exports.GRAPHQL_INTROSPECTION_QUERY=Nr;exports.NICE_API_AUTH_TYPES=qn;exports.NICE_API_CODE_LANGUAGES=Kt;exports.NICE_API_MARKDOWN_LABELS=Nn;exports.NICE_API_METHODS=Un;exports.NiceYamlError=Q;exports.POSTMAN_SCHEMA_V21=on;exports.bodyContentType=ke;exports.bodyFromText=lt;exports.bodyText=se;exports.buildAuthorizationUrl=Dr;exports.buildGraphqlOperation=gn;exports.buildRequestUrl=$e;exports.buildSoapEnvelope=wn;exports.collectionToMarkdown=Jr;exports.createPkcePair=Hr;exports.detectApiDocument=jn;exports.digest=Ce;exports.digestAuthorization=Tn;exports.effectiveAuth=Rt;exports.exchangeAuthorizationCode=zr;exports.exportHar=Sr;exports.exportOpenApi=sn;exports.exportOpenApiYaml=yr;exports.exportPostman=vr;exports.exportPostmanEnvironment=Tr;exports.fetchOAuth2Token=Mr;exports.fetchTransport=Rr;exports.findApiItem=It;exports.findVariables=Dt;exports.flattenApiRequests=ze;exports.fromBase64=dt;exports.generateCode=Qt;exports.graphqlExampleValue=Se;exports.graphqlOperations=hn;exports.graphqlTypeName=Me;exports.headerValue=Pn;exports.hmac=fe;exports.importApiDocument=Gr;exports.importGraphqlIntrospection=bn;exports.importHar=dn;exports.importOpenApi=nn;exports.importPostman=ln;exports.importPostmanEnvironment=un;exports.importWsdl=An;exports.inferSchema=He;exports.interpolate=ft;exports.isCurlCommand=Bt;exports.isEnabled=I;exports.isHar=kt;exports.isPostmanCollection=gt;exports.joinUrl=zn;exports.jsonPointer=tt;exports.md5Hex=wt;exports.mockFromSchema=yt;exports.mockResponse=ur;exports.namedType=$t;exports.newApiCollection=be;exports.newApiFolder=ye;exports.newApiId=Ee;exports.newApiRequest=he;exports.paramsIn=Lt;exports.parseCurl=Vt;exports.parseDigestChallenge=vn;exports.parseFormEncoded=ut;exports.parseGraphqlIntrospection=mn;exports.parseJsonOrYaml=Re;exports.parseWsdl=kn;exports.parseYaml=Yt;exports.pathParamNames=Mt;exports.pollDeviceToken=Fr;exports.refreshOAuth2Token=Wr;exports.requestName=mt;exports.resolvePlainScalar=Be;exports.resolveRequest=ct;exports.rowsToRecord=In;exports.schemaResolver=ht;exports.sendApiRequest=Pr;exports.setRequestUrl=Wt;exports.signAwsV4=xn;exports.signHmac=Sn;exports.splitUrl=ce;exports.startDeviceAuthorization=Br;exports.stringifyYaml=en;exports.swagger2ToOpenApi3=rn;exports.syncPathParams=zt;exports.toBase64=We;exports.toCurl=Ie;exports.tokenizeCommand=Ft;exports.unresolvedVariables=Hn;exports.updateApiItem=Pt;exports.variableScope=Dn;