"use strict";

exports.__esModule = true;
exports.MultiLevelSortingCTAButton = void 0;
exports._MultiLevelSortingCTAButton = _MultiLevelSortingCTAButton;
var _react = _interopRequireWildcard(require("react"));
var _mobx = require("mobx");
var _mobxReactLite = require("mobx-react-lite");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _state = require("../../state");
var _MultiLevelSortingPanel = require("../MultiLevelSortingPanel");
var _CounterBadgeButton = require("../CounterBadgeButton");
var _react2 = require("@wix/bex-core/react");
var _ResponsiveButton = require("../ResponsiveButton/ResponsiveButton");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/MultiLevelSorting/MultiLevelSortingCTAButton.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 _MultiLevelSortingCTAButton(props) {
  const {
    state
  } = props;
  const {
    panels,
    container: {
      translate: t,
      isPanelLayout
    },
    toolbar: {
      responsive
    }
  } = state;
  const {
    modalsContainerRef
  } = (0, _react2.usePageContext)();
  const [multiLevelSortingState] = (0, _react.useState)(() => (0, _mobx.runInAction)(() => state.multiLevelSorting ?? (state.multiLevelSorting = new _state.MultiLevelSortingState({
    table: state,
    container: state.container,
    modalsContainerRef
  }))));
  (0, _react.useEffect)(() => multiLevelSortingState.init(), []);
  (0, _react.useEffect)(() => {
    panels.registerSidePanel('multiLevelSorting', _MultiLevelSortingPanel.MultiLevelSortingPanelEntry);
  }, []);
  return /*#__PURE__*/_react.default.createElement(_CounterBadgeButton.CounterBadgeButton, {
    dataHook: "multi-level-sorting-button-counter",
    count: multiLevelSortingState.sortListSize,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 46,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_ResponsiveButton.ResponsiveButton, {
    state: responsive.actions,
    shouldShrink: !isPanelLayout,
    icon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.ChangeOrderSmall, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 53,
        columnNumber: 15
      }
    }),
    dataHook: "multi-level-sorting-button",
    onClick: () => {
      const isOpen = panels.toggleSidePanel('multiLevelSorting');
      if (isOpen) {
        multiLevelSortingState.reportSidePanelOpen();
      } else {
        multiLevelSortingState.reportSidePanelClose({
          origin: 'Sort CTA'
        });
      }
    },
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 50,
      columnNumber: 7
    }
  }, t('cairo.table.advanced-sorting.button.cta')));
}
const MultiLevelSortingCTAButton = exports.MultiLevelSortingCTAButton = (0, _mobxReactLite.observer)(_MultiLevelSortingCTAButton);
//# sourceMappingURL=MultiLevelSortingCTAButton.js.map