import { cD as f, a4 as i, a3 as C, dx as y, W as g, a9 as w, bX as v, a5 as o, cf as p, aG as V, cg as k, S as x, c3 as b, dy as E, ci as F, U as P, H as a, dz as $, ad as s, I as m, ae as l, af as n, co as M, am as d, c0 as O, ag as I, d6 as j, dA as B, d8 as D, dB as N, ah as R, aj as W, c1 as A, aC as H, dC as L, cr as T } from "./56c67d3b.js";
import { useEffect as U, useContext as c } from "react";
import "react-dom";
const z = [f, {
  label: i("switchComp.open"),
  value: "true",
  description: i("switchComp.openDesc")
}, {
  label: i("switchComp.close"),
  value: "false",
  description: i("switchComp.closeDesc")
}], G = (t) => H`
    .ant-switch-handle::before {
      background: ${t.handle};
    }
    button {
      background-image: none;
      background: ${t.unchecked};
      &.ant-switch-checked {
        background: ${t.checked};
        &:hover:not(.ant-switch-disabled) {
          background: ${L(t.checked, 0.2)}
        }
      }
    }
  `, X = C.div`
  min-height: 32px;
  display: flex;
  align-items: center;
  // Can respond to drag & select events when disabled
  ${(t) => t.disabled && `
    cursor: not-allowed;
    >button:disabled {
      pointer-events: none;
    }
  `};
  ${(t) => t.$style && G(t.$style)}
`;
function q(t) {
  return t && t.hasOwnProperty("unChecked") ? {
    label: t.label,
    handle: t.handle,
    unchecked: t.unChecked,
    checked: t.checked
  } : t;
}
let r = function() {
  const t = {
    defaultValue: y("defaultValue"),
    value: y("value"),
    label: g,
    onEvent: w(z),
    disabled: v,
    style: o(p, "style"),
    animationStyle: o(V, "animationStyle"),
    labelStyle: o(k.filter((e) => ["accent", "validate"].includes(e.name) === !1), "labelStyle"),
    viewRef: x,
    inputFieldStyle: b(o(E, "inputFieldStyle"), q),
    ...F
  };
  return new P(t, (e) => {
    const u = {
      ...e.defaultValue
    }.value, S = {
      ...e.value
    }.value;
    return U(() => {
      e.value.onChange(u);
    }, [u]), e.label({
      style: e.style,
      labelStyle: e.labelStyle,
      inputFieldStyle: e.inputFieldStyle,
      animationStyle: e.animationStyle,
      children: /* @__PURE__ */ a(X, {
        disabled: e.disabled,
        $style: e.inputFieldStyle,
        children: /* @__PURE__ */ a($, {
          checked: S,
          disabled: e.disabled,
          ref: e.viewRef,
          onChange: (h) => {
            e.value.onChange(h), e.onEvent("change"), e.onEvent(h ? "true" : "false");
          }
        })
      })
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ s(m, {
    children: [/* @__PURE__ */ a(l, {
      name: n.basic,
      children: e.defaultValue.propertyView({
        label: i("switchComp.defaultValue")
      })
    }), /* @__PURE__ */ a(M, {
      ...e
    }), ["logic", "both"].includes(c(d).editorModeStatus) && /* @__PURE__ */ s(l, {
      name: n.interaction,
      children: [e.onEvent.getPropertyView(), O(e), I(e)]
    }), ["layout", "both"].includes(c(d).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(c(d).editorModeStatus) && /* @__PURE__ */ s(m, {
      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()
      })]
    })]
  })).setExposeMethodConfigs(j([B, D, N])).build();
}();
r = b(r, T);
const Y = R(r, [new W("value", i("switchComp.valueDesc")), ...A]);
export {
  Y as SwitchComp
};
