import * as util from "../core/util.js";
const error = () => {
    const Sizable = {
        string: { unit: "문자", verb: "to have" },
        file: { unit: "λ°”μ΄νŠΈ", verb: "to have" },
        array: { unit: "개", verb: "to have" },
        set: { unit: "개", verb: "to have" },
    };
    function getSizing(origin) {
        return Sizable[origin] ?? null;
    }
    const FormatDictionary = {
        regex: "μž…λ ₯",
        email: "이메일 μ£Όμ†Œ",
        url: "URL",
        emoji: "이λͺ¨μ§€",
        uuid: "UUID",
        uuidv4: "UUIDv4",
        uuidv6: "UUIDv6",
        nanoid: "nanoid",
        guid: "GUID",
        cuid: "cuid",
        cuid2: "cuid2",
        ulid: "ULID",
        xid: "XID",
        ksuid: "KSUID",
        datetime: "ISO λ‚ μ§œμ‹œκ°„",
        date: "ISO λ‚ μ§œ",
        time: "ISO μ‹œκ°„",
        duration: "ISO κΈ°κ°„",
        ipv4: "IPv4 μ£Όμ†Œ",
        ipv6: "IPv6 μ£Όμ†Œ",
        cidrv4: "IPv4 λ²”μœ„",
        cidrv6: "IPv6 λ²”μœ„",
        base64: "base64 인코딩 λ¬Έμžμ—΄",
        base64url: "base64url 인코딩 λ¬Έμžμ—΄",
        json_string: "JSON λ¬Έμžμ—΄",
        e164: "E.164 번호",
        jwt: "JWT",
        template_literal: "μž…λ ₯",
    };
    const TypeDictionary = {
        nan: "NaN",
    };
    return (issue) => {
        switch (issue.code) {
            case "invalid_type": {
                const expected = TypeDictionary[issue.expected] ?? issue.expected;
                const receivedType = util.parsedType(issue.input);
                const received = TypeDictionary[receivedType] ?? receivedType;
                if (/^[A-Z]/.test(issue.expected)) {
                    return `잘λͺ»λœ μž…λ ₯: μ˜ˆμƒ νƒ€μž…μ€ instanceof ${issue.expected}, 받은 νƒ€μž…μ€ ${received}μž…λ‹ˆλ‹€`;
                }
                return `잘λͺ»λœ μž…λ ₯: μ˜ˆμƒ νƒ€μž…μ€ ${expected}, 받은 νƒ€μž…μ€ ${received}μž…λ‹ˆλ‹€`;
            }
            case "invalid_value":
                if (issue.values.length === 1)
                    return `잘λͺ»λœ μž…λ ₯: 값은 ${util.stringifyPrimitive(issue.values[0])} 이어야 ν•©λ‹ˆλ‹€`;
                return `잘λͺ»λœ μ˜΅μ…˜: ${util.joinValues(issue.values, "λ˜λŠ” ")} 쀑 ν•˜λ‚˜μ—¬μ•Ό ν•©λ‹ˆλ‹€`;
            case "too_big": {
                const adj = issue.inclusive ? "μ΄ν•˜" : "미만";
                const suffix = adj === "미만" ? "이어야 ν•©λ‹ˆλ‹€" : "μ—¬μ•Ό ν•©λ‹ˆλ‹€";
                const sizing = getSizing(issue.origin);
                const unit = sizing?.unit ?? "μš”μ†Œ";
                if (sizing)
                    return `${issue.origin ?? "κ°’"}이 λ„ˆλ¬΄ ν½λ‹ˆλ‹€: ${issue.maximum.toString()}${unit} ${adj}${suffix}`;
                return `${issue.origin ?? "κ°’"}이 λ„ˆλ¬΄ ν½λ‹ˆλ‹€: ${issue.maximum.toString()} ${adj}${suffix}`;
            }
            case "too_small": {
                const adj = issue.inclusive ? "이상" : "초과";
                const suffix = adj === "이상" ? "이어야 ν•©λ‹ˆλ‹€" : "μ—¬μ•Ό ν•©λ‹ˆλ‹€";
                const sizing = getSizing(issue.origin);
                const unit = sizing?.unit ?? "μš”μ†Œ";
                if (sizing) {
                    return `${issue.origin ?? "κ°’"}이 λ„ˆλ¬΄ μž‘μŠ΅λ‹ˆλ‹€: ${issue.minimum.toString()}${unit} ${adj}${suffix}`;
                }
                return `${issue.origin ?? "κ°’"}이 λ„ˆλ¬΄ μž‘μŠ΅λ‹ˆλ‹€: ${issue.minimum.toString()} ${adj}${suffix}`;
            }
            case "invalid_format": {
                const _issue = issue;
                if (_issue.format === "starts_with") {
                    return `잘λͺ»λœ λ¬Έμžμ—΄: "${_issue.prefix}"(으)둜 μ‹œμž‘ν•΄μ•Ό ν•©λ‹ˆλ‹€`;
                }
                if (_issue.format === "ends_with")
                    return `잘λͺ»λœ λ¬Έμžμ—΄: "${_issue.suffix}"(으)둜 λλ‚˜μ•Ό ν•©λ‹ˆλ‹€`;
                if (_issue.format === "includes")
                    return `잘λͺ»λœ λ¬Έμžμ—΄: "${_issue.includes}"을(λ₯Ό) 포함해야 ν•©λ‹ˆλ‹€`;
                if (_issue.format === "regex")
                    return `잘λͺ»λœ λ¬Έμžμ—΄: μ •κ·œμ‹ ${_issue.pattern} νŒ¨ν„΄κ³Ό μΌμΉ˜ν•΄μ•Ό ν•©λ‹ˆλ‹€`;
                return `잘λͺ»λœ ${FormatDictionary[_issue.format] ?? issue.format}`;
            }
            case "not_multiple_of":
                return `잘λͺ»λœ 숫자: ${issue.divisor}의 λ°°μˆ˜μ—¬μ•Ό ν•©λ‹ˆλ‹€`;
            case "unrecognized_keys":
                return `인식할 수 μ—†λŠ” ν‚€: ${util.joinValues(issue.keys, ", ")}`;
            case "invalid_key":
                return `잘λͺ»λœ ν‚€: ${issue.origin}`;
            case "invalid_union":
                return `잘λͺ»λœ μž…λ ₯`;
            case "invalid_element":
                return `잘λͺ»λœ κ°’: ${issue.origin}`;
            default:
                return `잘λͺ»λœ μž…λ ₯`;
        }
    };
};
export default function () {
    return {
        localeError: error(),
    };
}