// src/components/factory.tsx
import { mergeProps } from "@zag-js/solid";
import { splitProps } from "solid-js";
import { Dynamic } from "solid-js/web";
var withAsProp = (Component) => {
  const ArkComponent = (props) => {
    const [localProps, parentProps] = splitProps(props, ["asChild"]);
    if (localProps.asChild) {
      const propsFn = (userProps) => {
        const [, restProps] = splitProps(parentProps, ["ref"]);
        return mergeProps(restProps, userProps);
      };
      return localProps.asChild(propsFn);
    }
    return <Dynamic component={Component} {...parentProps} />;
  };
  return ArkComponent;
};
function jsxFactory() {
  const cache = /* @__PURE__ */ new Map();
  return new Proxy(withAsProp, {
    apply(_target, _thisArg, argArray) {
      return withAsProp(argArray[0]);
    },
    get(_, element) {
      const asElement = element;
      if (!cache.has(asElement)) {
        cache.set(asElement, withAsProp(asElement));
      }
      return cache.get(asElement);
    }
  });
}
var ark = jsxFactory();

export {
  ark
};
