function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { BoxAiAgentSelector } from '@box/box-ai-agent-selector';
import { InlineNotice, TooltipProvider } from '@box/blueprint-web';
// $FlowFixMe
import BoxAiLogo from '@box/blueprint-web-assets/icons/Logo/BoxAiLogo';
import Toggle from '../../components/toggle';
import { RadioButton, RadioGroup } from '../../components/radio';
import Link from '../../components/link/Link';
import IconAlertDefault from '../../icons/general/IconAlertDefault';
import messages from './messages';
import './CascadePolicy.scss';
const COMMUNITY_LINK = 'https://support.box.com/hc/en-us/articles/360044195873-Cascading-metadata-in-folders';
const AI_LINK = 'https://www.box.com/ai';
const PRICING_LINK = 'https://www.box.com/pricing';
const agents = [{
  id: '1',
  name: 'Basic',
  isEnterpriseDefault: true
}, {
  id: '2',
  name: 'Enhanced (Gemini 2.5 Pro)',
  isEnterpriseDefault: false
}];
const CascadePolicy = ({
  canEdit,
  canUseAIFolderExtraction,
  isCascadingEnabled,
  isCascadingOverwritten,
  isCustomMetadata,
  isAIFolderExtractionEnabled,
  onAIFolderExtractionToggle,
  onCascadeToggle,
  onCascadeModeChange,
  shouldShowCascadeOptions
}) => {
  const readOnlyState = isCascadingEnabled ? /*#__PURE__*/React.createElement("div", {
    className: "metadata-cascade-notice"
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.metadataCascadePolicyEnabledInfo)) : null;
  return canEdit ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: "metadata-cascade-editor"
  }, /*#__PURE__*/React.createElement("div", {
    className: "metadata-cascade-enable"
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, _extends({
    tagName: "strong"
  }, messages.enableCascadePolicy)), !isCustomMetadata && /*#__PURE__*/React.createElement(Toggle, {
    className: `metadata-cascade-toggle ${isCascadingEnabled ? 'cascade-on' : 'cascade-off'}`,
    isOn: isCascadingEnabled,
    label: "",
    onChange: e => onCascadeToggle(e.target.checked)
  })), !isCustomMetadata ? /*#__PURE__*/React.createElement("div", {
    className: "cascade-policy-text"
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.applyCascadePolicyText), "\xA0", /*#__PURE__*/React.createElement(Link, {
    className: "cascade-policy-link",
    href: COMMUNITY_LINK,
    target: "_blank"
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.cascadePolicyLearnMore))) : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, messages.cannotApplyCascadePolicyText)))), shouldShowCascadeOptions && /*#__PURE__*/React.createElement("div", {
    className: "metadata-cascade-editor"
  }, /*#__PURE__*/React.createElement("div", {
    className: "metadata-cascading-mode"
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.cascadePolicyModeQuestion), /*#__PURE__*/React.createElement("div", {
    className: "metadata-operation-not-immediate"
  }, /*#__PURE__*/React.createElement(IconAlertDefault, null), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormattedMessage, messages.operationNotImmediate))), /*#__PURE__*/React.createElement(RadioGroup, {
    className: "metadata-cascading-options",
    onChange: e => onCascadeModeChange(e.target.value === 'overwrite'),
    value: isCascadingOverwritten ? 'overwrite' : 'skip'
  }, /*#__PURE__*/React.createElement(RadioButton, {
    label: /*#__PURE__*/React.createElement(FormattedMessage, messages.cascadePolicySkipMode),
    value: "skip"
  }), /*#__PURE__*/React.createElement(RadioButton, {
    label: /*#__PURE__*/React.createElement(FormattedMessage, messages.cascadePolicyOverwriteMode),
    value: "overwrite"
  })))), shouldShowCascadeOptions && canUseAIFolderExtraction && /*#__PURE__*/React.createElement("div", {
    className: "metadata-cascade-editor",
    "data-testid": "ai-folder-extraction"
  }, /*#__PURE__*/React.createElement("div", {
    className: "metadata-cascade-enable"
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BoxAiLogo, {
    className: "metadata-cascade-ai-logo",
    width: 16,
    height: 16
  }), /*#__PURE__*/React.createElement(FormattedMessage, _extends({
    tagName: "strong"
  }, messages.enableAIAutofill)), /*#__PURE__*/React.createElement(Toggle, {
    className: "metadata-cascade-toggle",
    isOn: isAIFolderExtractionEnabled,
    label: "",
    onChange: e => onAIFolderExtractionToggle(e.target.checked)
  })), /*#__PURE__*/React.createElement("div", {
    className: "cascade-policy-text"
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.aiAutofillDescription), "\xA0", /*#__PURE__*/React.createElement(Link, {
    className: "cascade-policy-link",
    href: AI_LINK,
    target: "_blank"
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.aiAutofillLearnMore))), /*#__PURE__*/React.createElement("div", {
    className: "metadata-cascade-ai-agent-selector"
  }, /*#__PURE__*/React.createElement(TooltipProvider, null, /*#__PURE__*/React.createElement(BoxAiAgentSelector, {
    agents: agents,
    onErrorAction: () => {},
    requestState: "success",
    selectedAgent: agents[0],
    variant: "sidebar"
  }))), /*#__PURE__*/React.createElement(InlineNotice, {
    className: "metadata-cascade-ai-notice",
    variant: "info"
  }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.aiAutofillNotice, {
    values: {
      pricingLink: /*#__PURE__*/React.createElement(Link, {
        className: "cascade-policy-link",
        href: PRICING_LINK,
        target: "_blank"
      }, /*#__PURE__*/React.createElement(FormattedMessage, messages.aiAutofillPricingDetails))
    }
  })))))) : readOnlyState;
};
export default CascadePolicy;
//# sourceMappingURL=CascadePolicy.js.map