"use client";
'use strict';

var chunkI2NZGVBG_js = require('./chunk-I2NZGVBG.js');
var react = require('react');
var client = require('@datatechsolutions/windsock/client');
var outline = require('@heroicons/react/24/outline');
var jsxRuntime = require('react/jsx-runtime');

function ImpersonationBanner({ onExit, className }) {
  const { isImpersonating, claim, exit } = client.useImpersonation();
  const [isExiting, setIsExiting] = react.useState(false);
  if (!isImpersonating || !claim) return null;
  const handleExit = async () => {
    setIsExiting(true);
    try {
      await exit();
      onExit?.();
    } finally {
      setIsExiting(false);
    }
  };
  return /* @__PURE__ */ jsxRuntime.jsxs(
    "div",
    {
      role: "status",
      "aria-live": "polite",
      className: "sticky top-0 z-50 flex items-center justify-between gap-3 border-b border-amber-300 bg-amber-100 px-4 py-2 text-sm text-amber-900 shadow-sm " + (className ?? ""),
      children: [
        /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
          /* @__PURE__ */ jsxRuntime.jsx(outline.EyeIcon, { "aria-hidden": "true", className: "h-5 w-5 shrink-0" }),
          /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
            "Impersonating session \u2014 signed in as the target user by",
            " ",
            /* @__PURE__ */ jsxRuntime.jsx("strong", { children: claim.email ?? claim.sub }),
            claim.reason ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
              " \xB7 ",
              /* @__PURE__ */ jsxRuntime.jsx("span", { className: "italic", children: claim.reason })
            ] }) : null
          ] })
        ] }),
        /* @__PURE__ */ jsxRuntime.jsxs(
          chunkI2NZGVBG_js.Button,
          {
            size: "sm",
            color: "ios-glass-red",
            onClick: handleExit,
            disabled: isExiting,
            "aria-label": "Exit impersonation",
            children: [
              /* @__PURE__ */ jsxRuntime.jsx(outline.XMarkIcon, { "aria-hidden": "true", className: "h-4 w-4" }),
              isExiting ? "Exiting\u2026" : "Exit impersonation"
            ]
          }
        )
      ]
    }
  );
}

exports.ImpersonationBanner = ImpersonationBanner;
//# sourceMappingURL=chunk-ZM5MVWIT.js.map
//# sourceMappingURL=chunk-ZM5MVWIT.js.map