import { X as $, w as C, Y as b, S as p, O as B, a5 as D, bI as M, bH as v, Z as E, bQ as V, U as k, F as a, ah as I, a6 as i, G as y, a7 as l, a8 as d, af as r, bJ as R, a9 as F, aa as P, ac as W, bL as H, al as N, bR as j } from "./603b75d9.js";
import h, { useContext as s } from "react";
import { getButtonStyle as w, ButtonCompWrapper as z, Button100 as L } from "./26dac75c.js";
import "react-dom";
const O = $(j)`
  width: 100%;
  
  .ant-btn-group {
    width: 100%;
   
  }
`, T = $.div`
  width: calc(100%);
  ${(t) => `margin: ${t.$buttonStyle.margin};`}
  margin-right: 0;
  .ant-btn span {
    ${(t) => t.$buttonStyle.textDecoration !== void 0 ? `text-decoration: ${t.$buttonStyle.textDecoration};` : ""}
    ${(t) => t.$buttonStyle.fontFamily !== void 0 ? `font-family: ${t.$buttonStyle.fontFamily};` : ""}
  }
  
  .ant-btn {
    ${(t) => w(t.$buttonStyle)}
    margin: 0 !important;
    height: 100%;
    &.ant-btn-default {
      margin: 0 !important;

      ${(t) => `border-radius: ${t.$buttonStyle.radius} 0 0 ${t.$buttonStyle.radius};`}
      ${(t) => `text-transform: ${t.$buttonStyle.textTransform};`}
      ${(t) => `font-weight: ${t.$buttonStyle.textWeight};`}
    }
    ${(t) => `background: ${t.$buttonStyle.background};`}
    ${(t) => `color: ${t.$buttonStyle.text};`}
    ${(t) => `padding: ${t.$buttonStyle.padding};`}
    ${(t) => `font-size: ${t.$buttonStyle.textSize};`}
    ${(t) => `font-style: ${t.$buttonStyle.fontStyle};`}

    width: 100%;
    line-height:${(t) => t.$buttonStyle.lineHeight}; 
  }
  
`, U = $.div`
  // width: 32px;
  ${(t) => `margin: ${t.$buttonStyle.margin};`}
  margin-left: -1px;
  .ant-btn {
    ${(t) => w(t.$buttonStyle)}
    margin: 0 !important;
    height: 100%;
    &.ant-btn-default {
      margin: 0 !important;
      ${(t) => `border-radius: 0 ${t.$buttonStyle.radius} ${t.$buttonStyle.radius} 0;`}
    }
    width: 100%;
  }
`, _ = function() {
  const t = {
    text: C(p, b("menu")),
    onlyMenu: B,
    options: D,
    disabled: M,
    onEvent: v,
    style: E(V, "style")
  };
  return new k(t, (e) => {
    var g;
    const f = e.options.findIndex((n) => {
      var o;
      return (o = n.prefixIcon) == null ? void 0 : o.props.value;
    }) > -1, c = e.options.filter((n) => !n.hidden).map((n, o) => ({
      title: n.label,
      label: n.label,
      style: {
        padding: e.style.padding
      },
      key: n.label + " - " + o,
      disabled: n.disabled,
      icon: f && /* @__PURE__ */ a("span", {
        children: n.prefixIcon
      }),
      index: o
    })), m = /* @__PURE__ */ a(N, {
      items: c,
      onClick: ({
        key: n
      }) => {
        var S;
        const o = c.find((u) => u.key === n), x = e.options.findIndex((u) => u.label === (o == null ? void 0 : o.label));
        o && ((S = e.options[x]) == null || S.onEvent("click"));
      }
    });
    return /* @__PURE__ */ a(z, {
      $disabled: e.disabled,
      children: e.onlyMenu ? /* @__PURE__ */ a(I, {
        disabled: e.disabled,
        dropdownRender: () => m,
        children: /* @__PURE__ */ a(L, {
          $buttonStyle: e.style,
          disabled: e.disabled,
          children: e.text || " "
          /* Avoid button disappearing */
        })
      }) : /* @__PURE__ */ a(O, {
        disabled: e.disabled,
        dropdownRender: () => m,
        onClick: () => e.onEvent("click"),
        buttonsRender: ([n, o]) => [/* @__PURE__ */ a(T, {
          $buttonStyle: e.style,
          children: h.cloneElement(n, {
            disabled: e.disabled
          })
        }), /* @__PURE__ */ a(U, {
          $buttonStyle: e.style,
          children: h.cloneElement(o, {
            disabled: e.disabled
          })
        })],
        children: !e.text || ((g = e.text) == null ? void 0 : g.length) === 0 ? " " : e.text
      })
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ i(y, {
    children: [/* @__PURE__ */ a(l, {
      name: d.basic,
      children: e.options.propertyView({})
    }), (s(r).editorModeStatus === "logic" || s(r).editorModeStatus === "both") && /* @__PURE__ */ a(y, {
      children: /* @__PURE__ */ i(l, {
        name: d.interaction,
        children: [!e.onlyMenu.getView() && e.onEvent.getPropertyView(), R(e), F(e)]
      })
    }), (s(r).editorModeStatus === "layout" || s(r).editorModeStatus === "both") && /* @__PURE__ */ i(y, {
      children: [/* @__PURE__ */ i(l, {
        name: d.layout,
        children: [e.text.propertyView({
          label: b("label")
        }), e.onlyMenu.propertyView({
          label: b("dropdown.onlyMenu")
        })]
      }), /* @__PURE__ */ a(l, {
        name: d.style,
        children: e.style.getPropertyView()
      })]
    })]
  })).build();
}(), Y = P(_, [new W("text", b("dropdown.textDesc")), ...H]);
export {
  Y as DropdownComp
};
