"use strict";
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxDevRuntime = require("react/jsx-dev-runtime");
const reactBinding = require("@contember/react-binding");
const react = require("react");
const _SideDimensions = class _SideDimensions extends react.PureComponent {
  render() {
    return /* @__PURE__ */ jsxDevRuntime.jsxDEV("div", { className: "sideDimensions", children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.EnvironmentContext.Consumer, { children: (oldEnvironment) => _SideDimensions.staticRender(this.props, oldEnvironment) }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
      lineNumber: 28,
      columnNumber: 5
    }, this) }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
      lineNumber: 27,
      columnNumber: 4
    }, this);
  }
  static staticRender(props, environment) {
    if (props.dimension === void 0 === (props.staticOptions === void 0)) {
      throw new reactBinding.BindingError(
        `The SideDimensions component needs to be passed exactly one of its 'dimension' or 'staticOptions' props.`
      );
    }
    let dimensions;
    if (props.dimension !== void 0) {
      const selectedDimensions = environment.getAllDimensions();
      if (!(props.dimension in selectedDimensions)) {
        console.error(new reactBinding.BindingError(`The '${props.dimension}' dimension in undefined`));
        return null;
      }
      dimensions = selectedDimensions[props.dimension];
    } else if (props.staticOptions !== void 0) {
      dimensions = props.staticOptions;
    }
    const alignChildren = props.alignChildren !== false;
    const children = Array.isArray(props.children) && alignChildren ? props.children : [props.children];
    return /* @__PURE__ */ jsxDevRuntime.jsxDEV("div", { className: "sideDimensions-dimensions", children: children.map((child, i) => /* @__PURE__ */ jsxDevRuntime.jsxDEV("div", { className: "sideDimensions-dimensions-in", children: dimensions.map((item, j) => {
      return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
        _SideDimensions.SingleDimension,
        {
          environment,
          dimensionValue: item,
          variableName: props.variableName,
          variables: props.variables,
          hasOneField: props.hasOneField,
          renderDimensionValue: dimensions.length > 1,
          labelMiddleware: props.labelMiddleware,
          children: child
        },
        j,
        false,
        {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
          lineNumber: 66,
          columnNumber: 9
        },
        this
      );
    }) }, i, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
      lineNumber: 63,
      columnNumber: 6
    }, this)) }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
      lineNumber: 61,
      columnNumber: 4
    }, this);
  }
};
__publicField(_SideDimensions, "displayName", "SideDimensions");
let SideDimensions = _SideDimensions;
((SideDimensions2) => {
  const _SingleDimension = class _SingleDimension extends react.PureComponent {
    render() {
      const children = _SingleDimension.staticRender(this.props, this.props.environment);
      const newLabelMiddleware = this.getLabelMiddleware();
      const inner = /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.EnvironmentContext.Provider, { value: _SingleDimension.generateEnvironment(this.props, this.props.environment), children: /* @__PURE__ */ jsxDevRuntime.jsxDEV("div", { className: "sideDimensions-dimensions-dimension", children: [
        this.props.renderDimensionValue && /* @__PURE__ */ jsxDevRuntime.jsxDEV("span", { className: "sideDimensions-dimensions-dimensionValue", children: this.props.dimensionValue }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
          lineNumber: 113,
          columnNumber: 43
        }, this),
        children
      ] }, void 0, true, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
        lineNumber: 112,
        columnNumber: 6
      }, this) }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
        lineNumber: 111,
        columnNumber: 5
      }, this);
      if (newLabelMiddleware) {
        return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.LabelMiddlewareProvider, { value: newLabelMiddleware, children: inner }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
          lineNumber: 120,
          columnNumber: 6
        }, this);
      }
      return inner;
    }
    getLabelMiddleware() {
      if (this.props.labelMiddleware) {
        return this.props.labelMiddleware;
      }
      if (!this.props.variables) {
        return void 0;
      }
      const variables = typeof this.props.variables === "function" ? this.props.variables(this.props.dimensionValue) : this.props.variables;
      if ("labelMiddleware" in variables) {
        return variables.labelMiddleware;
      }
      return void 0;
    }
    static staticRender(props, environment) {
      if (!props.hasOneField) {
        return props.children;
      }
      const hasOneProps = typeof props.hasOneField === "string" ? {
        field: props.hasOneField
      } : props.hasOneField;
      return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.HasOne, { ...hasOneProps, children: props.children }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/environment/SideDimensions.tsx",
        lineNumber: 152,
        columnNumber: 11
      }, this);
    }
    static generateEnvironment(props, oldEnvironment) {
      const deltaFactory = typeof props.variables === "function" ? props.variables(props.dimensionValue) : props.variables ?? {};
      if (props.variableName) {
        deltaFactory[props.variableName] = props.dimensionValue;
      }
      const { labelMiddleware, ...variables } = deltaFactory;
      return oldEnvironment.withVariables(variables);
    }
  };
  __publicField(_SingleDimension, "displayName", "SideDimension");
  let SingleDimension = _SingleDimension;
  SideDimensions2.SingleDimension = SingleDimension;
})(SideDimensions || (SideDimensions = {}));
exports.SideDimensions = SideDimensions;
//# sourceMappingURL=SideDimensions.cjs.map
