import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import { useState, useEffect, useRef } from 'react';
import classnames from 'classnames';
import { globalProps, taxonomies } from '@bigbinary/neeto-commons-frontend/initializers';
import { showThumbsUpToastr } from '@bigbinary/neeto-commons-frontend/utils';
import Info from '@bigbinary/neeto-icons/Info';
import LeftArrow from '@bigbinary/neeto-icons/LeftArrow';
import { useProfileImageUpload } from '@bigbinary/neeto-image-uploader-frontend/hooks';
import Button from '@bigbinary/neetoui/Button';
import Typography from '@bigbinary/neetoui/Typography';
import Toastr from '@bigbinary/neetoui/Toastr';
import Callout from '@bigbinary/neetoui/Callout';
import Spinner from '@bigbinary/neetoui/Spinner';
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
import Form from '@bigbinary/neetoui/formik/Form';
import { pluck, not, isEmpty, head, reverse, groupBy, prop } from 'ramda';
import { useTranslation, Trans } from 'react-i18next';
import { S as ScrollToErrorField } from './index-BISwUwuE.js';
import { u as useCountries, a as ProfileImage } from './ProfileImage-OoIOAGCe.js';
import { u as useFetchRoles, a as useFetchGlobalRoles } from './useRolesApi-93OoRU1s.js';
import { u as useFetchMembers, c as useFetchMember, d as useCreateMember, e as useMembersCreationStatus, r as refetchMembers, f as useUpdateMember } from './useTeamsApi-DkgWqw-g.js';
import { n } from './inject-css-C2dztUxs.js';
import { useFormikContext } from 'formik';
import { toLabelAndValue, filterBy, findBy } from '@bigbinary/neeto-cist';
import Checkbox from '@bigbinary/neetoui/Checkbox';
import Tooltip from '@bigbinary/neetoui/Tooltip';
import Select from '@bigbinary/neetoui/formik/Select';
import Switch from '@bigbinary/neetoui/formik/Switch';
import { N as NEETO_AUTH_MANAGE_PRODUCT_URL, g as getSingleInvitationTranslationProps, a as getInviteURL, r as remainingExpiryDays, F as FORM_PAGES, b as FILTER_INVALID_EMAILS, C as COUNTER_PROPS, E as EMAIL_REGEX, D as DEFAULT_COMPONENT_CONFIG, M as MEMBERS_FORM_COMPONENT_MAPPER, c as buildValidationSchema, d as renderInitialValues, e as renderPayload, R as RolesRadioGroup } from './RolesRadioGroup-BusIs5tc.js';
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import { SINGULAR, PLURAL, LANGUAGE_OPTIONS } from '@bigbinary/neeto-commons-frontend/constants';
import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
import MenuHorizontal from '@bigbinary/neeto-icons/MenuHorizontal';
import CopyToClipboardButton from '@bigbinary/neeto-molecules/CopyToClipboardButton';
import Dropdown from '@bigbinary/neetoui/Dropdown';
import { u as useCreateInviteLinks, a as useRegenerateInviteLink, b as useFetchInviteLinks } from './useInviteLinksApi-gn-AP0Yx.js';
import Label from '@bigbinary/neetoui/Label';
import MultiEmailInput from '@bigbinary/neetoui/formik/MultiEmailInput';
import Input from '@bigbinary/neetoui/formik/Input';
import { isNeetoAuthApp } from './utils.js';
import { NeetoTimezoneSelector } from '@bigbinary/neeto-time-zones';
import { FormikPhoneNumberInput } from '@bigbinary/neeto-molecules/PhoneNumber';
import { T as TIME_FORMAT_OPTIONS, D as DATE_FORMAT_OPTIONS } from './constants-CXdiW8NZ.js';
import { g as getFilteredRoles } from './utils-3WlshQ9e.js';
import '@babel/runtime/helpers/toConsumableArray';
import './useCountriesApi-DK00167T.js';
import '@tanstack/react-query';
import 'axios';
import '@bigbinary/neeto-icons/Edit';
import '@bigbinary/neetoui/Avatar';
import 'i18next';
import 'yup';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'qs';
import './queryClient-Dsu-gu4Y.js';
import '@bigbinary/neetoui/formik/Radio';
import '@bigbinary/neetoui/Pane';
import '@bigbinary/neetoui/Modal';
import './_commonjsHelpers-BFTU3MAI.js';
import '@bigbinary/neeto-molecules/MoreDropdown';

var css = ".ntm-manage-members__header{align-items:flex-start;display:flex}.ntm-manage-members__header>*+*{margin-inline-start:.5rem}.ntm-product-roles-table th{color:rgb(var(--neeto-ui-gray-700));font-size:var(--neeto-ui-text-xs);font-weight:var(--neeto-ui-font-bold);text-transform:uppercase;vertical-align:middle}.ntm-product-roles-table td,.ntm-product-roles-table th{border:1px solid rgb(var(--neeto-ui-gray-200));padding:.5rem;text-align:start}.ntm-manage-members__app-roles{align-items:center;display:flex;justify-content:space-between;padding:.5rem 0;width:100%}.ntm-manage-members-app-roles__select-wrapper{max-width:250px;width:50%}.ntm-manage-members-effective-app-roles{align-items:center;display:flex;justify-content:space-between;padding:.25rem 0}.ntm-manage-members-effective-app-roles__role-name{max-width:300px;width:67%}.ntm-manage-members__checkbox-align-start.neeto-ui-checkbox__wrapper .neeto-ui-checkbox__container{align-items:flex-start}.ntm-manage-members__checkbox-align-start.neeto-ui-checkbox__wrapper .neeto-ui-checkbox[type=checkbox]{margin-top:.25rem}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL21hbmFnZS1tZW1iZXJzLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSw0QkFFRSxzQkFBdUIsQ0FEdkIsWUFFRixDQUVBLGdDQUNFLHlCQUNGLENBRUEsNEJBQ0UsbUNBQW9DLENBQ3BDLGlDQUFrQyxDQUVsQyxxQ0FBc0MsQ0FDdEMsd0JBQXlCLENBRnpCLHFCQUdGLENBRUEsd0RBRUUsOENBQStDLENBRS9DLGFBQWUsQ0FEZixnQkFFRixDQUVBLCtCQUVFLGtCQUFtQixDQURuQixZQUFhLENBRWIsNkJBQThCLENBRTlCLGVBQWlCLENBRGpCLFVBRUYsQ0FFQSw4Q0FFRSxlQUFnQixDQURoQixTQUVGLENBRUEsd0NBRUUsa0JBQW1CLENBRG5CLFlBQWEsQ0FFYiw2QkFBOEIsQ0FDOUIsZ0JBQ0YsQ0FFQSxtREFFRSxlQUFnQixDQURoQixTQUVGLENBRUEsbUdBQ0Usc0JBQ0YsQ0FFQSx1R0FDRSxpQkFDRiIsInNvdXJjZXNDb250ZW50IjpbIi5udG0tbWFuYWdlLW1lbWJlcnNfX2hlYWRlciB7XG4gIGRpc3BsYXk6IGZsZXg7XG4gIGFsaWduLWl0ZW1zOiBmbGV4LXN0YXJ0O1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzX19oZWFkZXIgPiAqICsgKiB7XG4gIG1hcmdpbi1pbmxpbmUtc3RhcnQ6IDAuNXJlbTtcbn1cblxuLm50bS1wcm9kdWN0LXJvbGVzLXRhYmxlIHRoIHtcbiAgY29sb3I6IHJnYih2YXIoLS1uZWV0by11aS1ncmF5LTcwMCkpO1xuICBmb250LXNpemU6IHZhcigtLW5lZXRvLXVpLXRleHQteHMpO1xuICB2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO1xuICBmb250LXdlaWdodDogdmFyKC0tbmVldG8tdWktZm9udC1ib2xkKTtcbiAgdGV4dC10cmFuc2Zvcm06IHVwcGVyY2FzZTtcbn1cblxuLm50bS1wcm9kdWN0LXJvbGVzLXRhYmxlIHRkLFxuLm50bS1wcm9kdWN0LXJvbGVzLXRhYmxlIHRoIHtcbiAgYm9yZGVyOiAxcHggc29saWQgcmdiKHZhcigtLW5lZXRvLXVpLWdyYXktMjAwKSk7XG4gIHRleHQtYWxpZ246IHN0YXJ0O1xuICBwYWRkaW5nOiAwLjVyZW07XG59XG5cbi5udG0tbWFuYWdlLW1lbWJlcnNfX2FwcC1yb2xlcyB7XG4gIGRpc3BsYXk6IGZsZXg7XG4gIGFsaWduLWl0ZW1zOiBjZW50ZXI7XG4gIGp1c3RpZnktY29udGVudDogc3BhY2UtYmV0d2VlbjtcbiAgd2lkdGg6IDEwMCU7XG4gIHBhZGRpbmc6IDAuNXJlbSAwO1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzLWFwcC1yb2xlc19fc2VsZWN0LXdyYXBwZXIge1xuICB3aWR0aDogNTAlO1xuICBtYXgtd2lkdGg6IDI1MHB4O1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzLWVmZmVjdGl2ZS1hcHAtcm9sZXMge1xuICBkaXNwbGF5OiBmbGV4O1xuICBhbGlnbi1pdGVtczogY2VudGVyO1xuICBqdXN0aWZ5LWNvbnRlbnQ6IHNwYWNlLWJldHdlZW47XG4gIHBhZGRpbmc6IDAuMjVyZW0gMDtcbn1cblxuLm50bS1tYW5hZ2UtbWVtYmVycy1lZmZlY3RpdmUtYXBwLXJvbGVzX19yb2xlLW5hbWUge1xuICB3aWR0aDogNjclO1xuICBtYXgtd2lkdGg6IDMwMHB4O1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzX19jaGVja2JveC1hbGlnbi1zdGFydC5uZWV0by11aS1jaGVja2JveF9fd3JhcHBlciAubmVldG8tdWktY2hlY2tib3hfX2NvbnRhaW5lciB7XG4gIGFsaWduLWl0ZW1zOiBmbGV4LXN0YXJ0O1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzX19jaGVja2JveC1hbGlnbi1zdGFydC5uZWV0by11aS1jaGVja2JveF9fd3JhcHBlciAubmVldG8tdWktY2hlY2tib3hbdHlwZT1cImNoZWNrYm94XCJdIHtcbiAgbWFyZ2luLXRvcDogMC4yNXJlbTtcbn1cbiJdfQ== */";
n(css,{});

var AppList = function AppList(_ref) {
  var _globalProps$user;
  var globalRoles = _ref.globalRoles,
    savedStateRef = _ref.savedStateRef;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(savedStateRef.current.isAppListEnabled),
    _useState2 = _slicedToArray(_useState, 2),
    isAppListEnabled = _useState2[0],
    setIsAppListEnabled = _useState2[1];
  var _useFormikContext = useFormikContext(),
    _useFormikContext$val = _useFormikContext.values,
    _useFormikContext$val2 = _useFormikContext$val.emails,
    emails = _useFormikContext$val2 === void 0 ? [] : _useFormikContext$val2,
    _useFormikContext$val3 = _useFormikContext$val.appRoles,
    appRoles = _useFormikContext$val3 === void 0 ? [] : _useFormikContext$val3,
    setFieldValue = _useFormikContext.setFieldValue;
  var selectedEmail = pluck("value", emails);
  var isManageProductsLinkEnabled = ((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.isOwner) && Object.keys(globalRoles).length >= 3;
  useEffect(function () {
    if (savedStateRef.current.isAppListEnabled !== isAppListEnabled) {
      appRoles === null || appRoles === void 0 || appRoles.forEach(function (appRole, index) {
        var _globalProps$appName;
        if ((appRole === null || appRole === void 0 ? void 0 : appRole.appName) === ((_globalProps$appName = globalProps.appName) === null || _globalProps$appName === void 0 ? void 0 : _globalProps$appName.substring(5))) {
          setFieldValue("appRoles[".concat(index, "].isEnabled"), true);
          return;
        }
        setFieldValue("appRoles[".concat(index, "].isEnabled"), isAppListEnabled);
      });
    }
    savedStateRef.current.isAppListEnabled = isAppListEnabled;
  }, [isAppListEnabled]); // eslint-disable-line react-hooks/exhaustive-deps

  var buildRoleOptions = function buildRoleOptions(roles) {
    return roles.map(function (role) {
      return toLabelAndValue(role.name);
    });
  };
  return /*#__PURE__*/jsxs("div", {
    className: "neeto-ui-flex neeto-ui-flex-col neeto-ui-gap-6",
    children: [/*#__PURE__*/jsxs("div", {
      className: "neeto-ui-w-full space-y-3",
      children: [/*#__PURE__*/jsx(Checkbox, {
        checked: isAppListEnabled,
        className: "ntm-manage-members__checkbox-align-start",
        "data-testid": "ntm-manage-members-app-list-checkbox",
        label: /*#__PURE__*/jsx(Typography, {
          component: "span",
          lineHeight: "relaxed",
          style: "body2",
          children: /*#__PURE__*/jsx(Trans, {
            i18nKey: "neetoTeamMembers.helpers.addMembersToNeetoProducts",
            values: {
              emails: selectedEmail
            }
          })
        }),
        onChange: function onChange() {
          return setIsAppListEnabled(not);
        }
      }), isManageProductsLinkEnabled && /*#__PURE__*/jsx(Typography, {
        style: "body2",
        children: /*#__PURE__*/jsx(Trans, {
          i18nKey: "neetoTeamMembers.helpers.manageProducts",
          components: {
            button: /*#__PURE__*/jsx(Button, {
              href: NEETO_AUTH_MANAGE_PRODUCT_URL,
              style: "link"
            })
          }
        })
      })]
    }), /*#__PURE__*/jsx("div", {
      className: "neeto-ui-w-full",
      children: appRoles.map(function (_ref2, index) {
        var _globalProps$appName2;
        var appName = _ref2.appName,
          isEnabled = _ref2.isEnabled;
        var isCurrentApp = appName === ((_globalProps$appName2 = globalProps.appName) === null || _globalProps$appName2 === void 0 ? void 0 : _globalProps$appName2.substring(5));
        var isAppRoleSelectionChecked = isCurrentApp || isEnabled;
        return /*#__PURE__*/jsxs("div", {
          className: "ntm-manage-members__app-roles",
          children: [/*#__PURE__*/jsx(Tooltip, {
            content: t("neetoTeamMembers.tooltips.hostAppIsRequired"),
            disabled: !isCurrentApp,
            position: "left",
            children: /*#__PURE__*/jsx("span", {
              children: /*#__PURE__*/jsx(Switch, {
                checked: isAppRoleSelectionChecked,
                disabled: isCurrentApp,
                name: "appsRoles[".concat(index, "].isEnabled"),
                label: t("neetoTeamMembers.labels.neeto_", {
                  product: appName
                }),
                onChange: function onChange(_ref3) {
                  var target = _ref3.target;
                  setFieldValue("appRoles[".concat(index, "].isEnabled"), target.checked);
                }
              })
            })
          }), /*#__PURE__*/jsx(Tooltip, {
            content: t("neetoTeamMembers.tooltips.goBackToChangeRole"),
            disabled: !isCurrentApp,
            position: "top",
            children: /*#__PURE__*/jsx("span", {
              className: "ntm-manage-members-app-roles__select-wrapper",
              children: /*#__PURE__*/jsx(Select, {
                dataTestid: "ntm-manage-members-app-roles",
                isDisabled: isCurrentApp || !isEnabled,
                name: "appRoles[".concat(index, "].activeRole"),
                options: buildRoleOptions(globalRoles[appName]),
                size: "small",
                strategy: "fixed",
                onChange: function onChange(_ref4) {
                  var value = _ref4.value;
                  setFieldValue("appRoles[".concat(index, "].activeRole"), value);
                }
              })
            })
          })]
        }, appName);
      })
    })]
  });
};

var Confirmation = function Confirmation() {
  var _globalProps$organiza;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useFormikContext = useFormikContext(),
    _useFormikContext$val = _useFormikContext.values,
    emails = _useFormikContext$val.emails,
    role = _useFormikContext$val.role,
    appRoles = _useFormikContext$val.appRoles;
  var selectedEmail = pluck("value", emails);
  var activeAppRoles = filterBy({
    isEnabled: true
  }, appRoles);
  return activeAppRoles.length > 1 ? /*#__PURE__*/jsxs("div", {
    className: "neeto-ui-flex neeto-ui-flex-col neeto-ui-gap-6",
    children: [/*#__PURE__*/jsx("div", {
      className: "neeto-ui-w-full",
      children: /*#__PURE__*/jsx(Typography, {
        component: "span",
        lineHeight: "relaxed",
        style: "body2",
        children: /*#__PURE__*/jsx(Trans, {
          i18nKey: "neetoTeamMembers.helpers.multipleProductInvitation",
          values: {
            count: selectedEmail.length,
            emails: selectedEmail,
            orgName: (_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.name
          }
        })
      })
    }), /*#__PURE__*/jsxs("table", {
      className: "neeto-ui-w-full ntm-product-roles-table",
      children: [/*#__PURE__*/jsx("thead", {
        children: /*#__PURE__*/jsxs("tr", {
          children: [/*#__PURE__*/jsx("th", {
            children: t("neetoTeamMembers.common.productName")
          }), /*#__PURE__*/jsx("th", {
            children: t("neetoTeamMembers.common.role", SINGULAR)
          })]
        })
      }), /*#__PURE__*/jsx("tbody", {
        children: activeAppRoles.map(function (_ref) {
          var appName = _ref.appName,
            activeRole = _ref.activeRole;
          return /*#__PURE__*/jsxs("tr", {
            children: [/*#__PURE__*/jsx("td", {
              children: /*#__PURE__*/jsx(Typography, {
                component: "span",
                lineHeight: "relaxed",
                style: "body2",
                children: t("neetoTeamMembers.labels.neeto_", {
                  product: appName
                })
              })
            }), /*#__PURE__*/jsx("td", {
              children: /*#__PURE__*/jsx(Typography, {
                component: "span",
                lineHeight: "relaxed",
                style: "body2",
                children: activeRole
              })
            })]
          }, appName);
        })
      })]
    })]
  }) : /*#__PURE__*/jsx(Typography, {
    component: "span",
    lineHeight: "relaxed",
    style: "body2",
    children: /*#__PURE__*/jsx(Trans, {
      i18nKey: "neetoTeamMembers.helpers.singleProductInvitation",
      values: getSingleInvitationTranslationProps({
        activeAppRoles: activeAppRoles,
        role: role,
        selectedEmail: selectedEmail
      })
    })
  });
};

var Menu = Dropdown.Menu,
  MenuItem = Dropdown.MenuItem;
var MenuItemButton = MenuItem.Button;
var InviteLink$1 = function InviteLink(_ref) {
  var _inviteLinks$, _inviteLinks$2, _inviteLinks$3, _inviteLinks$4, _inviteLinks$5, _inviteLinks$6;
  var t = _ref.t,
    roles = _ref.roles;
  var _useCreateInviteLinks = useCreateInviteLinks(),
    createInviteLink = _useCreateInviteLinks.mutate,
    isCreateLinkPending = _useCreateInviteLinks.isPending;
  var _useRegenerateInviteL = useRegenerateInviteLink(),
    regenerateLink = _useRegenerateInviteL.mutate;
  var _useFetchInviteLinks = useFetchInviteLinks(),
    _useFetchInviteLinks$ = _useFetchInviteLinks.data,
    _useFetchInviteLinks$2 = _useFetchInviteLinks$ === void 0 ? {} : _useFetchInviteLinks$,
    _useFetchInviteLinks$3 = _useFetchInviteLinks$2.inviteLinks,
    inviteLinks = _useFetchInviteLinks$3 === void 0 ? [] : _useFetchInviteLinks$3,
    isFetchLinkLoading = _useFetchInviteLinks.isLoading;
  var _useFormikContext = useFormikContext(),
    values = _useFormikContext.values;
  var isInviteLinkEmpty = !isFetchLinkLoading && isEmpty(inviteLinks);
  var handleRegenerate = function handleRegenerate() {
    var _findBy = findBy({
        name: values.role
      }, roles),
      roleId = _findBy.id;
    if (isEmpty(inviteLinks)) {
      createInviteLink({
        organizationRoleId: roleId
      });
      return;
    }
    regenerateLink({
      inviteLinkId: inviteLinks[0].id,
      payload: {
        organizationRoleId: roleId
      }
    });
  };
  if (isFetchLinkLoading || isCreateLinkPending) {
    return /*#__PURE__*/jsx("div", {
      className: "neeto-ui-w-full flex justify-center items-center",
      children: /*#__PURE__*/jsx(Spinner, {
        size: "large"
      })
    });
  }
  return /*#__PURE__*/jsxs("div", {
    className: "neeto-ui-w-full space-y-2",
    children: [/*#__PURE__*/jsxs("div", {
      className: "flex items-center gap-2 pt-1",
      children: [/*#__PURE__*/jsxs("div", {
        className: "neeto-ui-rounded-md neeto-ui-border-gray-300 neeto-ui-bg-gray-50 relative flex min-w-0 grow items-center truncate border leading-none",
        children: [/*#__PURE__*/jsx("div", {
          className: "relative min-w-0 grow truncate p-2 leading-none",
          children: !isInviteLinkEmpty && getInviteURL(inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$ = inviteLinks[0]) === null || _inviteLinks$ === void 0 ? void 0 : _inviteLinks$.token)
        }), isInviteLinkEmpty ? /*#__PURE__*/jsx(Button, {
          className: "rounded-ss-none rounded-es-none",
          label: t("neetoTeamMembers.buttons.generateLink"),
          onClick: handleRegenerate
        }) : /*#__PURE__*/jsx(CopyToClipboardButton, {
          className: "rounded-ss-none rounded-es-none",
          label: t("neetoTeamMembers.buttons.copyLink"),
          value: getInviteURL(inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$2 = inviteLinks[0]) === null || _inviteLinks$2 === void 0 ? void 0 : _inviteLinks$2.token)
        })]
      }), !isInviteLinkEmpty && /*#__PURE__*/jsx(Dropdown, {
        buttonProps: {
          className: "shrink-0"
        },
        buttonStyle: "text",
        icon: MenuHorizontal,
        children: /*#__PURE__*/jsx(Menu, {
          children: /*#__PURE__*/jsx(MenuItem, {
            children: /*#__PURE__*/jsx(MenuItemButton, {
              onClick: handleRegenerate,
              children: t("neetoTeamMembers.buttons.regenerateLink")
            })
          })
        })
      })]
    }), /*#__PURE__*/jsx("div", {
      children: !isInviteLinkEmpty && /*#__PURE__*/jsx(Typography, {
        className: "leading-relaxed neeto-ui-text-gray-500",
        style: "body3",
        children: /*#__PURE__*/jsx(Trans, {
          components: {
            strong: /*#__PURE__*/jsx("strong", {})
          },
          i18nKey: "neetoTeamMembers.alerts.messages.inviteLink",
          values: {
            expiryDays: remainingExpiryDays(inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$3 = inviteLinks[0]) === null || _inviteLinks$3 === void 0 ? void 0 : _inviteLinks$3.expiresAt),
            role: inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$4 = inviteLinks[0]) === null || _inviteLinks$4 === void 0 || (_inviteLinks$4 = _inviteLinks$4.organizationRole) === null || _inviteLinks$4 === void 0 ? void 0 : _inviteLinks$4.name,
            inviteLimit: inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$5 = inviteLinks[0]) === null || _inviteLinks$5 === void 0 ? void 0 : _inviteLinks$5.inviteLimit,
            appName: globalProps.appName,
            emailDomain: inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$6 = inviteLinks[0]) === null || _inviteLinks$6 === void 0 ? void 0 : _inviteLinks$6.domain
          }
        })
      })
    })]
  });
};
var InviteLink = withT(InviteLink$1);

var MultipleEmailInput = function MultipleEmailInput(_ref) {
  var _head;
  var _ref$emails = _ref.emails,
    emails = _ref$emails === void 0 ? [] : _ref$emails,
    innerRef = _ref.innerRef,
    _ref$selectedMember = _ref.selectedMember,
    selectedMember = _ref$selectedMember === void 0 ? null : _ref$selectedMember,
    setCurrentPage = _ref.setCurrentPage;
  var isInviteLinkFeatureEnabled = !isNeetoAuthApp();
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useFormikContext = useFormikContext(),
    setFieldValue = _useFormikContext.setFieldValue;
  var handleInputChange = function handleInputChange(event) {
    var email = event.target.value;
    var emailList = [{
      label: email,
      value: email,
      valid: EMAIL_REGEX.test(email)
    }];
    setFieldValue("emails", emailList);
  };
  return /*#__PURE__*/jsx("div", {
    className: "neeto-ui-w-full",
    children: selectedMember ? /*#__PURE__*/jsx(Input, {
      "data-testid": "ntm-manage-member-email-input",
      name: "emails",
      size: "medium",
      type: "email",
      value: (_head = head(emails)) === null || _head === void 0 ? void 0 : _head.value,
      label: /*#__PURE__*/jsx("span", {
        className: "neeto-ui-w-full neeto-ui-flex neeto-ui-justify-between",
        children: /*#__PURE__*/jsx(Typography, {
          component: "span",
          style: "body2",
          children: t("neetoTeamMembers.common.email", SINGULAR)
        })
      }),
      onChange: handleInputChange
    }) : /*#__PURE__*/jsxs("div", {
      children: [/*#__PURE__*/jsxs("div", {
        className: "flex items-center justify-between pb-2",
        children: [/*#__PURE__*/jsx(Label, {
          required: true,
          children: t("neetoTeamMembers.common.email", PLURAL)
        }), isInviteLinkFeatureEnabled && /*#__PURE__*/jsx(Button, {
          label: t("neetoTeamMembers.buttons.inviteLink"),
          style: "link",
          onClick: function onClick() {
            return setCurrentPage(FORM_PAGES.INVITE_LINK);
          }
        })]
      }), /*#__PURE__*/jsx(MultiEmailInput, {
        required: true,
        counter: COUNTER_PROPS,
        "data-testid": "ntm-manage-member-email-input",
        filterInvalidEmails: FILTER_INVALID_EMAILS,
        helpText: t("neetoTeamMembers.helpers.enterMultipleEmails"),
        label: "",
        name: "emails",
        placeholder: t("neetoTeamMembers.placeholders.email"),
        ref: innerRef
      })]
    })
  });
};

var NameInputs = withT(function (_ref) {
  var t = _ref.t,
    innerRef = _ref.innerRef;
  return /*#__PURE__*/jsxs("div", {
    className: "neeto-ui-flex neeto-ui-w-full neeto-ui-gap-4 pt-4 border-t mt-0 neeto-ui-border-gray-200",
    children: [/*#__PURE__*/jsx(Input, {
      "data-testid": "ntm-edit-member-first-name-text-field",
      label: t("neetoTeamMembers.labels.firstName"),
      name: "firstName",
      ref: innerRef
    }), /*#__PURE__*/jsx(Input, {
      "data-testid": "ntm-edit-member-last-name-text-field",
      label: t("neetoTeamMembers.labels.lastName"),
      name: "lastName"
    })]
  });
});

var ProfileSettings = function ProfileSettings(_ref) {
  var member = _ref.member,
    setFieldValue = _ref.setFieldValue,
    isTimezoneFieldDisabled = _ref.isTimezoneFieldDisabled;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var setFieldValueRef = useRef(setFieldValue);
  useEffect(function () {
    setFieldValueRef.current = setFieldValue;
  }, [setFieldValue]);
  var _useCountries = useCountries(),
    countryDropdownOptions = _useCountries.countryDropdownOptions,
    selectedCountryOption = _useCountries.selectedCountryOption,
    isFetchingCountriesList = _useCountries.isFetchingCountriesList,
    handleCountryChange = _useCountries.handleCountryChange;
  var timezoneContainerRef = useRef(null);
  useEffect(function () {
    var node = timezoneContainerRef.current;
    if (!node) return undefined;
    new NeetoTimezoneSelector(node, {
      isTimeFormat24H: member.timeFormat === "24h",
      className: "w-full z-10",
      position: "bottom",
      initialValue: member.timeZone,
      onChange: function onChange(_ref2) {
        var main = _ref2.main;
        return setFieldValueRef.current("timeZone", main);
      },
      disabled: isTimezoneFieldDisabled
    });
    return function () {
      node.innerHTML = "";
    };
  }, [member.timeZone, member.timeFormat, isTimezoneFieldDisabled]);
  useEffect(function () {
    var country = findBy({
      value: member.countryIdentifier
    }, countryDropdownOptions);
    if (country) handleCountryChange(country);
  }, [member.countryIdentifier, countryDropdownOptions, handleCountryChange]);
  return /*#__PURE__*/jsxs("div", {
    className: "w-full space-y-4",
    "data-cy": "ntm-profile-settings",
    children: [/*#__PURE__*/jsx(FormikPhoneNumberInput, {
      "data-cy": "ntm-edit-member-phonenumber-field",
      label: t("neetoTeamMembers.profile.inputs.label.phonenumber"),
      name: "phonenumber"
    }), /*#__PURE__*/jsx(Select, {
      "data-cy": "ntm-edit-member-country-select",
      isLoading: isFetchingCountriesList,
      label: t("neetoTeamMembers.profile.inputs.label.country"),
      name: "countryId",
      options: countryDropdownOptions,
      value: selectedCountryOption,
      onChange: function onChange(option) {
        var dependentFields = handleCountryChange(option);
        setFieldValue("dateFormat", dependentFields === null || dependentFields === void 0 ? void 0 : dependentFields.dateFormat);
        setFieldValue("countryId", option === null || option === void 0 ? void 0 : option.value);
      }
    }), /*#__PURE__*/jsx(Select, {
      "data-cy": "ntm-edit-member-language-select",
      label: t("neetoTeamMembers.profile.inputs.label.language"),
      name: "language",
      options: LANGUAGE_OPTIONS,
      onChange: function onChange(option) {
        return setFieldValue("language", option.value);
      }
    }), /*#__PURE__*/jsxs("div", {
      className: "space-y-2",
      children: [/*#__PURE__*/jsx(Label, {
        children: t("neetoTeamMembers.profile.inputs.label.timeZone")
      }), /*#__PURE__*/jsx("div", {
        "data-cy": "ntm-edit-member-timezone-select",
        ref: timezoneContainerRef,
        className: classnames("w-full grow", {
          "neeto-ui-bg-gray-100 pointer-events-none": isTimezoneFieldDisabled
        })
      })]
    }), /*#__PURE__*/jsx(Select, {
      "data-cy": "ntm-edit-member-time-format-select",
      label: t("neetoTeamMembers.profile.inputs.label.preferredTimeFormat"),
      name: "timeFormat",
      options: TIME_FORMAT_OPTIONS,
      onChange: function onChange(option) {
        return setFieldValue("timeFormat", option.value);
      }
    }), /*#__PURE__*/jsx(Select, {
      "data-cy": "ntm-edit-member-date-format-select",
      label: t("neetoTeamMembers.profile.inputs.label.preferredDateFormat"),
      name: "dateFormat",
      options: DATE_FORMAT_OPTIONS,
      onChange: function onChange(option) {
        return setFieldValue("dateFormat", option.value);
      }
    })]
  });
};

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var ManageMember = function ManageMember(_ref) {
  var _manageMemberComponen, _config$additionalFie2;
  var config = _ref.config,
    onComplete = _ref.onComplete,
    _ref$roles = _ref.roles,
    roles = _ref$roles === void 0 ? [] : _ref$roles,
    _ref$selectedMember = _ref.selectedMember,
    selectedMember = _ref$selectedMember === void 0 ? null : _ref$selectedMember,
    _ref$componentConfig = _ref.componentConfig,
    componentConfig = _ref$componentConfig === void 0 ? {} : _ref$componentConfig;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isCreationStatusPollingEnabled = _useState2[0],
    setIsCreationStatusPollingEnabled = _useState2[1];
  var isViewPermissionGranted = config.permissions.view;
  var isNotDevelopment = globalProps.railsEnv !== "development";
  var _useFetchMembers = useFetchMembers({
      enabled: isViewPermissionGranted
    }),
    team = _useFetchMembers.data;
  var _useFetchMember = useFetchMember(selectedMember === null || selectedMember === void 0 ? void 0 : selectedMember.id, {
      enabled: !!selectedMember
    }),
    memberShowData = _useFetchMember.data,
    isMemberDetailLoading = _useFetchMember.isLoading;
  var isTimezoneFieldDisabled = selectedMember && memberShowData && !selectedMember.isOwner && !memberShowData.timezoneChangeEnabled;
  var _useState3 = useState(FORM_PAGES.MAIN),
    _useState4 = _slicedToArray(_useState3, 2),
    currentPage = _useState4[0],
    setCurrentPage = _useState4[1];
  var formReference = useRef(null);
  var inputReference = useRef(null);
  var appListSavedStateReference = useRef({
    isAppListEnabled: true
  });
  var shouldSkipAppListPage = useRef(false);
  var formikValues = useRef(null);
  var manageMemberComponentConfig = _objectSpread(_objectSpread({}, DEFAULT_COMPONENT_CONFIG), {}, {
    initialFocusRef: inputReference
  }, componentConfig);
  var Component = MEMBERS_FORM_COMPONENT_MAPPER[manageMemberComponentConfig.type || "pane"];
  var haveToFetchRoles = isEmpty(roles) && isViewPermissionGranted;
  var isEditForm = !!selectedMember;
  var isLastPage = currentPage === FORM_PAGES.CONFIRMATION || isEditForm;
  var _useFetchRoles = useFetchRoles({
      select: function select(response) {
        var _response$organizatio;
        return reverse((_response$organizatio = response.organizationRoles) !== null && _response$organizatio !== void 0 ? _response$organizatio : []);
      },
      enabled: haveToFetchRoles
    }),
    _useFetchRoles$data = _useFetchRoles.data,
    rolesList = _useFetchRoles$data === void 0 ? roles : _useFetchRoles$data,
    isRolesLoading = _useFetchRoles.isLoading;
  var _useFetchGlobalRoles = useFetchGlobalRoles({
      select: function select(response) {
        return groupBy(prop("appName"), response !== null && response !== void 0 ? response : []);
      },
      enabled: isNotDevelopment && !selectedMember && isViewPermissionGranted
    }),
    _useFetchGlobalRoles$ = _useFetchGlobalRoles.data,
    globalRoles = _useFetchGlobalRoles$ === void 0 ? {} : _useFetchGlobalRoles$,
    isGlobalRolesLoading = _useFetchGlobalRoles.isLoading;
  var filteredRoles = getFilteredRoles(rolesList, config);
  var _useCreateMember = useCreateMember({
      onSuccess: function onSuccess() {
        return setIsCreationStatusPollingEnabled(true);
      }
    }),
    _useCreateMember$data = _useCreateMember.data,
    _useCreateMember$data2 = _useCreateMember$data === void 0 ? {} : _useCreateMember$data,
    jobId = _useCreateMember$data2.jobId,
    createMember = _useCreateMember.mutate,
    isCreatingMember = _useCreateMember.isPending;
  var refetchInterval = function refetchInterval(query) {
    var _ref2 = query.state.data || {},
      isCompleted = _ref2.isCompleted;
    if (isCompleted) {
      setIsCreationStatusPollingEnabled(false);
      return false;
    }
    return 2000;
  };
  var _useMembersCreationSt = useMembersCreationStatus(jobId, {
      refetchInterval: refetchInterval,
      enabled: isCreationStatusPollingEnabled
    }),
    creationStatus = _useMembersCreationSt.data;
  useEffect(function () {
    var _config$createMember;
    var _ref3 = creationStatus || {},
      isCompleted = _ref3.isCompleted,
      isSuccessful = _ref3.isSuccessful,
      users = _ref3.users,
      error = _ref3.error;
    if (!isCompleted) return;
    handleClose();
    config === null || config === void 0 || (_config$createMember = config.createMember) === null || _config$createMember === void 0 || (_config$createMember = _config$createMember.onSuccess) === null || _config$createMember === void 0 || _config$createMember.callback({
      users: users
    });
    if (isSuccessful) {
      showThumbsUpToastr();
    } else {
      Toastr.error(error);
    }
    refetchMembers();
  }, [creationStatus]);
  var _useUpdateMember = useUpdateMember({
      onSuccess: function onSuccess() {
        var _config$updateMember, _globalProps$user;
        handleClose(true);
        config === null || config === void 0 || (_config$updateMember = config.updateMember) === null || _config$updateMember === void 0 || (_config$updateMember = _config$updateMember.onSuccess) === null || _config$updateMember === void 0 || _config$updateMember.callback();
        if ((selectedMember === null || selectedMember === void 0 ? void 0 : selectedMember.id) === ((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id)) {
          window.location.reload();
        }
      }
    }),
    updateMember = _useUpdateMember.mutate,
    isUpdatingMember = _useUpdateMember.isPending;
  var hasRoleChanged = function hasRoleChanged(_ref4) {
    var submitted = _ref4.submitted,
      values = _ref4.values;
    return submitted && (values === null || values === void 0 ? void 0 : values.role) !== (selectedMember === null || selectedMember === void 0 ? void 0 : selectedMember.role);
  };
  var handleClose = function handleClose() {
    var submitted = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
    onComplete({
      submitted: hasRoleChanged({
        submitted: submitted,
        values: formikValues.current
      })
    });
    setCurrentPage(FORM_PAGES.MAIN);
    appListSavedStateReference.current = {
      isAppListEnabled: true
    };
    setIsCreationStatusPollingEnabled(false);
  };
  var _useProfileImageUploa = useProfileImageUpload({
      uploadConfig: {
        folder: "Auth",
        customMetadata: {
          appName: "neetoAuth"
        }
      }
    }),
    uploadImage = _useProfileImageUploa.uploadImage,
    isUploading = _useProfileImageUploa.isUploading;
  var handleUploadImage = /*#__PURE__*/function () {
    var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
      var result, didUpload;
      return _regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            didUpload = false;
            _context.next = 3;
            return uploadImage(image, function (uploadedImageData) {
              didUpload = true;
              result = uploadedImageData;
            });
          case 3:
            if (didUpload) {
              _context.next = 5;
              break;
            }
            throw new Error(t("neetoTeamMembers.common.imageUploadFailed"));
          case 5:
            return _context.abrupt("return", result);
          case 6:
          case "end":
            return _context.stop();
        }
      }, _callee);
    }));
    return function handleUploadImage(_x) {
      return _ref5.apply(this, arguments);
    };
  }();
  var isProcessing = isCreatingMember || isUpdatingMember || isUploading || isRolesLoading || isGlobalRolesLoading || isMemberDetailLoading;
  var handleAddMember = /*#__PURE__*/function () {
    var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(values) {
      var _values$avatar, payload, _yield$handleUploadIm, fileId, filePath, url;
      return _regeneratorRuntime.wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            if (!selectedMember) {
              _context2.next = 25;
              break;
            }
            payload = renderPayload(values, selectedMember);
            if (!((_values$avatar = values.avatar) !== null && _values$avatar !== void 0 && _values$avatar.file)) {
              _context2.next = 22;
              break;
            }
            if (!payload.profile) payload.profile = {};
            if (!(values.avatar.file === "_destroy")) {
              _context2.next = 8;
              break;
            }
            payload.profile.avatar = {
              fileId: "_destroy",
              filePath: "",
              url: ""
            };
            _context2.next = 22;
            break;
          case 8:
            _context2.prev = 8;
            _context2.next = 11;
            return handleUploadImage(values.avatar.file);
          case 11:
            _yield$handleUploadIm = _context2.sent;
            fileId = _yield$handleUploadIm.fileId;
            filePath = _yield$handleUploadIm.filePath;
            url = _yield$handleUploadIm.url;
            payload.profile.avatar = {
              fileId: fileId,
              filePath: filePath,
              url: url
            };
            _context2.next = 22;
            break;
          case 18:
            _context2.prev = 18;
            _context2.t0 = _context2["catch"](8);
            Toastr.error(_context2.t0.message);
            return _context2.abrupt("return");
          case 22:
            updateMember({
              id: selectedMember.id,
              payload: payload
            });
            _context2.next = 26;
            break;
          case 25:
            createMember(renderPayload(values));
          case 26:
          case "end":
            return _context2.stop();
        }
      }, _callee2, null, [[8, 18]]);
    }));
    return function handleAddMember(_x2) {
      return _ref6.apply(this, arguments);
    };
  }();
  var handleOnSubmit = /*#__PURE__*/function () {
    var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(values, _ref7) {
      var setSubmitting;
      return _regeneratorRuntime.wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            setSubmitting = _ref7.setSubmitting;
            shouldSkipAppListPage.current = isEmpty(values.appRoles);
            if (!isLastPage) {
              _context3.next = 7;
              break;
            }
            _context3.next = 5;
            return handleAddMember(values);
          case 5:
            _context3.next = 8;
            break;
          case 7:
            if (currentPage === FORM_PAGES.APP_LIST || shouldSkipAppListPage.current) {
              setCurrentPage(FORM_PAGES.CONFIRMATION);
              setSubmitting(false);
            } else if (currentPage === FORM_PAGES.MAIN) {
              setCurrentPage(FORM_PAGES.APP_LIST);
              setSubmitting(false);
            }
          case 8:
          case "end":
            return _context3.stop();
        }
      }, _callee3);
    }));
    return function handleOnSubmit(_x3, _x4) {
      return _ref8.apply(this, arguments);
    };
  }();
  var handleBackButton = function handleBackButton() {
    if (currentPage === FORM_PAGES.APP_LIST || shouldSkipAppListPage.current || currentPage === FORM_PAGES.INVITE_LINK) {
      setCurrentPage(FORM_PAGES.MAIN);
    } else if (currentPage === FORM_PAGES.CONFIRMATION) {
      setCurrentPage(FORM_PAGES.APP_LIST);
    }
  };
  var getTitle = function getTitle() {
    var memberLabel = taxonomies.member.singular;
    if (selectedMember) {
      return t("neetoTeamMembers.common.edit_", {
        what: memberLabel
      });
    }
    return currentPage === FORM_PAGES.INVITE_LINK ? t("neetoTeamMembers.common.inviteViaLink") : t("neetoTeamMembers.common.addNew_", {
      what: memberLabel
    });
  };
  var renderRolesRadioGroup = function renderRolesRadioGroup(role) {
    return /*#__PURE__*/jsx("div", {
      className: "pt-4 border-t neeto-ui-border-gray-200 w-full",
      children: /*#__PURE__*/jsx(RolesRadioGroup, {
        config: config,
        globalRoles: globalRoles,
        role: role,
        isEdit: !!selectedMember,
        roles: filteredRoles
      })
    });
  };
  var renderFormPage = function renderFormPage(page, emails, role, setFieldValue) {
    var _memberShowData$membe, _memberShowData$membe2, _config$additionalFie;
    switch (page) {
      case FORM_PAGES.MAIN:
        return /*#__PURE__*/jsxs(Fragment, {
          children: [selectedMember && /*#__PURE__*/jsx(ProfileImage, {}), selectedMember && /*#__PURE__*/jsx(NameInputs, {
            innerRef: inputReference
          }), /*#__PURE__*/jsx(MultipleEmailInput, {
            emails: emails,
            selectedMember: selectedMember,
            setCurrentPage: setCurrentPage,
            innerRef: inputReference
          }), selectedMember && /*#__PURE__*/jsx(ProfileSettings, {
            isTimezoneFieldDisabled: isTimezoneFieldDisabled,
            setFieldValue: setFieldValue,
            member: _objectSpread(_objectSpread({}, selectedMember), {}, {
              countryIdentifier: (_memberShowData$membe = memberShowData === null || memberShowData === void 0 || (_memberShowData$membe2 = memberShowData.member) === null || _memberShowData$membe2 === void 0 ? void 0 : _memberShowData$membe2.countryIdentifier) !== null && _memberShowData$membe !== void 0 ? _memberShowData$membe : selectedMember.countryIdentifier
            })
          }), renderRolesRadioGroup(role), (_config$additionalFie = config.additionalFields) === null || _config$additionalFie === void 0 ? void 0 : _config$additionalFie.component]
        });
      case FORM_PAGES.APP_LIST:
        return /*#__PURE__*/jsx(AppList, {
          globalRoles: globalRoles,
          savedStateRef: appListSavedStateReference
        });
      case FORM_PAGES.CONFIRMATION:
        return /*#__PURE__*/jsx(Confirmation, {});
      case FORM_PAGES.INVITE_LINK:
        return /*#__PURE__*/jsxs(Fragment, {
          children: [/*#__PURE__*/jsx(InviteLink, {
            roles: filteredRoles
          }), renderRolesRadioGroup(role)]
        });
      default:
        return null;
    }
  };
  return /*#__PURE__*/jsxs(Component, {
    className: manageMemberComponentConfig.className,
    "data-testid": "ntm-manage-members-pane-wrapper",
    initialFocusRef: manageMemberComponentConfig.initialFocusRef,
    isOpen: manageMemberComponentConfig.isOpen,
    onClose: function onClose() {
      return handleClose(false);
    },
    children: [/*#__PURE__*/jsxs(Component.Header, _objectSpread(_objectSpread({}, manageMemberComponentConfig.headerProps), {}, {
      className: classnames([{
        "ntm-manage-members__header": currentPage !== FORM_PAGES.MAIN
      }, (_manageMemberComponen = manageMemberComponentConfig.headerProps) === null || _manageMemberComponen === void 0 ? void 0 : _manageMemberComponen.className]),
      children: [currentPage !== FORM_PAGES.MAIN && /*#__PURE__*/jsx(Button, {
        "aria-label": "Back",
        icon: LeftArrow,
        size: "medium",
        style: "text",
        tooltipProps: {
          content: t("neetoTeamMembers.buttons.back"),
          position: "bottom"
        },
        onClick: handleBackButton
      }), /*#__PURE__*/jsx(Typography, {
        className: "ntm-members-form__header",
        "data-testid": "ntm-manage-members-pane-header",
        style: "h2",
        weight: "semibold",
        children: getTitle()
      }), selectedMember && /*#__PURE__*/jsx(Typography, {
        className: "neeto-ui-text-gray-600",
        style: "body2",
        children: t("neetoTeamMembers.helpers.editPaneSubtitle")
      })]
    })), /*#__PURE__*/jsx(Form, {
      ref: formReference,
      formikProps: {
        enableReinitialize: true,
        initialValues: renderInitialValues({
          additionalFieldsInitialValues: (_config$additionalFie2 = config.additionalFields) === null || _config$additionalFie2 === void 0 ? void 0 : _config$additionalFie2.initialValues,
          globalRoles: globalRoles,
          memberShowData: memberShowData,
          roles: filteredRoles,
          selectedMember: selectedMember
        }),
        onSubmit: handleOnSubmit,
        validationSchema: buildValidationSchema(_objectSpread({
          selectedMember: selectedMember
        }, team))
      },
      children: function children(_ref9) {
        var _manageMemberComponen2, _manageMemberComponen3;
        var values = _ref9.values,
          isValid = _ref9.isValid,
          dirty = _ref9.dirty,
          setFieldValue = _ref9.setFieldValue;
        var emails = values.emails,
          role = values.role;
        formikValues.current = values;
        return /*#__PURE__*/jsxs(Fragment, {
          children: [/*#__PURE__*/jsx(ScrollToErrorField, {
            formRef: formReference
          }), /*#__PURE__*/jsxs(Component.Body, _objectSpread(_objectSpread({}, manageMemberComponentConfig.bodyProps), {}, {
            className: classnames(["ntm-members-form__body", (_manageMemberComponen2 = manageMemberComponentConfig.bodyProps) === null || _manageMemberComponen2 === void 0 ? void 0 : _manageMemberComponen2.className]),
            children: [isCreationStatusPollingEnabled && /*#__PURE__*/jsxs(Callout, {
              className: "w-full",
              icon: Info,
              style: "info",
              children: [/*#__PURE__*/jsx(Spinner, {
                size: "small"
              }), t("neetoTeamMembers.helpers.memberCreationStatus", {
                count: emails.length
              })]
            }), renderFormPage(currentPage, emails, role, setFieldValue)]
          })), currentPage !== FORM_PAGES.INVITE_LINK && /*#__PURE__*/jsx(Component.Footer, _objectSpread(_objectSpread({}, manageMemberComponentConfig.footerProps), {}, {
            className: classnames(["ntm-members-form__footer", (_manageMemberComponen3 = manageMemberComponentConfig.footerProps) === null || _manageMemberComponen3 === void 0 ? void 0 : _manageMemberComponen3.className]),
            children: /*#__PURE__*/jsx(ActionBlock, {
              cancelButtonProps: {
                "data-testid": "ntm-manage-member-cancel-button",
                onClick: function onClick() {
                  return handleClose(false);
                }
              },
              isSubmitting: isProcessing || isCreationStatusPollingEnabled,
              submitButtonProps: {
                "data-testid": isLastPage ? "ntm-manage-member-submit-button" : "ntm-manage-member-continue-button",
                label: isLastPage ? t("neetoTeamMembers.buttons.saveChanges") : t("neetoTeamMembers.buttons.continue"),
                disabled: !isValid || isProcessing || !dirty || isCreationStatusPollingEnabled
              }
            })
          }))]
        });
      }
    })]
  });
};

export { ManageMember as default };
//# sourceMappingURL=ManageMember.js.map
