import { _export_sfc } from './_plugin-vue_export-helper-e9a2c33e.js';
import { openBlock, createElementBlock, createBaseVNode, renderSlot, Fragment, createBlock, createVNode, QBtn, resolveComponent, withCtx, createTextVNode, ref, pushScopeId, popScopeId } from './__federation_expose_Modules-a9c6a6fc.js';
import { QInput } from './QInput-a81d9a9f.js';
import { QSelect } from './QSelect-b16471ac.js';

const _sfc_main$5 = {};
const _hoisted_1$1 = {
  class: "row",
  style: {
    "column-gap": "40px"
  }
};
const _hoisted_2$1 = {
  class: "col"
};
const _hoisted_3$1 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_4$1 = {
  class: "row"
};
const _hoisted_5 = {
  class: "col"
};
const _hoisted_6 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_7 = {
  class: "row"
};
const _hoisted_8 = {
  class: "row",
  style: {
    "column-gap": "40px"
  }
};
const _hoisted_9 = {
  class: "row",
  style: {
    "column-gap": "40px"
  }
};
const _hoisted_10 = {
  class: "col"
};
const _hoisted_11 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_12 = {
  class: "row"
};
const _hoisted_13 = {
  class: "col"
};
const _hoisted_14 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_15 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_16 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_17 = {
  class: "col text-right"
};
const _hoisted_18 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_19 = {
  class: "col text-right"
};
function _sfc_render$5(_ctx, _cache) {
  return openBlock(), createElementBlock(Fragment, null, [createBaseVNode("div", _hoisted_1$1, [createBaseVNode("div", _hoisted_2$1, [createBaseVNode("div", _hoisted_3$1, [renderSlot(_ctx.$slots, "1")]), createBaseVNode("div", _hoisted_4$1, [renderSlot(_ctx.$slots, "2")])]), createBaseVNode("div", _hoisted_5, [createBaseVNode("div", _hoisted_6, [renderSlot(_ctx.$slots, "3")]), createBaseVNode("div", _hoisted_7, [renderSlot(_ctx.$slots, "4")])])]), createBaseVNode("div", _hoisted_8, [createBaseVNode("div", _hoisted_9, [createBaseVNode("div", _hoisted_10, [createBaseVNode("div", _hoisted_11, [renderSlot(_ctx.$slots, "5")]), createBaseVNode("div", _hoisted_12, [renderSlot(_ctx.$slots, "6")])]), createBaseVNode("div", _hoisted_13, [createBaseVNode("div", _hoisted_14, [renderSlot(_ctx.$slots, "7")]), createBaseVNode("div", _hoisted_15, [renderSlot(_ctx.$slots, "8")]), createBaseVNode("div", _hoisted_16, [createBaseVNode("div", _hoisted_17, [renderSlot(_ctx.$slots, "9")])]), createBaseVNode("div", _hoisted_18, [createBaseVNode("div", _hoisted_19, [renderSlot(_ctx.$slots, "10")])])])])])], 64);
}
const SettingsLayout = /*#__PURE__*/_export_sfc(_sfc_main$5, [['render', _sfc_render$5]]);

const _sfc_main$4 = {
  props: ['value'],
  data() {
    return {};
  }
};
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createBlock(QInput, {
    style: {
      "width": "400px"
    },
    dense: "",
    "bottom-slots": "",
    outlined: "",
    "model-value": $props.value,
    onInput: _cache[0] || (_cache[0] = $event => _ctx.$emit('update:modelValue', $event.target.value))
  }, null, 8, ["model-value"]);
}
const InputField = /*#__PURE__*/_export_sfc(_sfc_main$4, [['render', _sfc_render$4]]);

const getTimeZoneList$1 = () => {
  var tzs = Intl.supportedValuesOf('timeZone');
  tzs.forEach((tz, idx) => {
    const myTimezoneName = tz;

    // Generating the formatted text
    // Setting the timeZoneName to longOffset will convert PDT to GMT-07:00
    const options = {
      timeZone: myTimezoneName,
      timeZoneName: "longOffset"
    };
    const dateText = Intl.DateTimeFormat([], options).format(new Date());

    // Scraping the numbers we want from the text
    // The default value '+0' is needed when the timezone is missing the number part. Ex. Africa/Bamako --> GMT
    let timezoneString = dateText.split(" ")[1].slice(3) || '+00:00';
    tzs[idx] = tzs[idx] + ' (UTC ' + timezoneString + ')';
  });
  return tzs;
};

const _sfc_main$3 = {
  props: ['value'],
  computed: {
    options() {
      return getTimeZoneList$1();
    }
  }
};
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createBlock(QSelect, {
    style: {
      "width": "400px"
    },
    dense: "",
    options: $options.options,
    outlined: "",
    "model-value": $props.value,
    onInput: _cache[0] || (_cache[0] = $event => _ctx.$emit('update:modelValue', $event.target.value))
  }, null, 8, ["options", "model-value"]);
}
const SelectField = /*#__PURE__*/_export_sfc(_sfc_main$3, [['render', _sfc_render$3]]);

const SettingsSaveButton_vue_vue_type_style_index_0_scoped_2d96b44b_lang = '';

const _sfc_main$2 = {
  props: ["username", "userid", "email", "timezone"],
  data() {
    return {};
  },
  methods: {
    onClickedUpdated() {
      const data = {
        "username": this.username,
        "email": this.email,
        "timezone": this.timezone
      };
      window.$http.post('/rest/v1/user/update-info', data).then(res => {
        this.$q.notify({
          color: "positive",
          message: "Changes saved successfully. You might need to refresh the page to take effect.",
          icon: "check"
        });
      }).catch(error => {
        if (error.response.status == 409) {
          this.$q.notify({
            color: "negative",
            message: "Email is already used.",
            icon: "close"
          });
        }
      });
    }
  }
};
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createElementBlock("div", null, [createVNode(QBtn, {
    flat: "",
    label: "Save",
    class: "save-btn",
    onClick: _cache[0] || (_cache[0] = $event => $options.onClickedUpdated())
  })]);
}
const SaveButton = /*#__PURE__*/_export_sfc(_sfc_main$2, [['render', _sfc_render$2], ['__scopeId', "data-v-2d96b44b"]]);

const _sfc_main$1 = {};
function _sfc_render$1(_ctx, _cache) {
  const _component_router_link = resolveComponent("router-link");
  return openBlock(), createBlock(_component_router_link, {
    to: "/user-settings/password",
    class: "text-grey-9"
  }, {
    default: withCtx(() => [createTextVNode(" Change password ")]),
    _: 1
  });
}
const ChangePasswordLink = /*#__PURE__*/_export_sfc(_sfc_main$1, [['render', _sfc_render$1]]);

const index_vue_vue_type_style_index_0_scoped_bf694bdc_lang = '';

const _sfc_main = {
  components: {
    SaveButton,
    ChangePasswordLink,
    InputField,
    SelectField,
    SettingsLayout
  },
  setup() {
    return {
      tab: ref('info')
    };
  },
  data() {
    return {
      userid: null,
      username: null,
      email: null,
      timezone: null
    };
  },
  methods: {
    getUserInfo() {
      window.$http.get('/rest/v1/user').then(res => {
        this.username = res.data.details.username;
        this.userid = res.data.details.userid;
        this.email = res.data.details.email;
        this.timezone = res.data.details.timezone;
      }).catch(error => {
        console.log("get_user_info", error);
      });
    }
  },
  computed: {
    options() {
      return getTimeZoneList();
    }
  },
  created() {
    this.getUserInfo();
  }
};
const _withScopeId = n => (pushScopeId("data-v-bf694bdc"), n = n(), popScopeId(), n);
const _hoisted_1 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/createBaseVNode("span", null, "ID *", -1));
const _hoisted_2 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/createBaseVNode("span", null, "Username *", -1));
const _hoisted_3 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/createBaseVNode("span", null, "Email *", -1));
const _hoisted_4 = /*#__PURE__*/_withScopeId(() => /*#__PURE__*/createBaseVNode("span", null, "Timezone *", -1));
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_input_field = resolveComponent("input-field");
  const _component_select_field = resolveComponent("select-field");
  const _component_change_password_link = resolveComponent("change-password-link");
  const _component_save_button = resolveComponent("save-button");
  const _component_settings_layout = resolveComponent("settings-layout");
  return openBlock(), createBlock(_component_settings_layout, null, {
    "1": withCtx(() => [_hoisted_1]),
    "2": withCtx(() => [createVNode(_component_input_field, {
      filled: "",
      readonly: "",
      modelValue: $data.userid,
      "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => $data.userid = $event)
    }, null, 8, ["modelValue"])]),
    "3": withCtx(() => [_hoisted_2]),
    "4": withCtx(() => [createVNode(_component_input_field, {
      modelValue: $data.username,
      "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => $data.username = $event)
    }, null, 8, ["modelValue"])]),
    "5": withCtx(() => [_hoisted_3]),
    "6": withCtx(() => [createVNode(_component_input_field, {
      modelValue: $data.email,
      "onUpdate:modelValue": _cache[2] || (_cache[2] = $event => $data.email = $event)
    }, null, 8, ["modelValue"])]),
    "7": withCtx(() => [_hoisted_4]),
    "8": withCtx(() => [createVNode(_component_select_field, {
      modelValue: $data.timezone,
      "onUpdate:modelValue": _cache[3] || (_cache[3] = $event => $data.timezone = $event)
    }, null, 8, ["modelValue"])]),
    "9": withCtx(() => [createVNode(_component_change_password_link)]),
    "10": withCtx(() => [createVNode(_component_save_button, {
      username: $data.username,
      userid: $data.userid,
      email: $data.email,
      timezone: $data.timezone
    }, null, 8, ["username", "userid", "email", "timezone"])]),
    _: 1
  });
}
const index = /*#__PURE__*/_export_sfc(_sfc_main, [['render', _sfc_render], ['__scopeId', "data-v-bf694bdc"]]);

export { index as default };
