text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.SplitStory = SplitStory;
  
  var _range2 = _interopRequireDefault(require("lodash/range"));
  
  var _default = _interopRequireDefault(require("part:@sanity/components/panes/default"));
  
  var _splitController = _interopRequireDefault(require("part:@sanity/components/panes/split-controller"));
  
  var _splitPaneWrapper = _interopRequireDefault(require("part:@sanity/components/panes/split-pane-wrapper"));
  
  var _actions = require("part:@sanity/storybook/addons/actions");
  
  var _knobs = require("part:@sanity/storybook/addons/knobs");
  
  var _components = require("part:@sanity/storybook/components");
  
  var _react = _interopRequireDefault(require("react"));
  
  var _split = _interopRequireDefault(require("./split.css"));
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  class AutoCollapseTest extends _react.default.PureComponent {
    constructor() {
      super(...arguments);
  
      _defineProperty(this, "state", {
        collapsed: []
      });
  
      _defineProperty(this, "handleCollapse", collapsedPanes => {
        this.setState({
          collapsed: collapsedPanes
        });
      });
  
      _defineProperty(this, "handleExpand", collapsedPanes => {
        this.setState({
          collapsed: collapsedPanes
        });
      });
  
      _defineProperty(this, "handlePaneCollapse", index => {
        this.setState(prevState => {
          var collapsed = prevState.collapsed.slice();
          collapsed[index] = true;
          return {
            collapsed
          };
        });
      });
  
      _defineProperty(this, "handlePaneExpand", index => {
        this.setState(prevState => {
          var collapsed = prevState.collapsed.slice();
          collapsed[index] = false;
          return {
            collapsed
          };
        });
      });
    }
  
    render() {
      var panes = this.props.panes;
      var collapsed = this.state.collapsed;
      return /*#__PURE__*/_react.default.createElement(_splitController.default, {
        onShouldCollapse: this.handleCollapse,
        onShouldExpand: this.handleExpand,
        collapsed: collapsed // trigger
  
      }, panes.map((pane, i) => {
        return /*#__PURE__*/_react.default.createElement(_splitPaneWrapper.default, {
          minSize: pane.minSize,
          defaultSize: pane.defaultSize,
          key: pane.key,
          isCollapsed: pane.isCollapsed
        }, /*#__PURE__*/_react.default.createElement(_default.default, {
          index: i,
          title: pane.title,
          minSize: pane.minSize,
          defaultSize: pane.defaultSize,
          onExpand: this.handlePaneExpand,
          onCollapse: this.handlePaneCollapse,
          onMenuToggle: _actions.action,
          isCollapsed: pane.isCollapsed
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: _split.default.root
        }, /*#__PURE__*/_react.default.createElement("pre", null, "collapsed=", pane.isCollapsed ? 'true' : 'false'), /*#__PURE__*/_react.default.createElement("pre", null, "defaultSize=", pane.defaultSize), /*#__PURE__*/_react.default.createElement("pre", null, "minSize=", pane.minSize))));
      }));
    }
  
  }
  
  function SplitStory() {
    var panes = (0, _range2.default)((0, _knobs.number)('Panes qty', 4, 'test')).map((pane, i) => {
      return {
        index: i,
        title: "Pane ".concat(i),
        key: "pane".concat(i),
        isCollapsed: [false][i],
        minSize: [100, 200, 300, 400][i] || 100,
        defaultSize: [400, 400, 400, 800][i] || 400
      };
    });
    return /*#__PURE__*/_react.default.createElement(_components.DebugRouterProvider, null, /*#__PURE__*/_react.default.createElement(AutoCollapseTest, {
      panes: (0, _knobs.object)('Panes', panes, 'props')
    }));
  }