'use strict';

require('../stores/index.js');
var arrayOperation = require('../utils/arrayOperation.js');
var vue = require('vue');
var userInfo = require('../stores/userInfo.js');

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

exports.auth = auth;
exports.authAll = authAll;
exports.auths = auths;
exports.hAuth = hAuth;
exports.hAuthAll = hAuthAll;
exports.hAuths = hAuths;
