import { b9 as x, a0 as i, w as g, ba as w, bb as h, bc as v, bd as f, be as p, bf as I, U as V, V as n, bg as a, P as r, bh as l, bi as u, bj as b, bk as P, bl as B, bm as E, bn as F, bo as C, bp as M, bq as S, br as D, bs as k, bt as N, bu as R } from "./684d2f28.js";
import { useContext as m } from "react";
import { ButtonStyleControl as T, ButtonCompWrapper as j, Button100 as L, buttonRefMethods as U } from "./926d8ea1.js";
import "react-dom";
import "./d6402597.js";
const H = x(S)`
  font-size: 13px;
  margin-right: 4px;
`, y = x.div`
  display: flex;
`;
function O(t) {
  return t.uiCompInfoList().filter((e) => e.type === "form").map((e) => ({
    label: e.name,
    value: e.name
  }));
}
function d(t, e) {
  const o = t == null ? void 0 : t.getUICompByName(e);
  if (o && o.children.compType.getView() === "form")
    return o.children.comp;
}
function W(t, e) {
  const o = d(t, e);
  if (o)
    return /* @__PURE__ */ n(R.Provider, {
      value: e,
      children: o.onEventPropertyView(/* @__PURE__ */ r(l, {
        children: [/* @__PURE__ */ n(H, {
          onClick: () => t.setSelectedCompNames(/* @__PURE__ */ new Set([e]), "rightPanel"),
          children: e
        }), i("button.formButtonEvent")]
      }))
    });
}
class q extends D {
  getPropertyView() {
    const e = i("button.formToSubmit");
    return k({
      filterText: e
    }, /* @__PURE__ */ n(a.Consumer, {
      children: (o) => /* @__PURE__ */ r(l, {
        children: [/* @__PURE__ */ n(N, {
          label: e,
          value: this.value,
          options: O(o),
          onChange: (s) => this.dispatchChangeValueAction(s),
          allowClear: !0
        }), W(o, this.value)]
      })
    }));
  }
}
const z = [{
  label: i("button.default"),
  value: ""
}, {
  label: i("button.submit"),
  value: "submit"
}];
function c(t) {
  return !t;
}
function A(t, e) {
  const o = d(t, e);
  o && o.submit();
}
const $ = function() {
  const t = {
    text: g(w, i("button.button")),
    type: h(z, ""),
    onEvent: v,
    disabled: f,
    loading: f,
    form: q,
    prefixIcon: p,
    suffixIcon: p,
    style: T,
    viewRef: I
  };
  return new V(t, (e) => /* @__PURE__ */ n(j, {
    disabled: e.disabled,
    children: /* @__PURE__ */ n(a.Consumer, {
      children: (o) => {
        var s;
        return /* @__PURE__ */ r(L, {
          ref: e.viewRef,
          $buttonStyle: e.style,
          loading: e.loading,
          disabled: e.disabled || !c(e.type) && ((s = d(o, e.form)) == null ? void 0 : s.disableSubmit()),
          onClick: () => c(e.type) ? e.onEvent("click") : A(o, e.form),
          children: [
            e.prefixIcon && /* @__PURE__ */ n(y, {
              children: e.prefixIcon
            }),
            e.text || (e.prefixIcon || e.suffixIcon ? void 0 : " "),
            e.suffixIcon && /* @__PURE__ */ n(y, {
              children: e.suffixIcon
            })
          ]
        });
      }
    })
  })).setPropertyViewFn((e) => /* @__PURE__ */ r(l, {
    children: [/* @__PURE__ */ n(u, {
      name: b.basic,
      children: e.text.propertyView({
        label: i("text")
      })
    }), (m(a).editorModeStatus === "logic" || m(a).editorModeStatus === "both") && /* @__PURE__ */ n(l, {
      children: /* @__PURE__ */ r(u, {
        name: b.interaction,
        children: [e.type.propertyView({
          label: i("prop.type"),
          radioButton: !0
        }), c(e.type.getView()) ? [e.onEvent.getPropertyView(), P(e), B(e), E(e)] : e.form.getPropertyView()]
      })
    }), (m(a).editorModeStatus === "layout" || m(a).editorModeStatus === "both") && /* @__PURE__ */ r(l, {
      children: [/* @__PURE__ */ r(u, {
        name: b.layout,
        children: [e.prefixIcon.propertyView({
          label: i("button.prefixIcon")
        }), e.suffixIcon.propertyView({
          label: i("button.suffixIcon")
        })]
      }), /* @__PURE__ */ n(u, {
        name: b.style,
        children: e.style.getPropertyView()
      })]
    })]
  })).setExposeMethodConfigs(U).build();
}(), Y = F($, [new C("text", i("button.textDesc")), new C("loading", i("button.loadingDesc")), ...M]);
export {
  Y as ButtonComp
};
