"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.boxShadow = exports.border = exports.color = exports.colorHash = void 0;
const vars_1 = require("./vars");
const hash_1 = require("@saulx/hash");
const selectVar = (group, color, option) => {
    const g = vars_1.vars[group];
    if (!g) {
        return;
    }
    if (!(color in g)) {
        return;
    }
    const c = g[color];
    if (!option) {
        return g._ === undefined
            ? c[0]
            : c[g._.default ?? g._.normal ?? g._.primary ?? g._.strong];
    }
    if (typeof option === 'number') {
        if (option === 0) {
            return c[0];
        }
        if (option > 0) {
            return c[1][option] ?? c[1][c[1].length - 1];
        }
        else if (option < 0) {
            const select = Math.abs(option);
            return c[2][select] ?? c[c[2].length - 1];
        }
        return;
    }
    return c[g._[option]];
};
const colorHash = (group, value) => {
    const hashed = value === undefined ? 0 : (0, hash_1.hash)(value);
    const g = vars_1.vars[group];
    const colors = Object.keys(g);
    const index = Math.floor(Math.abs(Math.sin(hashed)) * (colors.length - 1)) + 1;
    // @ts-ignore
    return colors[index];
};
exports.colorHash = colorHash;
const color = (group, color, option) => {
    const colorVar = selectVar(group, color, option);
    if (colorVar) {
        return `var(--${colorVar})`;
    }
    return ``;
};
exports.color = color;
const border = (size = 1, borderColor = 'default', variant = 'strong') => {
    return `${size}px solid ${(0, exports.color)('border', borderColor, variant)}`;
};
exports.border = border;
// color...
const boxShadow = (size) => {
    let shadowSize;
    let shadowColor;
    // correct color...
    if (size === 'small') {
        shadowSize = '0px 2px 4px';
        shadowColor = 'rgba(156, 156, 156, 0.08)';
    }
    if (size === 'medium') {
        shadowSize = '0px 1px 4px';
        shadowColor = 'rgba(156, 156, 156, 0.08)';
    }
    if (size === 'large') {
        shadowSize = '0px 12px 24px';
        shadowColor = 'rgba(0, 0, 0, 0.08)';
    }
    return ` ${shadowSize} ${shadowColor}`;
};
exports.boxShadow = boxShadow;
//# sourceMappingURL=varsUtilities.js.map