const q=new Set(["text/event-stream","application/jsonl","application/json-seq","multipart/mixed"]);function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function c(e,t){const s=e[t];return i(s)?s:void 0}function l(e,t){const s=e[t];return Array.isArray(s)?s:[]}function b(e,t){let s=0;for(const a of Object.keys(e))t.has(a)&&s++;return s}function O(e){let t=0;for(const s of Object.values(e))i(s)&&s.itemSchema!=null&&t++;return t}function S(e){return b(e,q)}function d(e){return e.filter(t=>i(t)?t.in==="querystring":!1).length}function g(e,t){const s=e.responses;if(i(s))for(const o of Object.values(s))i(o)&&i(o.content)&&(t.streaming+=S(o.content),t.itemSchema+=O(o.content));const a=c(e,"requestBody");if(a){const o=c(a,"content");o&&(t.streaming+=S(o),t.itemSchema+=O(o))}const m=l(e,"parameters");t.queryStringParams+=d(m)}function v(e,t){const s=l(e,"parameters");t.queryStringParams+=d(s);const a=["get","put","post","delete","patch","head","options","trace","query"];for(const o of a){const n=e[o];i(n)&&(o==="query"&&t.queryMethod++,g(n,t))}const m=c(e,"additionalOperations");if(m){t.additionalOps+=Object.keys(m).length;for(const o of Object.values(m))i(o)&&g(o,t)}}function f(e,t){e.discriminator!=null&&t.discriminator++,c(e,"xml")?.nodeType!=null&&t.xmlNodeType++;const a=e.items;i(a)&&f(a,t);for(const o of["properties","patternProperties"]){const n=e[o];if(i(n))for(const r of Object.values(n))i(r)&&f(r,t)}const m=e.additionalProperties;i(m)&&f(m,t);for(const o of["oneOf","anyOf","allOf","prefixItems"]){const n=e[o];if(Array.isArray(n))for(const r of n)i(r)&&f(r,t)}}function T(e){if(!i(e))return null;const t={streamingOperations:0,itemSchemaMediaTypes:0,additionalOperations:0,serversWithName:0,discriminatorSchemas:0,queryMethodOperations:0,parametersWithQueryString:0,oauth2WithMetadataUrl:0,oauth2DeviceAuthorization:0,componentMediaTypes:0,xmlNodeTypeUsage:0},s=l(e,"servers");for(const n of s)i(n)&&n.name!=null&&t.serversWithName++;const a=c(e,"paths");if(a){const n={streaming:0,additionalOps:0,queryMethod:0,queryStringParams:0,itemSchema:0};for(const r of Object.values(a))i(r)&&v(r,n);t.streamingOperations=n.streaming,t.additionalOperations=n.additionalOps,t.queryMethodOperations=n.queryMethod,t.parametersWithQueryString=n.queryStringParams,t.itemSchemaMediaTypes=n.itemSchema}const m=c(e,"webhooks");if(m){const n={streaming:0,additionalOps:0,queryMethod:0,queryStringParams:0,itemSchema:0};for(const r of Object.values(m))i(r)&&v(r,n);t.streamingOperations+=n.streaming,t.additionalOperations+=n.additionalOps,t.queryMethodOperations+=n.queryMethod,t.parametersWithQueryString+=n.queryStringParams,t.itemSchemaMediaTypes+=n.itemSchema}const o=c(e,"components");if(o){const n=c(o,"mediaTypes");if(n){t.componentMediaTypes=Object.keys(n).length;for(const u of Object.values(n))i(u)&&u.itemSchema!=null&&t.itemSchemaMediaTypes++}const r=c(o,"schemas");if(r){const u={discriminator:0,xmlNodeType:0};for(const p of Object.values(r))i(p)&&f(p,u);t.discriminatorSchemas=u.discriminator,t.xmlNodeTypeUsage=u.xmlNodeType}const h=c(o,"securitySchemes");if(h)for(const u of Object.values(h))i(u)&&u.type==="oauth2"&&(u.oauth2MetadataUrl!=null&&t.oauth2WithMetadataUrl++,c(u,"flows")?.deviceAuthorization!=null&&t.oauth2DeviceAuthorization++);const y=c(o,"parameters");y&&(t.parametersWithQueryString+=d(Object.values(y)))}return t}export{T as computeOas32Stats};
