import { useState, useEffect } from 'react';
import parseToken from '../services/check.js';
export function useLicense(licenceKey) {
    const [licenseInfo, setLicenseInfo] = useState(process.env.NODE_ENV === 'development' ? { valid: true, allowed: true } : {});
    useEffect(() => {
        async function validate() {
            const info = await parseToken(licenceKey);
            setLicenseInfo(info);
        }
        validate();
    }, [licenceKey]);
    return { licenseInfo, isValid: isValidLicense(licenseInfo) };
}
function isValidLicense(license) {
    return (license.valid && license.allowed && !license.expired) || !!license.local;
}
//# sourceMappingURL=useLicense.js.map