import{LayoutVariant,isUndefined,addTrailingSlash}from"@redocly/theme";import{WindowReferenceOptions}from"../../constants";import{argValueToBoolean,argValueToExpandLevel,argValueToInt,argValueToNumber,getWindowReferenceOptions,normalizePath}from"../../utils";import{normalizeShowExtensions,normalizeScrollYOffset}from"./helpers";import{Languages}from"../code-samples/constants";export function normalizeOptions(e,o){var n,a,i,s,l,r,t,d,u,c,m;e=Object.assign(Object.assign(Object.assign({},o),e),{markdocOptions:Object.assign(Object.assign({},null==e?void 0:e.markdocOptions),{components:Object.assign(Object.assign({},null===(n=null==o?void 0:o.markdocOptions)||void 0===n?void 0:n.components),null===(a=null==e?void 0:e.markdocOptions)||void 0===a?void 0:a.components),tags:Object.assign(Object.assign({},null===(i=null==o?void 0:o.markdocOptions)||void 0===i?void 0:i.tags),null===(s=null==e?void 0:e.markdocOptions)||void 0===s?void 0:s.tags),nodes:Object.assign(Object.assign(Object.assign({},null===(l=null==o?void 0:o.markdocOptions)||void 0===l?void 0:l.nodes),null===(r=null==e?void 0:e.markdocOptions)||void 0===r?void 0:r.nodes),{heading:(null===(d=null===(t=null==o?void 0:o.markdocOptions)||void 0===t?void 0:t.nodes)||void 0===d?void 0:d.heading)||(null===(u=null==e?void 0:e.markdocOptions)||void 0===u?void 0:u.nodes.heading)})})});const p=Array.isArray(e.ignoreNamedSchemas)?e.ignoreNamedSchemas:null===(c=e.ignoreNamedSchemas)||void 0===c?void 0:c.split(",").map((e=>e.trim()));return{downloadUrls:e.downloadUrls,schemaDefinitionsTagName:e.schemaDefinitionsTagName,corsProxyUrl:e.corsProxyUrl&&addTrailingSlash(e.corsProxyUrl),hideSidebar:argValueToBoolean(e.hideSidebar,!1),jsonSamplesExpandLevel:argValueToExpandLevel(e.jsonSamplesExpandLevel,2),generatedSamplesMaxDepth:argValueToInt(e.generatedSamplesMaxDepth,8),hideDownloadButtons:argValueToBoolean(e.hideDownloadButtons,!1),hideInfoMetadata:argValueToBoolean(e.hideInfoMetadata,!1),hideLoading:argValueToBoolean(e.hideLoading,!1),hideSchemaTitles:argValueToBoolean(e.hideSchemaTitles,!1),maxDisplayedEnumValues:argValueToNumber(e.maxDisplayedEnumValues),mockServer:(null===(m=e.mockServer)||void 0===m?void 0:m.url)?{url:e.mockServer.url,position:e.mockServer.position||"first",description:e.mockServer.description||"Mock server"}:void 0,hideReplay:argValueToBoolean(e.hideReplay,!1),oAuth2RedirectURI:e.oAuth2RedirectURI||null,onlyRequiredInSamples:argValueToBoolean(e.onlyRequiredInSamples,!1),onDeepLinkClick:e.onDeepLinkClick||getWindowReferenceOptions(WindowReferenceOptions.ON_DEEP_LINK_CLICK),requestInterceptor:e.requestInterceptor||getWindowReferenceOptions(WindowReferenceOptions.REQUEST_INTERCEPTOR),routingBasePath:isUndefined(e.disableRouter)?"":e.routingBasePath&&normalizePath(e.routingBasePath)||"",schemasExpansionLevel:argValueToExpandLevel(e.schemasExpansionLevel),feedback:e.feedback||{hide:!1},sortRequiredPropsFirst:argValueToBoolean(e.sortRequiredPropsFirst,!1),scrollYOffset:normalizeScrollYOffset(e.scrollYOffset),showExtensions:normalizeShowExtensions(e.showExtensions),sanitize:argValueToBoolean(e.sanitize,!1),skipBundle:argValueToBoolean(e.skipBundle,!1),ignoreNamedSchemas:new Set(p),markdocOptions:null==e?void 0:e.markdocOptions,codeSamples:e.codeSamples||{languages:Object.values(Languages).map((e=>({lang:e})))},layout:e.layout||LayoutVariant.THREE_PANEL,events:e.events||{},unstable_hooks:e.unstable_hooks||getWindowReferenceOptions(WindowReferenceOptions.HOOKS)||{},unstable_externalCodeSamples:e.unstable_externalCodeSamples||[],hidePropertiesPrefix:argValueToBoolean(null==e?void 0:e.hidePropertiesPrefix,!1)}}
//# sourceMappingURL=normalizeOptions.js.map