import '@das-fed/ui/packages/components/dropdown/style.css';
import { withInstall as u } from "@das-fed/utils/with-install/index";
import { setI18nRule as C, t as E } from "@das-fed/web/packages/i18n/index";
import { setThemeRule as k } from "@das-fed/web/packages/theme/index";
import "@das-fed/ui/packages/global/theme";
import { defineComponent as m, createBlock as v, openBlock as c, unref as t, mergeProps as h, withCtx as s, renderSlot as p, normalizeProps as F, guardReactiveProps as y, useAttrs as B, ref as n, watch as I, onMounted as M, createElementBlock as P, createVNode as R } from "vue";
import "element-plus/es/components/dropdown-item/style/css";
import { ElDropdownItem as A, ElDropdownMenu as b, ElDropdown as x } from "element-plus";
import "element-plus/es/components/dropdown-menu/style/css";
import "element-plus/es/components/dropdown/style/css";
const z = {
  "--das-ui-dropdown-bgff-color": "#fff",
  "--das-ui-dropdown-divided-color": "#e5e5e5",
  "--das-ui-dropdown-active-color": "#5582F3",
  "--das-ui-dropdown-hover-color": "#F5F5F5"
}, L = /* @__PURE__ */ m({
  __name: "dropdownItem",
  props: {
    danger: { type: Boolean, default: !1 }
  },
  setup(d) {
    return (o, a) => (c(), v(t(A), h(o.$attrs, {
      class: { danger: o.danger }
    }), {
      default: s(() => [
        p(o.$slots, "default")
      ]),
      _: 3
      /* FORWARDED */
    }, 16, ["class"]));
  }
}), N = /* @__PURE__ */ m({
  __name: "dropdownMenu",
  setup(d) {
    return (o, a) => (c(), v(
      t(b),
      F(y(o.$attrs)),
      {
        default: s(() => [
          p(o.$slots, "default")
        ]),
        _: 3
        /* FORWARDED */
      },
      16
      /* FULL_PROPS */
    ));
  }
}), O = /* @__PURE__ */ m({
  __name: "index",
  props: {
    selfPopperClass: { default: "" },
    visibleArrow: { type: Boolean, default: !1 }
  },
  setup(d, { expose: o }) {
    const a = B(), w = n(null), r = n(null);
    let D = d, _ = n("hidden-arrow"), l = n({
      modifiers: [
        {
          name: "offset",
          options: {
            offset: [10, 10]
          }
        }
      ]
    });
    I(
      () => D.visibleArrow,
      (e, f) => {
        _.value = e ? "" : "hidden-arrow", l.value = {
          modifiers: [
            {
              name: "offset",
              options: {
                offset: e ? [10, 10] : [4, 4]
              }
            }
          ]
        };
      },
      { immediate: !0 }
    ), M(() => {
      if (a.trigger == "contextmenu") {
        const e = w.value;
        e == null || e.addEventListener("contextmenu", $), e == null || e.addEventListener("mousedown", g);
      }
    });
    function $(e) {
      const f = e.offsetX;
      let i = e.offsetY;
      i = 100 - i, l.value = {
        modifiers: [
          {
            name: "offset",
            options: {
              // offset:[x.value,y.value], x正数，y负数
              offset: [f, -i]
            }
          }
        ]
      }, r.value.handleOpen();
    }
    function g(e) {
      r.value.handleClose();
    }
    return o({
      getElRef: () => r.value
    }), (e, f) => (c(), P(
      "div",
      {
        class: "das-ui-dropdown",
        ref_key: "_selfDropdown",
        ref: w
      },
      [
        R(t(x), h(e.$attrs, {
          "popper-class": `das-ui-dropdown-popper ${e.selfPopperClass} ${t(_)}`,
          "popper-options": t(l),
          ref_key: "_selfElDropdown",
          ref: r
        }), {
          dropdown: s(() => [
            p(e.$slots, "default")
          ]),
          default: s(() => [
            p(e.$slots, "content")
          ]),
          _: 3
          /* FORWARDED */
        }, 16, ["popper-class", "popper-options"])
      ],
      512
      /* NEED_PATCH */
    ));
  }
}), S = { 下拉菜单: { "zh-CN": "下拉菜单", en: "Dropdown Menu", _appCode: "framework" } };
C(S);
k(z);
const Q = u(L), U = u(N), W = u(O), Z = { name: `Dropdown ${E("下拉菜单")}` };
export {
  W as DasDropdown,
  Q as DasDropdownItem,
  U as DasDropdownMenu,
  Z as default
};
