"use strict";
const jsxRuntime = require("react/jsx-runtime");
const antd = require("antd");
const React = require("react");
const kit_internal_Label = require("./internal/Label.cjs");
const kit_Column = require("./Column.cjs");
const kit_Row = require("./Row.cjs");
const Toggle = ({ checked = false, label, onChange, disabled }) => {
  const [toggled, setToggled] = React.useState(checked);
  React.useEffect(() => {
    setToggled(checked);
  }, [checked]);
  const handleClick = React.useCallback(() => {
    if (onChange) {
      onChange(!toggled);
    } else {
      setToggled(!toggled);
    }
  }, [toggled, onChange, setToggled]);
  return /* @__PURE__ */ jsxRuntime.jsxs(kit_Row.Row, { children: [
    /* @__PURE__ */ jsxRuntime.jsx(kit_Column, { width: "hug", children: label && /* @__PURE__ */ jsxRuntime.jsx(kit_internal_Label.default, { type: "textOnly", children: label }) }),
    /* @__PURE__ */ jsxRuntime.jsx(kit_Column, { width: "hug", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Switch, { checked: toggled, disabled, size: "small", onClick: handleClick }) })
  ] });
};
module.exports = Toggle;
