"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.PickerStandalone = void 0;
exports._PickerStandalone = _PickerStandalone;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _PickerStandaloneLayout = require("../PickerStandaloneLayout");
var _Picker = require("../Picker");
var _react = _interopRequireWildcard(require("react"));
var _Splash = require("../Splash");
var _CollectionContext = require("../CollectionContext");
var _PickerListContent = require("../PickerListContent");
var _PickerStandaloneTableListItem = require("./PickerStandaloneTableListItem");
var _mobxReactLite = require("mobx-react-lite");
var _MultiCollectionSupportProvider = require("../MultiCollectionSupportProvider");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/PickerStandalone/PickerStandalone.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function _PickerStandalone(props) {
  const {
    state,
    renderItem,
    renderEmptyState,
    renderError,
    selectorListProps,
    dataHook,
    height,
    mobileHeight,
    minContentHeight,
    primaryActionWidth,
    defaultPrimaryButtonText,
    ...rest
  } = props;
  const {
    picker,
    initTask,
    isMobileView
  } = state;
  const {
    collection
  } = picker;
  state._hasCreateNewAction = props.createNewAction != null;
  (0, _react.useState)(() => {
    if (minContentHeight != null) {
      picker.minContentHeight = minContentHeight;
    }
  });
  (0, _react.useEffect)(() => {
    return state.init();
  }, []);
  const {
    splashProps
  } = isMobileView ? {
    splashProps: {
      height: mobileHeight
    }
  } : {
    splashProps: {
      paddingTop: 'SP8',
      paddingBottom: 'SP8',
      height
    }
  };
  return /*#__PURE__*/_react.default.createElement(_CollectionContext.CollectionProvider, {
    value: collection,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 135,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_MultiCollectionSupportProvider.MultiCollectionSupportProvider, {
    value: state.picker.multi,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 136,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement("div", {
    "data-patterns": true,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 137,
      columnNumber: 9
    }
  }, /*#__PURE__*/_react.default.createElement(_Splash.Splash, (0, _extends2.default)({
    renderError: renderError,
    dataHook: dataHook,
    state: initTask
  }, splashProps, {
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 138,
      columnNumber: 11
    }
  }), /*#__PURE__*/_react.default.createElement(_PickerStandaloneLayout.PickerStandaloneLayout, (0, _extends2.default)({
    renderError: renderError,
    state: state
  }, rest, {
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 144,
      columnNumber: 13
    }
  }), /*#__PURE__*/_react.default.createElement(_Picker.Picker, {
    dataHook: "picker",
    state: picker,
    renderEmptyState: renderEmptyState,
    renderError: renderError,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 149,
      columnNumber: 15
    }
  }, /*#__PURE__*/_react.default.createElement(_PickerListContent.PickerListContent, (0, _extends2.default)({}, selectorListProps, {
    state: picker,
    spacing: 94,
    renderItem: (keyedItem, index) => /*#__PURE__*/_react.default.createElement(_PickerStandaloneTableListItem.PickerStandaloneTableListItem, (0, _extends2.default)({}, renderItem == null ? void 0 : renderItem(keyedItem.item, index, {
      isMobileView
    }), {
      defaultPrimaryButtonText: defaultPrimaryButtonText,
      state: state,
      primaryActionWidth: primaryActionWidth,
      keyedItem: keyedItem,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 160,
        columnNumber: 21
      }
    })),
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 155,
      columnNumber: 17
    }
  }))))))));
}
const PickerStandalone = exports.PickerStandalone = (0, _mobxReactLite.observer)(_PickerStandalone);
//# sourceMappingURL=PickerStandalone.js.map