import { dynamic } from "@solidjs/web";
import { omit } from "solid-js";
import { mergeRootProps } from "../../internals/merge-root-props.jsx";
import { resolveClassStyle } from "../../internals/resolve-class-style.jsx";
import { useMeterRootContext } from "../meter-root-context.jsx";
/**
 * A text element displaying the current value. Renders a `<span>` (or `as`
 * override).
 *
 * §1 wave 2: replaces `renderElement` with a `dynamic()` element. Function-children
 * are resolved via a reactive getter on the internal slot bag.
 */
export function MeterValue(props) {
  const context = useMeterRootContext();
  const content = () => {
    const value = context.value();
    const formattedValue = context.formattedValue();
    const child = props.children;
    if (typeof child === "function") {
      return child(formattedValue, value);
    }
    if (child !== undefined) return child;
    return formattedValue || value;
  };
  const userClassStyle = resolveClassStyle(props, () => ({}));
  const userProps = omit(props, "as", "children", "class", "style", "attrs");
  const internalSlot = {
    "aria-hidden": "true",
    get children() {
      return content();
    }
  };
  let merged = mergeRootProps(internalSlot, userClassStyle);
  merged = mergeRootProps(merged, userProps);
  const Tag = dynamic(() => props.as ?? "span");
  return <Tag {...merged} />;
}
//# sourceMappingURL=meter-value.jsx.map
