/* eslint-disable react-hooks/rules-of-hooks */ import { useState } from "react";
/**
 * This is used to dynamically allow controlling hooks by providing a `value` +
 * `setValue` or defaulting to uncontrolled behavior with local state.
 *
 * @internal
 * @since 6.0.0
 */ export function useEnsuredState(options) {
    const { value, setValue, defaultValue } = options;
    if (typeof value !== "undefined" && typeof setValue !== "undefined") {
        return [
            value,
            setValue
        ];
    }
    if (typeof value !== "undefined" || typeof setValue !== "undefined") {
        throw new Error("Both a `value` and `setValue` must be defined for controlled components.");
    }
    if (typeof defaultValue === "undefined") {
        throw new Error("A `defaultValue` must be defined for uncontrolled components.");
    }
    return useState(defaultValue);
}

//# sourceMappingURL=useEnsuredState.js.map