import { OpenIDConnectSchema as p } from "@scalar/workspace-store/entities/auth";
import { coerceValue as c } from "@scalar/workspace-store/schemas/typebox-coerce";
const u = (o) => {
  const s = Object.fromEntries((o.scopes_supported ?? []).map((a) => [a, ""])), r = new Set(o.grant_types_supported ?? ["authorization_code", "implicit"]), t = o.authorization_endpoint, e = o.token_endpoint, i = o.code_challenge_methods_supported?.includes("S256") ? "SHA-256" : o.code_challenge_methods_supported?.includes("plain") ? "plain" : "no", n = {};
  return r.has("implicit") && t && (n.implicit = {
    authorizationUrl: t,
    refreshUrl: t,
    scopes: s
  }), r.has("password") && e && (n.password = {
    tokenUrl: e,
    refreshUrl: e,
    scopes: s
  }), r.has("client_credentials") && e && (n.clientCredentials = {
    tokenUrl: e,
    refreshUrl: e,
    scopes: s
  }), r.has("authorization_code") && t && e && (n.authorizationCode = {
    authorizationUrl: t,
    tokenUrl: e,
    refreshUrl: e,
    "x-usePkce": i,
    scopes: s
  }), c(p, n);
};
export {
  u as openIDDiscoveryToFlows
};
