import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
import { Field, EntityListSubTree } from "@contember/binding";
import { getDesugaredEntityList, getDesugaredFieldList } from "./hooks/useDesugaredOptionPath.js";
const renderDynamicChoiceFieldStatic = (props, environment, filter) => {
  const searchByFields = props.searchByFields !== void 0 && (Array.isArray(props.searchByFields) ? props.searchByFields.map((field, i) => /* @__PURE__ */ jsxDEV(Field, { field }, i, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
    lineNumber: 13,
    columnNumber: 43
  }, globalThis)) : /* @__PURE__ */ jsxDEV(Field, { field: props.searchByFields }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
    lineNumber: 15,
    columnNumber: 4
  }, globalThis));
  if ("renderOption" in props || "optionLabel" in props) {
    let renderedOptionBase;
    if ("renderOption" in props) {
      renderedOptionBase = typeof props.optionsStaticRender === "function" ? props.optionsStaticRender(environment) : props.optionsStaticRender;
    } else {
      renderedOptionBase = props.optionLabel;
    }
    const renderedOption = /* @__PURE__ */ jsxDEV(Fragment, { children: [
      searchByFields,
      renderedOptionBase
    ] }, void 0, true, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
      lineNumber: 31,
      columnNumber: 4
    }, globalThis);
    const entityList = getDesugaredEntityList(props.options, environment, props.lazy, filter);
    const subTree = /* @__PURE__ */ jsxDEV(Fragment, { children: [
      /* @__PURE__ */ jsxDEV(EntityListSubTree, { entities: entityList, ...entityList, expectedMutation: "none", children: renderedOption }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
        lineNumber: 40,
        columnNumber: 5
      }, globalThis),
      props.createNewForm && /* @__PURE__ */ jsxDEV(EntityListSubTree, { entities: {
        entityName: entityList.entityName
      }, limit: 0, expectedMutation: "none", children: [
        props.createNewForm,
        renderedOption
      ] }, void 0, true, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
        lineNumber: 44,
        columnNumber: 6
      }, globalThis)
    ] }, void 0, true, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
      lineNumber: 39,
      columnNumber: 4
    }, globalThis);
    return { subTree, renderedOption };
  } else {
    const fieldList = getDesugaredFieldList(props.options, environment, props.lazy, filter);
    const renderedOptionBase = /* @__PURE__ */ jsxDEV(Field, { field: fieldList }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
      lineNumber: 59,
      columnNumber: 30
    }, globalThis);
    const renderedOption = /* @__PURE__ */ jsxDEV(Fragment, { children: [
      searchByFields,
      renderedOptionBase
    ] }, void 0, true, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
      lineNumber: 61,
      columnNumber: 4
    }, globalThis);
    const subTree = /* @__PURE__ */ jsxDEV(Fragment, { children: [
      /* @__PURE__ */ jsxDEV(
        EntityListSubTree,
        {
          ...fieldList,
          entities: {
            entityName: fieldList.entityName,
            filter: fieldList.filter
          },
          expectedMutation: "none",
          children: renderedOption
        },
        void 0,
        false,
        {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
          lineNumber: 69,
          columnNumber: 5
        },
        globalThis
      ),
      props.createNewForm && /* @__PURE__ */ jsxDEV(EntityListSubTree, { entities: {
        entityName: fieldList.entityName
      }, limit: 0, expectedMutation: "none", children: [
        props.createNewForm,
        searchByFields,
        renderedOptionBase
      ] }, void 0, true, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
        lineNumber: 80,
        columnNumber: 6
      }, globalThis)
    ] }, void 0, true, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/fields/ChoiceField/renderDynamicChoiceFieldStatic.tsx",
      lineNumber: 68,
      columnNumber: 4
    }, globalThis);
    return { subTree, renderedOption };
  }
};
export {
  renderDynamicChoiceFieldStatic
};
//# sourceMappingURL=renderDynamicChoiceFieldStatic.js.map
