import '../stores/index.mjs';
import { judgementSameArr } from '../utils/arrayOperation.mjs';
import { withDirectives, resolveDirective } from 'vue';
import { useUserInfo } from '../stores/userInfo.mjs';

function auth(value) {
  const stores = useUserInfo();
  return stores.userInfos.authApiList.some((v) => v === value);
}
function auths(value) {
  let flag = false;
  const stores = useUserInfo();
  stores.userInfos.authApiList.map((val) => {
    value.map((v) => {
      if (val === v) flag = true;
    });
  });
  return flag;
}
function authAll(value) {
  const stores = useUserInfo();
  return judgementSameArr(value, stores.userInfos.authApiList);
}
function hAuth(el, value) {
  return withDirectives(el, [[resolveDirective("auth"), value]]);
}
function hAuths(el, value) {
  return withDirectives(el, [[resolveDirective("auths"), value]]);
}
function hAuthAll(el, value) {
  return withDirectives(el, [[resolveDirective("auth-all"), value]]);
}

export { auth, authAll, auths, hAuth, hAuthAll, hAuths };
