"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = DataViewsSidebarContent;
var _components = require("@wordpress/components");
var _router = require("@wordpress/router");
var _defaultViews = require("./default-views");
var _lockUnlock = require("../../lock-unlock");
var _dataviewItem = _interopRequireDefault(require("./dataview-item"));
var _customDataviewsList = _interopRequireDefault(require("./custom-dataviews-list"));
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const {
  useLocation
} = (0, _lockUnlock.unlock)(_router.privateApis);
function DataViewsSidebarContent({
  postType
}) {
  const {
    query: {
      activeView = 'all',
      isCustom = 'false'
    }
  } = useLocation();
  const defaultViews = (0, _defaultViews.useDefaultViews)({
    postType
  });
  if (!postType) {
    return null;
  }
  const isCustomBoolean = isCustom === 'true';
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalItemGroup, {
      className: "edit-site-sidebar-dataviews",
      children: defaultViews.map(dataview => {
        return /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewItem.default, {
          slug: dataview.slug,
          title: dataview.title,
          icon: dataview.icon,
          type: dataview.view.type,
          isActive: !isCustomBoolean && dataview.slug === activeView,
          isCustom: false
        }, dataview.slug);
      })
    }), window?.__experimentalCustomViews && /*#__PURE__*/(0, _jsxRuntime.jsx)(_customDataviewsList.default, {
      activeView: activeView,
      type: postType,
      isCustom: true
    })]
  });
}
//# sourceMappingURL=index.js.map