import { X as x, Y as i, w as g, S as w, a3 as h, bH as v, bI as b, L as p, Z as I, az as V, N as P, U as B, F as n, af as r, a6 as a, G as l, a7 as u, a8 as m, bJ as S, a9 as E, bK as F, aa as M, ac as y, bL as N, bM as D, bN as L, bO as R, bP as T, ag as k } from "./603b75d9.js";
import { useContext as c } from "react";
import { ButtonStyleControl as H, ButtonCompWrapper as O, Button100 as U, buttonRefMethods as j } from "./26dac75c.js";
import "react-dom";
const z = x(T)`
  font-size: 13px;
  margin-right: 4px;
`, C = x.div`
  display: flex;
`;
function A(e) {
  return e.uiCompInfoList().filter((t) => t.type === "form").map((t) => ({
    label: t.name,
    value: t.name
  }));
}
function d(e, t) {
  const o = e == null ? void 0 : e.getUICompByName(t);
  if (o && o.children.compType.getView() === "form")
    return o.children.comp;
}
function W(e, t) {
  const o = d(e, t);
  if (o)
    return /* @__PURE__ */ n(k.Provider, {
      value: t,
      children: o.onEventPropertyView(/* @__PURE__ */ a(l, {
        children: [/* @__PURE__ */ n(z, {
          onClick: () => e.setSelectedCompNames(/* @__PURE__ */ new Set([t]), "rightPanel"),
          children: t
        }), i("button.formButtonEvent")]
      }))
    });
}
class $ extends D {
  getPropertyView() {
    const t = i("button.formToSubmit");
    return L({
      filterText: t
    }, /* @__PURE__ */ n(r.Consumer, {
      children: (o) => /* @__PURE__ */ a(l, {
        children: [/* @__PURE__ */ n(R, {
          label: t,
          value: this.value,
          options: A(o),
          onChange: (s) => this.dispatchChangeValueAction(s),
          allowClear: !0
        }), W(o, this.value)]
      })
    }));
  }
}
const G = [{
  label: i("button.default"),
  value: ""
}, {
  label: i("button.submit"),
  value: "submit"
}];
function f(e) {
  return !e;
}
function J(e, t) {
  const o = d(e, t);
  o && o.submit();
}
const K = function() {
  const e = {
    text: g(w, i("button.button")),
    type: h(G, ""),
    onEvent: v,
    disabled: b,
    loading: b,
    form: $,
    prefixIcon: p,
    suffixIcon: p,
    style: H,
    animationStyle: I(V, "animationStyle"),
    viewRef: P
  };
  return new B(e, (t) => /* @__PURE__ */ n(O, {
    $disabled: t.disabled,
    children: /* @__PURE__ */ n(r.Consumer, {
      children: (o) => {
        var s;
        return /* @__PURE__ */ a(U, {
          ref: t.viewRef,
          $buttonStyle: t.style,
          loading: t.loading,
          disabled: t.disabled || !f(t.type) && ((s = d(o, t.form)) == null ? void 0 : s.disableSubmit()),
          onClick: () => f(t.type) ? t.onEvent("click") : J(o, t.form),
          children: [
            t.prefixIcon && /* @__PURE__ */ n(C, {
              children: t.prefixIcon
            }),
            t.text || (t.prefixIcon || t.suffixIcon ? void 0 : " "),
            t.suffixIcon && /* @__PURE__ */ n(C, {
              children: t.suffixIcon
            })
          ]
        });
      }
    })
  })).setPropertyViewFn((t) => /* @__PURE__ */ a(l, {
    children: [/* @__PURE__ */ n(u, {
      name: m.basic,
      children: t.text.propertyView({
        label: i("text")
      })
    }), (c(r).editorModeStatus === "logic" || c(r).editorModeStatus === "both") && /* @__PURE__ */ n(l, {
      children: /* @__PURE__ */ a(u, {
        name: m.interaction,
        children: [t.type.propertyView({
          label: i("prop.type"),
          radioButton: !0
        }), f(t.type.getView()) ? [t.onEvent.getPropertyView(), S(t), E(t), F(t)] : t.form.getPropertyView()]
      })
    }), (c(r).editorModeStatus === "layout" || c(r).editorModeStatus === "both") && /* @__PURE__ */ a(l, {
      children: [/* @__PURE__ */ a(u, {
        name: m.layout,
        children: [t.prefixIcon.propertyView({
          label: i("button.prefixIcon")
        }), t.suffixIcon.propertyView({
          label: i("button.suffixIcon")
        })]
      }), /* @__PURE__ */ n(u, {
        name: m.style,
        children: t.style.getPropertyView()
      })]
    })]
  })).setExposeMethodConfigs(j).build();
}(), Q = M(K, [new y("text", i("button.textDesc")), new y("loading", i("button.loadingDesc")), ...N]);
export {
  Q as ButtonComp
};
