import { DEFAULT_FEED_ROW_STATE as c, FEED_ROW_STATE_BACKGROUND_COLOR as _ } from "./feed-item-row-constants.js";
import k from "../../common/mixins/modal.js";
import { DtIconUser as C } from "@dialpad/dialtone-icons/vue3";
import { hasSlotContent as D } from "../../common/utils/index.js";
import { resolveComponent as r, createBlock as h, openBlock as a, mergeProps as T, toHandlers as b, withCtx as n, createElementVNode as d, createElementBlock as o, createCommentVNode as i, renderSlot as s, toDisplayString as l, withDirectives as u, createVNode as f, vShow as p, createSlots as E } from "vue";
import { _ as F } from "../../_plugin-vue_export-helper-CHgC5LLL.js";
import I from "../badge/badge.js";
import B from "../list-item/list-item.js";
import H from "../lazy-show/lazy-show.js";
import N from "../avatar/avatar.js";
const q = {
  compatConfig: { MODE: 3 },
  name: "DtRecipeFeedItemRow",
  components: {
    DtAvatar: N,
    DtLazyShow: H,
    DtListItem: B,
    DtBadge: I,
    DtIconUser: C
  },
  mixins: [k],
  inheritAttrs: !1,
  props: {
    /**
     * Avatar seed, set this to the user's ID to get the same avatar background gradient each time it is displayed.
     */
    avatarSeed: {
      type: String,
      default: null
    },
    /**
     * Show avatar, show header text or dont show left time and vice versa
     */
    showHeader: {
      type: Boolean,
      default: !1
    },
    /**
     * Optional avatar image url.
     * If not provided it will use extracted initials from displayName.
     */
    avatarImageUrl: {
      type: String,
      default: ""
    },
    /**
     * The display name of the sender
     */
    displayName: {
      type: String,
      default: ""
    },
    /**
     * Initials will never be shown. Instead it will show a "User" icon.
     */
    noInitials: {
      type: Boolean,
      default: !1
    },
    /**
     * time string displayed as is.
     * Shown on the header when showHeader is true
     */
    time: {
      type: String,
      default: ""
    },
    /**
     * short time string without AM/PM displayed as is.
     * Shown on the left of feed item when showHeader is false and isActive is true
     */
    shortTime: {
      type: String,
      default: ""
    },
    /**
     * A label displayed next to the displayName. Will not show if empty.
     */
    labelText: {
      type: String,
      default: ""
    },
    /**
     * displays a darkened background on the row.
     */
    isActive: {
      type: Boolean,
      default: !1
    },
    /**
     * state for the feed item row. Can be normal, searched & error
     */
    state: {
      type: String,
      default: c,
      validator: (e) => Object.keys(_).includes(e)
    }
  },
  emits: [
    /**
     * Fires when hovered over feed row
     *
     * @event hover
     * @type {Boolean}
     */
    "hover",
    /**
     * Fires when focused over feed row
     *
     * @event focus
     * @type {Boolean}
     */
    "focus",
    /**
     * Key down event
     *
     * @event keydown
     * @type {KeyboardEvent}
     */
    "keydown"
  ],
  data() {
    return {
      transitionActive: !1
    };
  },
  computed: {
    feedListeners() {
      return {
        mouseenter: () => this.setHover(!0),
        mouseleave: () => this.setHover(!1),
        focusin: () => this.setFocus(!0),
        focusout: () => this.setFocus(!1),
        transitionend: () => this.transitionComplete(),
        keydown: (e) => {
          switch (e.code) {
            case "Tab":
              this.trapFocus(e);
              break;
          }
          this.$emit("keydown", e);
        }
      };
    },
    listItemClasses() {
      return [
        "d-recipe-feed-item-row",
        { "d-recipe-feed-item-row--active": this.isActive && this.state === c },
        { "d-recipe-feed-item-row__state-transition": this.transitionActive },
        _[this.state]
      ];
    },
    hasAttachmentContent() {
      return D(this.$slots.attachment);
    }
  },
  watch: {
    state: {
      immediate: !0,
      handler: function(e) {
        e !== c && (this.transitionActive = !0);
      }
    }
  },
  methods: {
    transitionComplete() {
      this.state === c && (this.transitionActive = !1);
    },
    trapFocus(e) {
      this.focusTrappedTabPress(e);
    },
    setFocus(e) {
      this.$emit("focus", e);
    },
    setHover(e) {
      this.$emit("hover", e);
    }
  }
}, O = {
  key: 0,
  class: "d-recipe-feed-item-row__avatar-container"
}, R = { class: "d-recipe-feed-item-row__content" }, L = {
  key: 0,
  "data-qa": "dt-recipe-feed-item-row--header",
  class: "d-recipe-feed-item-row__header"
}, z = { class: "d-recipe-feed-item-row__header-name" }, U = { class: "d-recipe-feed-item-row__header-time" }, V = { "data-qa": "dt-recipe-feed-item-row--content" }, M = {
  key: 1,
  "data-qa": "dt-recipe-feed-item-row--attachment",
  class: "d-recipe-feed-item-row__attachment"
}, P = {
  key: 0,
  class: "d-recipe-feed-item-row__reactions",
  "data-qa": "dt-recipe-feed-item-row--reactions"
}, W = {
  key: 1,
  class: "d-recipe-feed-item-row__threading"
}, j = {
  "data-qa": "dt-recipe-feed-item-row--menu",
  class: "d-recipe-feed-item-row__menu"
};
function G(e, K, t, x, J, m) {
  const w = r("dt-icon-user"), v = r("dt-avatar"), y = r("dt-badge"), g = r("dt-lazy-show"), A = r("dt-list-item");
  return a(), h(A, T({
    ref: "FeedItemRef",
    "navigation-type": "none"
  }, e.$attrs, {
    class: m.listItemClasses,
    "data-qa": "dt-recipe-feed-item-row"
  }, b(m.feedListeners)), {
    left: n(() => [
      t.showHeader ? (a(), o("div", O, [
        s(e.$slots, "avatar", {}, () => [
          f(v, {
            "full-name": t.displayName,
            "image-src": t.avatarImageUrl,
            "image-alt": "",
            seed: t.avatarSeed
          }, E({ _: 2 }, [
            t.noInitials ? {
              name: "icon",
              fn: n(({ iconSize: S }) => [
                f(w, { size: S }, null, 8, ["size"])
              ]),
              key: "0"
            } : void 0
          ]), 1032, ["full-name", "image-src", "seed"])
        ])
      ])) : i("", !0),
      t.showHeader ? i("", !0) : u((a(), o("span", {
        key: 1,
        class: "d-recipe-feed-item-row__left-time",
        "data-qa": "dt-recipe-feed-item-row--left-time"
      }, l(t.shortTime), 513)), [
        [p, t.isActive]
      ])
    ]),
    bottom: n(() => [
      e.$slots.reactions ? (a(), o("div", P, [
        s(e.$slots, "reactions")
      ])) : i("", !0),
      e.$slots.threading ? (a(), o("div", W, [
        s(e.$slots, "threading")
      ])) : i("", !0),
      u(d("div", j, [
        f(g, {
          appear: !0,
          transition: "fade",
          show: t.isActive
        }, {
          default: n(() => [
            s(e.$slots, "menu")
          ]),
          _: 3
        }, 8, ["show"])
      ], 512), [
        [p, t.isActive]
      ])
    ]),
    default: n(() => [
      d("article", R, [
        t.showHeader ? (a(), o("div", L, [
          s(e.$slots, "displayName", {}, () => [
            d("p", z, l(t.displayName), 1)
          ]),
          d("time", U, l(t.time), 1),
          t.labelText ? (a(), h(y, {
            key: 0,
            text: t.labelText
          }, null, 8, ["text"])) : i("", !0)
        ])) : i("", !0),
        d("span", V, [
          s(e.$slots, "default")
        ]),
        m.hasAttachmentContent ? (a(), o("div", M, [
          s(e.$slots, "attachment")
        ])) : i("", !0)
      ])
    ]),
    _: 3
  }, 16, ["class"]);
}
const oe = /* @__PURE__ */ F(q, [["render", G]]);
export {
  oe as default
};
//# sourceMappingURL=feed-item-row.js.map
