"use strict";
"use client";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.useId = useId;
//https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/useId.ts
const react_1 = __importStar(require("react"));
/* eslint-disable react-hooks/rules-of-hooks */
let globalId = 0;
function useGlobalId(idOverride) {
    // biome-ignore lint/correctness/useHookAtTopLevel: At runtime, `useGlobalId` is invariant.
    const [defaultId, setDefaultId] = (0, react_1.useState)(idOverride);
    const id = idOverride || defaultId;
    // biome-ignore lint/correctness/useHookAtTopLevel: At runtime, `useGlobalId` is invariant.
    (0, react_1.useEffect)(() => {
        if (defaultId == null) {
            // Fallback to this default id when possible.
            // Use the incrementing value for client-side rendering only.
            // We can't use it server-side.
            // If you want to use random values please consider the Birthday Problem: https://en.wikipedia.org/wiki/Birthday_problem
            globalId += 1;
            setDefaultId(`aksel-id-${globalId}`); // eslint-disable-line react-hooks/set-state-in-effect
        }
    }, [defaultId]);
    return id;
}
const maybeReactUseId = react_1.default["useId" + "" // Workaround for https://github.com/webpack/webpack/issues/14814
];
/**
 *
 * @example <div id={useId()} />
 * @param idOverride
 * @returns {string}
 */
function useId(idOverride) {
    var _a;
    if (maybeReactUseId !== undefined) {
        const reactId = maybeReactUseId();
        return idOverride !== null && idOverride !== void 0 ? idOverride : reactId.replace(/(:)/g, "");
    }
    // biome-ignore lint/correctness/useHookAtTopLevel: `useId` is invariant at runtime.
    return (_a = useGlobalId(idOverride)) !== null && _a !== void 0 ? _a : "";
}
//# sourceMappingURL=useId.js.map