import { cJ as m, w as h, P as w, O as C, bI as v, a2 as V, Z as r, c2 as x, az as p, c3 as F, bS as P, cN as E, U as k, F as a, a6 as i, G as u, a7 as l, a8 as n, Y as o, af as c, bJ as R, a9 as $, aa as H, ac as f, bL as O, X as M, ad as N, av as B, cn as I, cO as L } from "./603b75d9.js";
import { useRef as j, useEffect as b, useContext as d } from "react";
import { formDataChildren as D, FormDataPropertyView as J } from "./f9847c56.js";
import "react-dom";
const U = [I];
function z(t) {
  return t && t.hasOwnProperty("unChecked") ? {
    label: t.label,
    checked: t.checked,
    unchecked: t.unChecked
  } : t;
}
const A = function() {
  const t = {
    defaultValue: m("defaultValue"),
    value: m("value"),
    max: h(N, "5"),
    label: w,
    allowHalf: C,
    disabled: v,
    onEvent: V(U),
    style: r(x, "style"),
    animationStyle: r(p, "animationStyle"),
    labelStyle: r(F.filter((e) => ["accent", "validate"].includes(e.name) === !1), "labelStyle"),
    inputFieldStyle: P(r(E, "inputFieldStyle"), z),
    ...D
  };
  return new k(t, (e) => {
    const y = {
      ...e.defaultValue
    }.value, S = {
      ...e.value
    }.value, s = j(!1);
    return b(() => {
      e.value.onChange(y);
    }, [y]), b(() => {
      s.current && (e.onEvent("change"), s.current = !1);
    }, [S]), e.label({
      style: e.style,
      labelStyle: e.labelStyle,
      inputFieldStyle: e.inputFieldStyle,
      animationStyle: e.animationStyle,
      children: /* @__PURE__ */ a(T, {
        count: e.max,
        value: e.value.value,
        onChange: (g) => {
          e.value.onChange(g), s.current = !0;
        },
        allowHalf: e.allowHalf,
        disabled: e.disabled,
        $style: e.inputFieldStyle
      })
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ i(u, {
    children: [/* @__PURE__ */ i(l, {
      name: n.basic,
      children: [e.defaultValue.propertyView({
        label: o("prop.defaultValue")
      }), e.max.propertyView({
        label: o("rating.max")
      })]
    }), /* @__PURE__ */ a(J, {
      ...e
    }), ["logic", "both"].includes(d(c).editorModeStatus) && /* @__PURE__ */ i(u, {
      children: [/* @__PURE__ */ i(l, {
        name: n.interaction,
        children: [e.onEvent.getPropertyView(), R(e), $(e)]
      }), /* @__PURE__ */ a(l, {
        name: n.advanced,
        children: e.allowHalf.propertyView({
          label: o("rating.allowHalf")
        })
      })]
    }), ["layout", "both"].includes(d(c).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(d(c).editorModeStatus) && /* @__PURE__ */ i(u, {
      children: [/* @__PURE__ */ a(l, {
        name: n.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ a(l, {
        name: n.labelStyle,
        children: e.labelStyle.getPropertyView()
      }), /* @__PURE__ */ a(l, {
        name: n.inputFieldStyle,
        children: e.inputFieldStyle.getPropertyView()
      }), /* @__PURE__ */ a(l, {
        name: n.animationStyle,
        hasTooltip: !0,
        children: e.animationStyle.getPropertyView()
      })]
    })]
  })).build();
}(), K = H(A, [new f("value", o("export.ratingValueDesc")), new f("max", o("export.ratingMaxDesc")), ...O]), G = (t) => B`
    .ant-rate {
      color: ${t.checked};
    }

    .ant-rate-star-half .ant-rate-star-first,
    .ant-rate-star-full .ant-rate-star-second {
      color: ${t.checked};
    }

    .ant-rate-star-first,
    .ant-rate-star-second {
      color: ${t.unchecked};
    }
  `, T = M(L)`
  ${(t) => t.$style && G(t.$style)}
`;
export {
  T as RateStyled,
  K as RatingComp
};
