import { resolveComponent as u, createBlock as d, openBlock as f, withCtx as c, createVNode as i } from "vue";
import { _ as h } from "./install-BuMO14Rb.js";
const s = Object.freeze({
  ONLINE: "online",
  PAUSE: "pause",
  OFFLINE: "offline",
  BREAK_OUT: "break_out"
}), _ = (t) => {
  if (!t) return "00:00:00";
  let e = `${Math.floor(t / 3600)}`, l = `${Math.floor(t % 3600 / 60)}`, a = `${Math.floor(t % 3600 % 60)}`;
  return e.length === 1 && (e = `0${e}`), l.length === 1 && (l = `0${l}`), a.length === 1 && (a = `0${a}`), `${e}:${l}:${a}`;
}, m = [
  {
    locale: "webitelUI.statusSelect.online",
    color: "success",
    value: s.ONLINE
  },
  {
    locale: "webitelUI.statusSelect.pause",
    color: "primary",
    value: s.PAUSE
  },
  {
    locale: "webitelUI.statusSelect.offline",
    color: "disabled",
    value: s.OFFLINE
  },
  {
    locale: "webitelUI.statusSelect.breakOut",
    color: "break-out",
    value: s.BREAK_OUT
  }
], O = {
  name: "WtStatusSelect",
  model: {
    prop: "status",
    event: "change"
  },
  /**
   * @emits {string} change - Fires when status changes. Emits changed status value
   * @emits {Event} closed - Fires when dropdown is closed
   */
  props: {
    /**
     * Component is looking for value from AgentStatus enum
     * @type {string}
     * @default AgentStatus.OFFLINE
     */
    status: {
      type: String,
      default: s.OFFLINE
    },
    /**
     * If seconds number, converts to hh:mm:ss format
     * @type {string | number}
     * @default 0
     */
    statusDuration: {
      type: [
        String,
        Number
      ],
      default: 0
    },
    /**
     * If passed, replaces default status-select options. Should have 3 required properties: "color", "text" and "value"
     * @type {Array}
     */
    options: {
      type: Array
    }
    // size: {
    //   type: String,
    //   default: 'md',
    //   options: ['sm', 'md'],
    // },
  },
  emits: [
    "change",
    "closed"
  ],
  computed: {
    selectedOption() {
      return this.statusOptions.find((t) => t.value === this.status);
    },
    statusOptions() {
      return this.options ? this.options : m.map((t) => ({
        ...t,
        text: this.$t(t.locale)
      }));
    },
    availableOptions() {
      return this.statusOptions.reduce((t, e) => (this.status === e.value && e.value !== s.PAUSE || e.value === s.BREAK_OUT || t.push(e), t), []);
    },
    duration() {
      return typeof this.statusDuration == "string" ? this.statusDuration : this.statusDuration !== void 0 ? _(this.statusDuration) : this.selectedOption.text;
    }
  },
  methods: {
    inputHandler(t) {
      this.$emit("change", t.value);
    },
    closedHandler(t) {
      this.$emit("closed", t);
    }
  }
};
function v(t, e, l, a, b, o) {
  const r = u("wt-indicator"), p = u("wt-select");
  return f(), d(p, {
    clearable: !1,
    options: o.availableOptions,
    searchable: !1,
    value: o.selectedOption,
    class: "wt-status-select",
    "track-by": "value",
    onClosed: o.closedHandler,
    onInput: o.inputHandler
  }, {
    singleLabel: c(({ option: n }) => [
      i(r, {
        color: n.color,
        text: o.duration
      }, null, 8, ["color", "text"])
    ]),
    option: c(({ option: n }) => [
      i(r, {
        color: n.color,
        text: n.text
      }, null, 8, ["color", "text"])
    ]),
    _: 1
  }, 8, ["options", "value", "onClosed", "onInput"]);
}
const g = /* @__PURE__ */ h(O, [["render", v], ["__scopeId", "data-v-580212cb"]]);
export {
  g as default
};
