import { F as n } from "./floating-ui-5c56eab3.mjs";
class l extends n {
  constructor() {
    super(), this.handleBlur = () => {
      this.hasTrigger("focus") && this.hide();
    }, this.handleFocus = () => {
      this.hasTrigger("focus") && this.show();
    }, this.handleClick = () => {
      this.hasTrigger("click") && (this.isOpen() ? this.hide() : this.show());
    }, this.handleMouseOver = () => {
      this.hasTrigger("hover") && (clearTimeout(this.hoverTimeout), this.hoverTimeout = window.setTimeout(() => this.show(), this.options.showDelay));
    }, this.handleMouseOut = () => {
      this.hasTrigger("hover") && (clearTimeout(this.hoverTimeout), this.hoverTimeout = window.setTimeout(() => this.hide(), this.options.hideDelay));
    }, this.handleClickOutside = (t) => {
      this.hasTrigger("click") && this.isOpen() && (this != null && this.contains(t.target) || this.hide());
    };
  }
  setTarget(t) {
    this.options.target = t;
  }
  getTarget() {
    return this.options.target;
  }
  setContent(t) {
    this.options.content = t;
  }
  handleSlotChange({ target: t }) {
    const e = t == null ? void 0 : t.assignedElements({ flatten: !0 })[0], i = t == null ? void 0 : t.nextElementSibling;
    !e || !i || (this.setTarget(e), this.setContent(i), this.listener());
  }
  hasTrigger(t) {
    return this.trigger.split(" ").includes(t);
  }
  listener() {
    var t, e, i, s, h;
    (t = this.getTarget()) == null || t.addEventListener("blur", this.handleBlur, !0), (e = this.getTarget()) == null || e.addEventListener("focus", this.handleFocus, !0), (i = this.getTarget()) == null || i.addEventListener("click", this.handleClick), (s = this.getTarget()) == null || s.addEventListener("mouseover", this.handleMouseOver), (h = this.getTarget()) == null || h.addEventListener("mouseout", this.handleMouseOut), document.addEventListener("click", this.handleClickOutside);
  }
}
export {
  l as F
};
