import Cookies from "js-cookie";

const RelaComNoKey = "compute-Console-RelaComNo";
const RelaComNameKey = "compute-Console-RelaComName";
const superKey = "compute-Console-superUser";
const NoticeKey = "compute-Console-Notice";
const ActionKey = "compute-Console-Action";
const BtnKey = "compute-Console-MenuBtn";
const MenuKey = "compute-Console-Menu";
const InfoKey = "compute-Console-Info";


const VersionKey = "compute-Console-Version-Date";

export const TokenKey = "compute-Console-Token";
export const SECRET_KEY = "key123";

export const  time_config={
  d:new Date('2025-04-22 00:00:00').getTime(),
  a:[
    // {
    //   label:'8',
    //   a:new Date('2025-04-08 08:00:00').getTime(),
    //   key:'0,0,0,0',
    //   lang:30
    // },
    {
      label:'9',
      a:new Date('2025-04-09 08:00:00').getTime(),
      key:'0,1,0,0',
      lang:20
    },
    {
      label:'10',
      a:new Date('2025-04-10 08:00:00').getTime(),
      key:'0,0,1,0',
      lang:10
    },
    {
      label:'11',
      a:new Date('2025-04-11 08:00:00').getTime(),
      key:'1,1,1,1',
      lang:10
    }
  ]
}
export const TokenKey1 = "compute-Console-Token1";
export function setToken1(token) {
  return window.localStorage.setItem(TokenKey1, token);
}
export const TokenKey2 = "compute-Console-Token2";
export function setToken2(token) {
  return window.localStorage.setItem(TokenKey2, token);
}




export const getToken = () => localStorage.getItem(TokenKey) || "";

export function setToken(token) {
  return window.localStorage.setItem(TokenKey, token);
}

export function removeToken() {
  return localStorage.removeItem(TokenKey);
}

export function setSuperUser(state: boolean) {
  return Cookies.set(superKey, state ? "1" : "0");
}

export function setRelaComNo(relaComNo) {
  return window.sessionStorage.setItem(RelaComNoKey, relaComNo);
}

export function removeRelaComNo() {
  return window.sessionStorage.removeItem(RelaComNoKey);
}

export function getVersionDate(){
 return localStorage.getItem(VersionKey) 
}

export function setVersionDate(date: string){
  return localStorage.setItem(VersionKey, date)
}

export function getRelaComNo() {
  return window.sessionStorage.getItem(RelaComNoKey);
}

export function setRelaComName(relaComName) {
  return window.sessionStorage.setItem(RelaComNameKey, relaComName);
}

export function getRelaComName() {
  return window.sessionStorage.getItem(RelaComNameKey);
}

export function getSuperUser() {
  return Cookies.get(superKey);
}

export function getMenu() {
  const menu = Cookies.get(MenuKey);
  if (menu) {
    return JSON.parse(menu);
  } else {
    return [];
  }
}

export function setMenu(menu) {
  return Cookies.set(MenuKey, menu);
}

export function removeMenu() {
  return Cookies.remove(MenuKey);
}

export function getBtn() {
  return Cookies.get(BtnKey);
}

export function setBtn(has) {
  return Cookies.set(BtnKey, has);
}

export function removeBtn() {
  return Cookies.remove(BtnKey);
}

export function getNotice() {
  return Cookies.get(NoticeKey);
}

export function setNotice(has) {
  return Cookies.set(NoticeKey, has);
}

export function removeNotice() {
  return Cookies.remove(NoticeKey);
}

export function getAction() {
  return localStorage.getItem(ActionKey);
}

export function setAction(has) {
  return localStorage.setItem(ActionKey, has);
}

export function removeAction() {
  return localStorage.removeItem(ActionKey);
}
