"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FullScreenDrawerHeader = FullScreenDrawerHeader;
var _react = _interopRequireWildcard(require("react"));
var _button = require("../../button");
var _stepper = require("../../stepper");
var _truncateWithTooltip = require("../../truncate-with-tooltip");
var _useTranslation = require("../../hooks/use-translation");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function FullScreenDrawerHeader({
  children,
  onDismiss,
  title = '',
  activeStepKey,
  stepperTestId = 'header-section-stepper',
  steps,
  onStepClick,
  buttons,
  showUnsavedDataDialog = false,
  setShowUnsavedDataDialog,
  dismissWarningText,
  localizationText: localizationTextParams = {},
  unsavedDataDialogButtons
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  const localizationText = {
    cancelButton: t('Close'),
    keepDrawer: t('Continue setup'),
    closeWithoutSaving: t('Exit without saving'),
    ...localizationTextParams
  };
  const onContinueSetup = () => {
    setShowUnsavedDataDialog?.(false);
  };
  const cancelBtn = (0, _react.useMemo)(() => /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
    testId: "drawer-dismiss-button",
    onClick: onDismiss,
    accentType: _button.ACCENT_TYPES.GHOST,
    children: localizationText?.cancelButton
  }, "drawer-dismiss-button"), [onDismiss, localizationText?.cancelButton]);
  const buttonList = (0, _react.useMemo)(() => buttons ? [cancelBtn, ...buttons] : [cancelBtn], [buttons, cancelBtn]);
  const unsavedButtons = unsavedDataDialogButtons || [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
    testId: "continue-setup",
    className: "warning-button-continue",
    onClick: onContinueSetup,
    accentType: _button.ACCENT_TYPES.SECONDARY,
    children: localizationText?.keepDrawer
  }, "continue-setup"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
    testId: "exit-setup",
    onClick: onDismiss,
    className: "warning-button-exit",
    accentType: _button.ACCENT_TYPES.ATTENTION,
    children: localizationText?.closeWithoutSaving
  }, "exit-setup")];
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "full-screen-drawer-header-wrapper",
    "test-id": "full-screen-drawer-header",
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
      children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
        "test-id": "drawer-title",
        className: "drawer-title",
        children: title
      }), showUnsavedDataDialog ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        className: "dismiss-button-section",
        children: [dismissWarningText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_truncateWithTooltip.TruncateWithTooltip, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
            className: "dismiss-warning-text",
            children: dismissWarningText
          })
        }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: "dismiss-warning-dialog",
          children: unsavedButtons
        })]
      }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
        children: [children && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          "test-id": "custom-header-section",
          className: "custom-header",
          children: children
        }), steps && onStepClick && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: "header-section-stepper",
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_stepper.Stepper, {
            testId: stepperTestId,
            steps: steps,
            onClick: onStepClick,
            activeKey: activeStepKey
          })
        }), buttonList && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: "header-section-buttons",
          children: buttonList
        })]
      })]
    })
  });
}