import { useCallback, createElement } from "react";
import { Component, useEnvironment } from "@contember/binding";
import { useResolvedSingleKindFileSelection } from "./selection/useResolvedSingleKindFileSelection.js";
import { createEntityConnectorFactory } from "../fileHandler/utils/createEntityConnector.js";
import { BareFileRepeater } from "./BareFileRepeater.js";
import { useSingleKindFileHandler } from "../fileHandler/useSingleKindFileHandler.js";
import { SingleKindFileHandler, isEmptyByUrlField } from "../fileHandler/SingleKindFileHandler.js";
const SingleKindFileRepeater = Component((props) => {
  const env = useEnvironment();
  const connectorFactoryFactory = useCallback(() => createEntityConnectorFactory(env, props.baseEntity), [env, props.baseEntity]);
  return /* @__PURE__ */ createElement(BareFileRepeater, {
    ...props,
    fileSelection: useResolvedSingleKindFileSelection(props, connectorFactoryFactory),
    fileHandler: useSingleKindFileHandler(props, props.kindFactory)
  });
}, (props) => /* @__PURE__ */ createElement(BareFileRepeater, {
  ...props,
  fileHandler: new SingleKindFileHandler(props.kindFactory(props), isEmptyByUrlField(props.urlField))
}), "SingleKindFileRepeater");
export { SingleKindFileRepeater };
//# sourceMappingURL=SingleKindFileRepeater.js.map
