/*
 * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { Menu } from "@base-ui/react/menu";
import React, { memo, useCallback } from "react";
import { CheckIcon, ChevronDownIcon, ExcludeIcon } from "./FilterIcons.js";
import { useFilterListBoundary } from "./FilterListBoundaryContext.js";
import styles from "./ExcludeDropdown.module.css";
function ExcludeDropdownInner({
  isExcluding,
  onToggleExclude
}) {
  const collisionBoundary = useFilterListBoundary();
  const label = isExcluding ? "Excluding" : "Keeping";
  const handleSelectKeeping = useCallback(() => {
    if (isExcluding) {
      onToggleExclude();
    }
  }, [isExcluding, onToggleExclude]);
  const handleSelectExcluding = useCallback(() => {
    if (!isExcluding) {
      onToggleExclude();
    }
  }, [isExcluding, onToggleExclude]);
  return /*#__PURE__*/React.createElement("div", {
    className: styles.excludeDropdownContainer
  }, /*#__PURE__*/React.createElement(Menu.Root, null, /*#__PURE__*/React.createElement(Menu.Trigger, {
    className: styles.trigger,
    "aria-label": label,
    "data-excluding": isExcluding || undefined
  }, isExcluding && /*#__PURE__*/React.createElement(ExcludeIcon, null), /*#__PURE__*/React.createElement("span", {
    className: styles.triggerLabel
  }, label), /*#__PURE__*/React.createElement(ChevronDownIcon, null)), /*#__PURE__*/React.createElement(Menu.Portal, null, /*#__PURE__*/React.createElement(Menu.Positioner, {
    className: styles.positioner,
    sideOffset: 4,
    collisionBoundary: collisionBoundary
  }, /*#__PURE__*/React.createElement(Menu.Popup, {
    className: styles.popup
  }, /*#__PURE__*/React.createElement(Menu.Item, {
    className: styles.menuItem,
    onClick: handleSelectKeeping
  }, /*#__PURE__*/React.createElement("span", {
    className: styles.menuItemCheck
  }, !isExcluding && /*#__PURE__*/React.createElement(CheckIcon, null)), "Keeping"), /*#__PURE__*/React.createElement(Menu.Item, {
    className: styles.menuItem,
    onClick: handleSelectExcluding
  }, /*#__PURE__*/React.createElement("span", {
    className: styles.menuItemCheck
  }, isExcluding && /*#__PURE__*/React.createElement(CheckIcon, null)), "Excluding"))))));
}
export const ExcludeDropdown = /*#__PURE__*/memo(ExcludeDropdownInner);
//# sourceMappingURL=ExcludeDropdown.js.map