import "lodash/cloneDeep";
import "lodash/get";
import "lodash/omit";
import "lodash/isNaN";
import { g as getTrad } from "./schema-88aedae1.mjs";
import "lodash/merge";
import "lodash/set";
import "@strapi/helper-plugin";
import { jsx, jsxs } from "react/jsx-runtime";
import { Combobox, ComboboxOption, SingleSelect, Flex, Typography, Loader, SingleSelectOption } from "@strapi/design-system";
import PropTypes from "prop-types";
import { useIntl } from "react-intl";
import { g as getDisplayName } from "./index-a9dd60c5.mjs";
import { u as useAdminUsers } from "./useAdminUsers-09f86a58.mjs";
import { u as useReviewWorkflows } from "./useReviewWorkflows-9e6b8986.mjs";
import { g as getStageColorByHex } from "./colors-e7489dd4.mjs";
import "react";
import "react-dnd";
import "@reduxjs/toolkit";
import "./index-466b22f5.mjs";
import "react-dom/client";
import "invariant";
import "lodash/isFunction";
import "lodash/pick";
import "react-helmet";
import "react-router-dom";
import "react-redux";
import "@radix-ui/react-context";
import "@strapi/design-system/v2";
import "@strapi/icons";
import "formik";
import "lodash/camelCase";
import "react-query";
import "styled-components";
import "yup";
import "lodash/defaultsDeep";
import "qs";
import "immer";
import "lodash/isBoolean";
import "lodash/isEmpty";
import "lodash/toNumber";
import "lodash/sortBy";
import "./DragLayer-bff96835.mjs";
import "./AuthenticatedApp-4e25ce97.mjs";
import "semver/functions/lt";
import "semver/functions/valid";
import "react-dnd-html5-backend";
import "react-error-boundary";
import "axios";
import "lodash/isObject";
import "lodash/isEqual";
import "lodash/upperFirst";
import "lodash/size";
import "lodash/take";
import "slate";
import "slate-history";
import "slate-react";
import "@radix-ui/react-toolbar";
import "./useDebounce-9364f340.mjs";
import "react-window";
import "codemirror5";
import "highlight.js";
import "markdown-it";
import "markdown-it-abbr";
import "markdown-it-container";
import "markdown-it-deflist";
import "markdown-it-emoji";
import "markdown-it-footnote";
import "markdown-it-ins";
import "markdown-it-mark";
import "markdown-it-sub";
import "markdown-it-sup";
import "sanitize-html";
import "codemirror5/addon/display/placeholder";
import "lodash/toLower";
import "lodash/toString";
import "react-dom";
import "fractional-indexing";
import "lodash/uniqBy";
import "lodash/unset";
import "lodash/isArray";
import "lodash/flatMap";
import "lodash/uniq";
import "./formatAPIErrors-db6ed675.mjs";
import "date-fns/parseISO";
import "lodash/isNumber";
import "lodash/groupBy";
import "./constants-8092eeb5.mjs";
const AssigneeFilter = ({ value, onChange }) => {
  const { formatMessage } = useIntl();
  const { users, isLoading } = useAdminUsers();
  return /* @__PURE__ */ jsx(
    Combobox,
    {
      value,
      "aria-label": formatMessage({
        id: "content-manager.components.Filters.usersSelect.label",
        defaultMessage: "Search and select an user to filter"
      }),
      onChange,
      loading: isLoading,
      children: users.map((user) => {
        return /* @__PURE__ */ jsx(ComboboxOption, { value: user.id.toString(), children: getDisplayName(user, formatMessage) }, user.id);
      })
    }
  );
};
AssigneeFilter.propTypes = {
  onChange: PropTypes.func.isRequired,
  value: PropTypes.string
};
AssigneeFilter.defaultProps = {
  value: ""
};
const StageFilter = ({ value, onChange, uid }) => {
  const { formatMessage } = useIntl();
  const {
    workflows: [workflow],
    isLoading
  } = useReviewWorkflows({ filters: { contentTypes: uid } });
  return /* @__PURE__ */ jsx(
    SingleSelect,
    {
      "aria-label": formatMessage({
        id: "content-manager.components.Filters.reviewWorkflows.label",
        defaultMessage: "Search and select an workflow stage to filter"
      }),
      value,
      onChange,
      loading: isLoading,
      customizeContent: () => /* @__PURE__ */ jsxs(Flex, { as: "span", justifyContent: "space-between", alignItems: "center", width: "100%", children: [
        /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", ellipsis: true, children: value }),
        isLoading ? /* @__PURE__ */ jsx(Loader, { small: true, style: { display: "flex" } }) : null
      ] }),
      children: (workflow?.stages ?? []).map(({ id, color, name }) => {
        const { themeColorName } = getStageColorByHex(color);
        return /* @__PURE__ */ jsx(
          SingleSelectOption,
          {
            startIcon: /* @__PURE__ */ jsx(
              Flex,
              {
                height: 2,
                background: color,
                borderColor: themeColorName === "neutral0" ? "neutral150" : "transparent",
                hasRadius: true,
                shrink: 0,
                width: 2
              }
            ),
            value: name,
            children: name
          },
          id
        );
      })
    }
  );
};
StageFilter.defaultProps = {
  value: ""
};
StageFilter.propTypes = {
  onChange: PropTypes.func.isRequired,
  uid: PropTypes.string.isRequired,
  value: PropTypes.string
};
const REVIEW_WORKFLOW_FILTERS = [
  {
    fieldSchema: {
      type: "relation",
      mainField: {
        name: "name",
        schema: {
          type: "string"
        }
      }
    },
    metadatas: {
      customInput: StageFilter,
      label: {
        id: getTrad(`containers.ListPage.table-headers.reviewWorkflows.stage`),
        defaultMessage: "Review stage"
      }
    },
    name: "strapi_stage"
  },
  {
    fieldSchema: {
      type: "relation",
      mainField: {
        name: "id",
        schema: {
          type: "int"
        }
      }
    },
    metadatas: {
      customInput: AssigneeFilter,
      customOperators: [
        {
          intlLabel: {
            id: "components.FilterOptions.FILTER_TYPES.$eq",
            defaultMessage: "is"
          },
          value: "$eq"
        },
        {
          intlLabel: {
            id: "components.FilterOptions.FILTER_TYPES.$ne",
            defaultMessage: "is not"
          },
          value: "$ne"
        }
      ],
      label: {
        id: getTrad(`containers.ListPage.table-headers.reviewWorkflows.assignee.label`),
        defaultMessage: "Assignee"
      }
    },
    name: "strapi_assignee"
  }
];
export {
  REVIEW_WORKFLOW_FILTERS
};
//# sourceMappingURL=constants-031d70b7.mjs.map
