import{d as P}from"../chunk-W5ETCPTA.js";import{W as l,_ as c,b as a,d as m,i as f,k as d,m as u,o as h,w as g}from"../chunk-Q5JRYDN7.js";import{a as y}from"../chunk-E7C5DUH2.js";import{createDiagnosable as E,defineKit as R}from"@typespec/compiler/typekit";R({httpOperation:{get:E(function(t){return P(this.program,t)}),getReturnType(t,e){let r=this.httpOperation.flattenResponses(t);e?.includeErrors||(r=r.filter(n=>!this.httpResponse.isErrorResponse(n)));let i={kind:"Intrinsic",name:"void"},s;if(!r.length)return i;if(r.length>1){let n=[...new Set(r.map(o=>o.responseContent.body?.type))];s=this.union.create({variants:n.map(o=>this.unionVariant.create({type:b(this,o)}))})}else s=b(this,r[0].responseContent.body?.type);return s},flattenResponses(t){let e=[];for(let r of t.responses)for(let i of r.responses){let s=i.properties.find(o=>o.kind==="contentType"),n;s?n=s.property.type.value:i.body&&(n="application/json"),e.push({statusCode:r.statusCodes,contentType:n,responseContent:i,type:r.type})}return e}}});function b(t,e){return e===void 0?{kind:"Intrinsic",name:"void"}:t.model.is(e)?t.model.getEffectiveModel(e):e}y(b,"getEffectiveType");import{defineKit as O}from"@typespec/compiler/typekit";O({httpPart:{is(t){return this.model.is(t)&&this.httpPart.get(t)!==void 0},get(t){return c(this.program,t)},unpack(t){let e=this.httpPart.get(t);return e?e.type:t}}});import{defineKit as x}from"@typespec/compiler/typekit";x({httpRequest:{body:{isExplicit(t){return t.parameters.properties.find(e=>e.kind==="body"||e.kind==="bodyRoot"||e.kind==="multipartBody")!==void 0}},getBodyParameters(t){let e=t.parameters.body;if(!e)return;let r=e.property;if(!r){if(e.type.kind==="Model")return e.type;throw new Error("Body property not found")}let i=r.name?r.name:"body";return this.model.create({properties:{[i]:r}})},getParameters(t,e){let r=new Set(Array.isArray(e)?e:[e]),i=new Map;if(r.forEach(n=>{n==="body"?this.httpRequest.getBodyParameters(t)?.properties.forEach((o,H)=>i.set(H,o)):t.parameters.properties.filter(o=>o.kind===n&&o.property).forEach(o=>i.set(o.property.name,o.property))}),i.size===0)return;let s=Object.fromEntries(i);return this.model.create({properties:s})}}});import{isErrorModel as v}from"@typespec/compiler";import{defineKit as M}from"@typespec/compiler/typekit";M({httpResponse:{isErrorResponse(t){return this.model.is(t.type)?v(this.program,t.type):!1},statusCode:{isSingle(t){return typeof t=="number"},isRange(t){return typeof t=="object"&&"start"in t&&"end"in t},isDefault(t){return t==="*"}}}});import{defineKit as T}from"@typespec/compiler/typekit";T({modelProperty:{getHttpParamOptions(t){if(m(this.program,t))return a(this.program,t);if(h(this.program,t))return u(this.program,t);if(d(this.program,t))return f(this.program,t)},getHttpHeaderOptions(t){return a(this.program,t)},getHttpPathOptions(t){return u(this.program,t)},getHttpQueryOptions(t){return f(this.program,t)},isHttpHeader(t){return m(this.program,t)},isHttpPathParam(t){return h(this.program,t)},isHttpQueryParam(t){return d(this.program,t)},isHttpMultipartBody(t){return g(this.program,t)}}});import{defineKit as k}from"@typespec/compiler/typekit";k({model:{isHttpFile(t){return l(this.program,t)}}});
