"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAvailableLanguagesForDevice = void 0;
const react_1 = require("react");
const _1 = __importDefault(require("."));
const useAvailableLanguagesForDevice = (deviceInfo) => {
    const [availableLanguages, setAvailableLanguages] = (0, react_1.useState)([]);
    const [loaded, setLoaded] = (0, react_1.useState)(false);
    const [error, setError] = (0, react_1.useState)(null);
    (0, react_1.useEffect)(() => {
        let dead = false;
        if (deviceInfo) {
            _1.default.getAvailableLanguagesDevice(deviceInfo).then(languages => {
                if (dead)
                    return;
                setAvailableLanguages(languages);
                setError(null);
                setLoaded(true);
            }, error => {
                if (dead)
                    return;
                setAvailableLanguages([]);
                setError(error);
                setLoaded(true);
            });
        }
        return () => {
            dead = true;
        };
    }, [deviceInfo]);
    return { availableLanguages, loaded, error };
};
exports.useAvailableLanguagesForDevice = useAvailableLanguagesForDevice;
//# sourceMappingURL=useAvailableLanguagesForDevice.js.map