import '../../../../../node_modules/preact/compat/dist/compat.module.mjs';
import { useB2BInternals } from './useB2BInternals.mjs';
import { useState as h, useEffect as p } from '../../../../../node_modules/preact/hooks/dist/hooks.module.mjs';

const useRoles = (includeOrgRoles = false)=>{
    const b2bInternals = useB2BInternals();
    const [roles, setRoles] = h(b2bInternals.bootstrap.getSync().rbacPolicy?.roles);
    p(()=>{
        b2bInternals.bootstrap.getAsync().then((value)=>{
            setRoles(value.rbacPolicy?.roles);
        });
    });
    let allRoles = roles;
    if (includeOrgRoles) {
        const orgRoles = b2bInternals.dataLayer.state?.organization?.custom_roles ?? [];
        allRoles = (roles ?? []).concat(orgRoles ?? []);
    }
    return allRoles;
};

export { useRoles };
//# sourceMappingURL=useRoles.mjs.map
