import { jsx } from "react/jsx-runtime";
import { SugaredField, QueryLanguage } from "@contember/react-binding";
const getFileUrlDataExtractor = ({ urlField }) => ({
  staticRender: () => /* @__PURE__ */ jsx(SugaredField, { field: urlField }),
  populateFields: ({ entity, uploadResult }) => {
    if (!uploadResult.fileUrl || typeof uploadResult.fileUrl !== "string") {
      return;
    }
    entity.getField(urlField).updateValue(uploadResult.fileUrl);
  },
  getErrorsHolders: ({ entity, environment }) => {
    const desugaredUrlField = QueryLanguage.desugarRelativeSingleField(urlField, environment);
    const owningEntity = entity.getRelativeSingleEntity({
      hasOneRelationPath: desugaredUrlField.hasOneRelationPath
    });
    return [entity.getField(urlField), owningEntity];
  }
});
export {
  getFileUrlDataExtractor
};
//# sourceMappingURL=getFileUrlDataExtractor.js.map
