import { b9 as C, co as P, ca as E, cb as I, a0 as r, U as z, V as a, bg as s, cy as F, P as l, bh as b, bi as d, bj as m, bk as D, bl as M, bm as N, bn as T, bo as j, bp as k, bq as W, w as f, ba as R, bb as L, cv as U, bc as A, bd as V, be as O, bf as q, br as G, bs as J, bt as K, bu as Q } from "./684d2f28.js";
import { useState as $, useRef as S, useEffect as X, useContext as h } from "react";
import { Button100 as Y, ButtonStyleControl as Z } from "./9f282d74.js";
import "react-dom";
import "./d6402597.js";
const _ = C.div`
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  ${(t) => t.$style && tt(t.$style)}
`, tt = (t) => P`
    button {
      border: 1px solid ${t.border};
      border-radius: ${t.radius};
      margin: ${t.margin};
      padding: ${t.padding};
      max-width: ${E(t.margin)};
      max-height: ${I(t.margin)};
    }
  `, et = C(W)`
  font-size: 13px;
  margin-right: 4px;
`, nt = C.div`
  display: flex;

  ${(t) => t.$style && it(t.$style)}
`;
function it(t) {
  return P`
    svg {
      width: ${t.size} !important;
      height: ${t.size} !important;
    }
  `;
}
function ot(t) {
  return t.uiCompInfoList().filter((e) => e.type === "form").map((e) => ({
    label: e.name,
    value: e.name
  }));
}
function w(t, e) {
  const n = t == null ? void 0 : t.getUICompByName(e);
  if (n && n.children.compType.getView() === "form")
    return n.children.comp;
}
function at(t, e) {
  const n = w(t, e);
  if (n)
    return /* @__PURE__ */ a(Q.Provider, {
      value: e,
      children: n.onEventPropertyView(/* @__PURE__ */ l(b, {
        children: [/* @__PURE__ */ a(et, {
          onClick: () => t.setSelectedCompNames(/* @__PURE__ */ new Set([e]), "rightPanel"),
          children: e
        }), r("button.formButtonEvent")]
      }))
    });
}
class rt extends G {
  getPropertyView() {
    const e = r("button.formToSubmit");
    return J({
      filterText: e
    }, /* @__PURE__ */ a(s.Consumer, {
      children: (n) => /* @__PURE__ */ l(b, {
        children: [/* @__PURE__ */ a(K, {
          label: e,
          value: this.value,
          options: ot(n),
          onChange: (u) => this.dispatchChangeValueAction(u),
          allowClear: !0
        }), at(n, this.value)]
      })
    }));
  }
}
const lt = [{
  label: r("button.default"),
  value: ""
}, {
  label: r("button.submit"),
  value: "submit"
}];
function H(t) {
  return !t;
}
function st(t, e) {
  const n = w(t, e);
  n && n.submit();
}
const ct = {
  iconSize: f(R, "20px"),
  type: L(lt, ""),
  autoHeight: f(U, "fixed"),
  aspectRatio: f(R, "1 / 1"),
  onEvent: A,
  disabled: V,
  loading: V,
  form: rt,
  prefixIcon: O,
  style: Z,
  viewRef: q
};
let y = function() {
  return new z(ct, (t) => {
    const [e, n] = $(120), [u, ut] = $(0), g = S(null), p = S(null);
    X(() => {
      u && e && v();
    }, [u, e]);
    const B = (i, o) => {
      const c = g.current, x = c == null ? void 0 : c.getElementsByTagName("button")[0];
      c.style.height = i, c.style.width = o, x.style.height = i, x.style.width = o;
    }, v = () => {
      const i = g.current, o = p.current;
      !(i != null && i.clientWidth) || !(i != null && i.clientHeight) || t.autoHeight || !e || B((o == null ? void 0 : o.clientHeight) + "px", (o == null ? void 0 : o.clientWidth) + "px");
    };
    return /* @__PURE__ */ a(s.Consumer, {
      children: (i) => {
        var o;
        return /* @__PURE__ */ a(F, {
          onResize: v,
          children: /* @__PURE__ */ a(_, {
            ref: p,
            $style: t.style,
            children: /* @__PURE__ */ a("div", {
              ref: g,
              style: t.autoHeight ? {
                width: "100%",
                height: "100%"
              } : void 0,
              children: /* @__PURE__ */ a(Y, {
                ref: t.viewRef,
                $buttonStyle: t.style,
                loading: t.loading,
                style: t.autoHeight ? {
                  width: "100%",
                  height: "100%",
                  aspectRatio: t.aspectRatio,
                  borderRadius: t.style.radius
                } : {
                  aspectRatio: t.aspectRatio,
                  borderRadius: t.style.radius
                },
                disabled: t.disabled || !H(t.type) && ((o = w(i, t.form)) == null ? void 0 : o.disableSubmit()),
                onClick: () => H(t.type) ? t.onEvent("click") : st(i, t.form),
                children: t.prefixIcon && /* @__PURE__ */ a(nt, {
                  $style: {
                    ...t.style,
                    size: t.iconSize
                  },
                  children: t.prefixIcon
                })
              })
            })
          })
        });
      }
    });
  }).setPropertyViewFn((t) => /* @__PURE__ */ l(b, {
    children: [/* @__PURE__ */ a(d, {
      name: m.basic,
      children: t.prefixIcon.propertyView({
        label: r("button.icon")
      })
    }), (h(s).editorModeStatus === "logic" || h(s).editorModeStatus === "both") && /* @__PURE__ */ l(d, {
      name: m.interaction,
      children: [t.onEvent.getPropertyView(), D(t), M(t), N(t)]
    }), (h(s).editorModeStatus === "layout" || h(s).editorModeStatus === "both") && /* @__PURE__ */ l(b, {
      children: [/* @__PURE__ */ l(d, {
        name: m.layout,
        children: [t.autoHeight.getPropertyView(), t.iconSize.propertyView({
          label: r("button.iconSize")
        })]
      }), /* @__PURE__ */ l(d, {
        name: m.style,
        children: [t.style.getPropertyView(), t.aspectRatio.propertyView({
          label: r("style.aspectRatio")
        })]
      })]
    })]
  })).build();
}();
y = class extends y {
  autoHeight() {
    return this.children.autoHeight.getView();
  }
};
const ft = T(y, [new j("loading", r("button.loadingDesc")), ...k]);
export {
  ft as ControlButton
};
