import{s as e}from"./rolldown-runtime-Bjp52BOI.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";import{Lr as t,or as n}from"./initial-vendor-CbfHqnih.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";import{D as r,F as i,N as a,O as o,P as s,R as c,et as l,i as u,k as d}from"./utils-D6b6ny2H.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";import{t as f}from"./isEqual-BfaiBbcl.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";import{t as p}from"./shallow-BzqLj4xC.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";import{Na as m}from"./index-DiVFqI9q.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";var h=e(t(),1),g=e(f(),1),_=l.body,v=e=>e===_||e.startsWith(`${_}.`),y=e=>Object.fromEntries(Object.entries(e).filter(([e])=>v(e))),b=`\0mintlify-raw-body-value:`,x=e=>!m(e)&&(Array.isArray(e)||r(e)),S=e=>{let t=[],n=Object.fromEntries(Object.entries(y(e)).map(([e,n])=>x(n)?(t.push(n),[e,`${b}${t.length-1}`]):[e,n]));return w(i(n).body,t)},C=e=>Object.assign(Object.assign({},i(e)),{body:S(e)}),w=(e,t)=>typeof e==`string`&&e.startsWith(b)?t[Number(e.slice(25))]:Array.isArray(e)?e.map(e=>w(e,t)):r(e)&&!m(e)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,w(n,t)])):e,T=e=>``,E=e=>e===void 0?``:JSON.stringify(e,(e,t)=>m(t)?T(t):t,2),D=e=>{if(e.trim()===``)return{ok:!0,value:void 0};try{return{ok:!0,value:JSON.parse(e)}}catch{let{offset:t,openOffsets:n,reason:r}=X(e)??{offset:e.length,openOffsets:[]},i=t-1;for(;i>=0&&V.includes(e.charAt(i));)i--;let{line:a,column:o}=L(e,t);return{ok:!1,error:{offset:t,line:a,column:o,startLine:i<0?a:L(e,i).line,openLines:n.map(t=>L(e,t).line),unclosedBlocks:B(e),reason:r}}}},O=({schema:e,body:t,initialBody:n})=>{if(Array.isArray(e?.oneOf)){let r=e.oneOf.filter(d);return[...new Set(r.flatMap(e=>O({schema:e,body:t,initialBody:n})))]}if(e?.type!==`object`||!r(t))return[];let i=r(n)?n:{},a=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(e.properties??{}).flatMap(([e,n])=>{let r=!a.has(e)&&!(o(n)&&n.isRequired===!0),s=t[e]!==void 0&&!(0,g.default)(t[e],i[e]);return r&&s?[e]:[]})},k=({schema:e,value:t,previousInputs:n})=>{if(t===void 0)return{};let r=e===void 0?{}:c({schema:e,example:t}),a=[];P(t,i(r).body,[],a);let o;if(a.some(e=>e.length===0))o={[_]:t};else{o=Object.assign({},r);for(let e of a){for(let t of Object.keys(o)){let n=j(t);(n===void 0||M(n,e))&&delete o[t]}o[`${_}.${e.map(u).join(`.`)}`]=N(t,e)}(0,g.default)(S(o),t)||(o={[_]:t})}return F(o,n)},A=(e,t)=>{if(e?.type!==`object`||!r(t))return[];let n=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(e.properties??{}).forEach(([e,t])=>{o(t)&&t.isRequired===!0&&n.add(e)}),[...n].filter(e=>!Object.prototype.hasOwnProperty.call(t,e))},j=e=>{let[t,...n]=a(e);return t===_?s(n):void 0},M=(e,t)=>t.length<=e.length&&t.every((t,n)=>e[n]===t),N=(e,t)=>t.reduce((e,t)=>{if(Array.isArray(e))return e[Number(t)];if(r(e))return e[t]},e),P=(e,t,n,i)=>{if(!(0,g.default)(e,t)){if(r(e)&&r(t)){if(Object.keys(t).some(t=>!Object.prototype.hasOwnProperty.call(e,t))){i.push(n);return}for(let[r,a]of Object.entries(e))P(a,t[r],[...n,r],i)}else Array.isArray(e)&&Array.isArray(t)&&e.length===t.length?e.forEach((e,r)=>{P(e,t[r],[...n,String(r)],i)}):i.push(n)}},F=(e,t)=>{if(t===void 0)return e;let n=Object.assign({},e);for(let[e,r]of Object.entries(t)){if(!m(r)||!v(e))continue;let t=T(r);if(n[e]===t){n[e]=r;continue}let i=j(e);if(i!==void 0)for(let[e,a]of Object.entries(n)){let o=j(e);if(o===void 0||!x(a)||!M(i,o))continue;let s=i.slice(o.length);N(a,s)===t&&(n[e]=I(a,s,r))}}return n},I=(e,t,n)=>{let[i,...a]=t;if(i===void 0)return n;if(Array.isArray(e)){let t=[...e];return t[Number(i)]=I(t[Number(i)],a,n),t}return r(e)?Object.assign(Object.assign({},e),{[i]:I(e[i],a,n)}):e},L=(e,t)=>{let n=e.slice(0,t).split(` `);return{line:n.length,column:(n[n.length-1]?.length??0)+1}},R=(e,t)=>t>=e.startLine&&t<=e.line||e.openLines.slice(1).includes(t)||e.unclosedBlocks.some(({startLine:e,endLine:n})=>t>=e&&t<=n),z=e=>/^[ \t]*/.exec(e)?.[0].length??0,B=e=>{let t=e.split(` `),n=t.findIndex(e=>e.trim()!==``),r=[],i=[];t.forEach((e,t)=>{if(e.trim()===``)return;let a=z(e);for(;(r.at(-1)?.level??-1)>=a;){let n=r.pop();n!==void 0&&!e.trim().startsWith(n.closer)&&i.push({startLine:n.index+1,endLine:t})}let o=e.trimEnd().at(-1);t!==n&&(o===`{`||o===`[`)&&r.push({index:t,level:a,closer:o===`{`?`}`:`]`})});for(let e of r)i.push({startLine:e.index+1,endLine:t.length});return i.sort((e,t)=>e.startLine-t.startLine)},V=` \r`,H=class{constructor(e){this.result=e}},U=/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y,W=/^[0-9a-fA-F]$/,G=new Set([`"`,`\\`,`/`,`b`,`f`,`n`,`r`,`t`]),K=/^[A-Za-z_$]$/,q=/^[0-9]$/,J=512,Y=e=>e===`"`||e===`{`||e===`[`||e===`-`||q.test(e),X=e=>{let t=0,n=!1,r=[],i=e=>{throw new H({offset:t,openOffsets:[...r],reason:e})},a=()=>{let t=r.at(-1);if(t!==void 0)return{kind:`unclosedBracket`,bracket:e[t]===`{`?`}`:`]`}},o=()=>{for(;t{e[t]!==n&&i(t>=e.length?a():r),t++},c=e=>{for(let t of e)s(t,{kind:`expectedValue`})},l=()=>{for(t++;;){let n=e[t];if((n===void 0||n<` `)&&i({kind:`unterminatedString`}),n===`"`){t++;return}if(n===`\\`){t++;let n=e[t];if(n===`u`){t++;for(let n=0;n<4;n++)W.test(e[t]??``)||i(),t++}else n!==void 0&&G.has(n)?t++:i()}else t++}},u=()=>{U.lastIndex=t;let n=U.exec(e);n===null?i({kind:`expectedValue`}):t+=n[0].length},d=(s,c)=>{if(r.length>=J&&i(),r.push(t),t++,o(),e[t]!==s)for(n=!1;o(),c(),o(),e[t]===`,`;)t++,n=!0;let l=e[t];if(l===void 0)return i(a());l!==s&&((l===`}`||l===`]`)&&i({kind:`mismatchedBracket`,expected:s,found:l}),!(q.test(l)&&q.test(e[t-1]??``))&&(Y(l)||K.test(l))&&i({kind:`missingComma`}),i()),t++,r.pop()},f=()=>{let r=n;n=!1;let o=e[t];if(o===`"`)l();else{if(o===void 0)return i(a());o===`}`&&r&&i({kind:`trailingComma`}),o===`'`&&i({kind:`singleQuotes`}),K.test(o)&&i({kind:`unquotedKey`}),i()}},p=()=>{let r=n;n=!1,o();let m=e[t];m===`{`?d(`}`,()=>{f(),o(),s(`:`,{kind:`missingColon`}),p()}):m===`[`?d(`]`,p):m===`"`?l():m===`t`?c(`true`):m===`f`?c(`false`):m===`n`?c(`null`):m===`-`||m!==void 0&&q.test(m)?u():i(m===void 0?a():m===`]`&&r?{kind:`trailingComma`}:m===`'`?{kind:`singleQuotes`}:{kind:`expectedValue`})};try{p(),o(),te.startsWith(`${l.server}.`),Q=n((e,t)=>({inputs:{},apiReferenceData:void 0,initializeInputs:t=>e({inputs:Object.assign({},t)}),initializeApiReferenceData:t=>e({apiReferenceData:t}),setInput:(t,n)=>e(e=>{let r=Object.assign(Object.assign({},e.inputs),{[t]:n}),i=t.match(/^(.+)\.oneOf\.(\d+)$/);if(i){let[,e]=i;Object.keys(r).forEach(n=>{n!==t&&n.startsWith(`${e}.oneOf.`)&&delete r[n]})}return{inputs:r}}),setInputs:t=>e(e=>({inputs:Object.assign(Object.assign({},e.inputs),t)})),replaceInputs:t=>e({inputs:t}),replaceBodyInputs:t=>e(e=>({inputs:Object.assign(Object.assign({},Object.fromEntries(Object.entries(e.inputs).filter(([e])=>!v(e)))),Object.fromEntries(Object.entries(t).filter(([e])=>v(e))))})),replaceServerInputs:t=>e(e=>({inputs:Object.assign(Object.assign({},Object.fromEntries(Object.entries(e.inputs).filter(([e])=>!Z(e)))),Object.fromEntries(Object.entries(t).filter(([e])=>Z(e))))})),deleteInput:t=>e(e=>{let n=Object.assign({},e.inputs);delete n[t];let r=t+`.`;return Object.keys(n).forEach(e=>{e.startsWith(r)&&delete n[e]}),{inputs:n}}),getInput:e=>t().inputs[e],getApiPlaygroundInputs:()=>C(t().inputs),clear:()=>e({inputs:{}}),reset:()=>e({inputs:{},selectedSecurityOptionIndex:0,selectedExampleIndex:0,selectedExampleName:void 0,selectedRequestBodyContentTypeIndex:0,selectedResponseContentTypeIndex:0}),selectedBaseUrlIndex:0,setSelectedBaseUrlIndex:t=>e({selectedBaseUrlIndex:t}),selectedSecurityOptionIndex:0,setSelectedSecurityOptionIndex:t=>e({selectedSecurityOptionIndex:t}),selectedExampleIndex:0,selectedExampleName:void 0,setSelectedExampleIndex:(t,n)=>e(n===void 0?{selectedExampleIndex:t}:{selectedExampleIndex:t,selectedExampleName:n}),selectedRequestBodyContentTypeIndex:0,setSelectedRequestBodyContentTypeIndex:t=>e({selectedRequestBodyContentTypeIndex:t}),selectedResponseContentTypeIndex:0,setSelectedResponseContentTypeIndex:t=>e({selectedResponseContentTypeIndex:t})})),$=e=>({value:Q(t=>t.inputs[e]),setInput:Q(e=>e.setInput)}),ee=()=>{let e=Q(p(e=>e.inputs));return(0,h.useMemo)(()=>C(e),[e])},te=(e=300)=>{let t=Q(p(e=>e.inputs)),[n,r]=(0,h.useState)(t);return(0,h.useEffect)(()=>{let n=setTimeout(()=>{r(t)},e);return()=>{clearTimeout(n)}},[t,e]),(0,h.useMemo)(()=>C(n),[n])};export{E as a,S as c,D as d,y as f,Q as i,R as l,te as n,O as o,$ as r,A as s,ee as t,k as u};