import { mergeProps, splitProps, useContext } from "solid-js";
import classNames from "./classnames";
import { useBootstrapPrefix } from "./ThemeProvider";
import OverlayContext from "./OverlayContext";
const defaultProps = {
    arrowProps: {},
    placement: "right",
};
const Tooltip = (p) => {
    const [local, props] = splitProps(mergeProps(defaultProps, p), [
        "bsPrefix",
        "placement",
        "className",
        "style",
        "children",
        "arrowProps",
        "popper",
        "show",
    ]);
    const bsPrefix = useBootstrapPrefix(local.bsPrefix, "tooltip");
    const [primaryPlacement] = local.placement?.split("-") || [];
    const context = useContext(OverlayContext);
    return (<div role="tooltip" x-placement={primaryPlacement} className={classNames(local.className, bsPrefix, `bs-tooltip-auto`)} {...props} {...context?.wrapperProps} style={Object.assign({}, local.style, context?.wrapperProps.style)}>
      <div className="tooltip-arrow" {...context?.arrowProps}>
        {context?.arrowProps?.children}
      </div>
      <div className={`${bsPrefix}-inner`}>{local.children}</div>
    </div>);
};
export default Tooltip;
