"use client";
import * as f from "react";
import { composeEventHandlers as m } from "../../primitive/dist/index.js";
import { useControllableState as p } from "../../react-use-controllable-state/dist/index.js";
import { Primitive as c } from "../../react-primitive/dist/index.js";
import { jsx as u } from "react/jsx-runtime";
var r = "Toggle", t = f.forwardRef((e, a) => {
  const { pressed: s, defaultPressed: d, onPressedChange: i, ...l } = e, [o, n] = p({
    prop: s,
    onChange: i,
    defaultProp: d ?? !1,
    caller: r
  });
  return /* @__PURE__ */ u(
    c.button,
    {
      type: "button",
      "aria-pressed": o,
      "data-state": o ? "on" : "off",
      "data-disabled": e.disabled ? "" : void 0,
      ...l,
      ref: a,
      onClick: m(e.onClick, () => {
        e.disabled || n(!o);
      })
    }
  );
});
t.displayName = r;
var C = t;
export {
  C as Root,
  t as Toggle
};
