import { cA as b, w, cn as C, bK as v, bv as V, bd as x, bL as S, bA as E, bB as f, cE as P, bO as k, U as R, V as t, P as l, bh as i, bi as n, bj as r, a0 as o, bg as u, bk as $, bl as p, bn as H, bo as m, bp as B, b9 as M, bZ as O, co as F, cF as N } from "./684d2f28.js";
import { useRef as j, useEffect as y, useContext as c } from "react";
import { formDataChildren as L, FormDataPropertyView as A } from "./00dac55d.js";
import "react-dom";
const D = [O];
function U(a) {
  return a && a.hasOwnProperty("unChecked") ? {
    label: a.label,
    checked: a.checked,
    unchecked: a.unChecked
  } : a;
}
const I = function() {
  const a = {
    defaultValue: b("defaultValue"),
    value: b("value"),
    max: w(C, "5"),
    label: v,
    allowHalf: V,
    disabled: x,
    onEvent: S(D),
    style: E(f(P), U),
    labelStyle: f(k.filter((e) => ["accent", "validate"].includes(e.name) === !1)),
    ...L
  };
  return new R(a, (e) => {
    const d = {
      ...e.defaultValue
    }.value, g = {
      ...e.value
    }.value, s = j(!1);
    return y(() => {
      e.value.onChange(d);
    }, [d]), y(() => {
      s.current && (e.onEvent("change"), s.current = !1);
    }, [g]), e.label({
      style: e.style,
      labelStyle: e.labelStyle,
      children: /* @__PURE__ */ t(Z, {
        count: e.max,
        value: e.value.value,
        onChange: (h) => {
          e.value.onChange(h), s.current = !0;
        },
        allowHalf: e.allowHalf,
        disabled: e.disabled,
        $style: e.style
      })
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ l(i, {
    children: [/* @__PURE__ */ l(n, {
      name: r.basic,
      children: [e.defaultValue.propertyView({
        label: o("prop.defaultValue")
      }), e.max.propertyView({
        label: o("rating.max")
      })]
    }), /* @__PURE__ */ t(A, {
      ...e
    }), ["logic", "both"].includes(c(u).editorModeStatus) && /* @__PURE__ */ l(i, {
      children: [/* @__PURE__ */ l(n, {
        name: r.interaction,
        children: [e.onEvent.getPropertyView(), $(e), p(e)]
      }), /* @__PURE__ */ t(n, {
        name: r.advanced,
        children: e.allowHalf.propertyView({
          label: o("rating.allowHalf")
        })
      })]
    }), ["layout", "both"].includes(c(u).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(c(u).editorModeStatus) && /* @__PURE__ */ l(i, {
      children: [/* @__PURE__ */ t(n, {
        name: r.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ t(n, {
        name: r.labelStyle,
        children: e.labelStyle.getPropertyView()
      })]
    })]
  })).build();
}(), Q = H(I, [new m("value", o("export.ratingValueDesc")), new m("max", o("export.ratingMaxDesc")), ...B]), K = (a) => F`
    .ant-rate {
      color: ${a.checked};
    }

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

    .ant-rate-star-first,
    .ant-rate-star-second {
      color: ${a.unchecked};
    }
  `, Z = M(N)`
  ${(a) => a.$style && K(a.$style)}
`;
export {
  Z as RateStyled,
  Q as RatingComp
};
