/**config api */
import { ref } from "vue";

const env = ref<string>(process.env.NODE_ENV || "development");
export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG;
export const apiUrlConfigPublish = import.meta.env.VITE_API_PUBLISH_URL;
export const apiUrlConfigReport = import.meta.env.VITE_API_REPORT_URL;

// if (process.env.VUE_APP_TEST) {
//   env = "test";
// }
const config = ref<any>({
  development: {
    // API_URI: "https://localhost:7260/api",
    API_URI: "https://hrmsbkk.case-collection.com/api/v1",
    API_URL_SUPPORT: "https://hrmsbkk.case-collection.com/api/v1/support",
    MEET_URI: "meet.frappet.com",
    LINK_EVALUATE_PUBLISH: "https://bma-ehr-publish.frappet.synology.me",
    API_REPORT_TEMPLATE_URI:
      "https://hrmsbkk.case-collection.com/api/v1/report-template",
  },
  test: {
    API_URI: "http://localhost:5010/api/v1",
    MEET_URI: "meet.frappet.com",
  },
  production: {
    API_URI: apiUrlConfig,
    API_URL_SUPPORT: `${apiUrlConfig}/support`,
    MEET_URI: "meet.frappet.com",
    LINK_EVALUATE_PUBLISH: apiUrlConfigPublish,
    API_REPORT_TEMPLATE_URI: apiUrlConfigReport,
  },
});

const API_URI = ref<string>(config.value[env.value].API_URI);
const API_URL_SUPPORT = ref<string>(config.value[env.value].API_URL_SUPPORT);
const MEET_URI = ref<string>(config.value[env.value].MEET_URI);
const LINK_EVALUATE_PUBLISH = ref<string>(
  config.value[env.value].LINK_EVALUATE_PUBLISH,
);
const API_REPORT_TEMPLATE_URI = ref<string>(
  config.value[env.value].API_REPORT_TEMPLATE_URI,
);

export default {
  env: env.value,
  config: config.value,
  API_URI: API_URI.value,
  API_URL_SUPPORT: API_URL_SUPPORT.value,
  MEET_URI: MEET_URI.value,
  LINK_EVALUATE_PUBLISH: LINK_EVALUATE_PUBLISH.value,
  API_REPORT_TEMPLATE_URI: API_REPORT_TEMPLATE_URI.value,
};
