import { RadioOption } from "#elements/forms/Radio";

import { PolicyBinding } from "@goauthentik/api";

import { match } from "ts-pattern";

import { msg } from "@lit/localize";

export enum PolicyBindingCheckTarget {
    Policy = "policy",
    Group = "group",
    User = "user",
}

export const PolicyBindingCheckTargetToLabel = (ct: PolicyBindingCheckTarget) =>
    match(ct)
        .with(PolicyBindingCheckTarget.Group, () => msg("Group"))
        .with(PolicyBindingCheckTarget.User, () => msg("User"))
        .with(PolicyBindingCheckTarget.Policy, () => msg("Policy"))
        .exhaustive();

export const PolicyObjectKeys = {
    [PolicyBindingCheckTarget.Policy]: "policyObj",
    [PolicyBindingCheckTarget.Group]: "groupObj",
    [PolicyBindingCheckTarget.User]: "userObj",
} as const satisfies Record<PolicyBindingCheckTarget, keyof PolicyBinding>;

export function createPassFailOptions(): RadioOption<boolean>[] {
    return [
        {
            label: msg("Pass"),
            value: true,
        },
        {
            label: msg("Don't Pass"),
            value: false,
            default: true,
        },
    ];
}
