import { useRef } from 'react';
import isDeepEqual from 'fast-deep-equal';
import { safeSlugify } from '../../utils/string.js';
export function fixSpec(resolvedSpec) {
    const schemas = (resolvedSpec.components && resolvedSpec.components.securitySchemes) || {};
    for (const s of Object.keys(schemas)) {
        const scheme = schemas[s];
        if (scheme['x-type']) {
            scheme.type = scheme['x-type'];
        }
        if (scheme['x-scheme']) {
            scheme.scheme = scheme['x-scheme'];
        }
    }
}
export function useDeepCompareMemoize(value) {
    const ref = useRef(null);
    const signalRef = useRef(0);
    if (!isDeepEqual(value, ref.current)) {
        ref.current = value;
        signalRef.current += 1;
    }
    return [signalRef.current];
}
export function getMarkdownHeaderId(children) {
    if (typeof children[0] === 'string') {
        return `section/${safeSlugify(children[0])}`;
    }
    else if (children.children) {
        return getMarkdownHeaderId(children[0]);
    }
}
//# sourceMappingURL=utils.js.map