export { isJsonRecord, missingScopes, readBoundedInteger, readBoundedPositiveInteger, readChannelConversationKind, readChannelLifecycleAction, readOptionalBoundedInteger, scopeMatches, } from '@pellux/goodvibes-daemon-sdk';
export function toSerializableJson(value, stack = new Map(), path = '$') {
    if (!value || typeof value !== 'object')
        return value;
    const prior = stack.get(value);
    if (prior) {
        return { $ref: prior };
    }
    const next = new Map(stack);
    next.set(value, path);
    if (Array.isArray(value)) {
        return value.map((entry, index) => toSerializableJson(entry, next, `${path}[${index}]`));
    }
    return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
        key,
        toSerializableJson(entry, next, `${path}.${key}`),
    ]));
}
export function serializableJsonResponse(body, init) {
    return Response.json(toSerializableJson(body), init);
}
