import { Alert as d } from "./accelbyte-widgets123.mjs";
import { Button as u, ButtonType as y, ButtonStyle as g } from "./accelbyte-widgets107.mjs";
import { Dialog as C, DialogBody as E, DialogFooter as f } from "./accelbyte-widgets235.mjs";
import { t as K } from "./accelbyte-widgets58.mjs";
import { ItemImageTag as m } from "./accelbyte-widgets192.mjs";
import { AlertType as b } from "./accelbyte-widgets128.mjs";
import { ItemHelper as N } from "./accelbyte-widgets398.mjs";
import I from "./accelbyte-widgets261.mjs";
import r from "classnames";
import e from "react";
import D from "react-copy-to-clipboard";
import { Trans as a } from "react-i18next";
import t from "./accelbyte-widgets629.mjs";
class H extends e.Component {
  constructor(o) {
    super(o), this.state = {
      isCopied: !1
    };
  }
  render() {
    const { selectedProductKey: o, codeItems: l, onClose: n } = this.props, { isCopied: i } = this.state;
    if (!o || !l)
      return null;
    const s = l.filter((p) => p.itemId === o.itemId), c = N.getFilteredImageUrlByTag(s[0].images, m.productCover) || I;
    return /* @__PURE__ */ e.createElement(C, { title: K("ProductKeyDialog.title"), isOpen: !0 }, /* @__PURE__ */ e.createElement(E, null, /* @__PURE__ */ e.createElement("div", { className: r(t.productKeyDialog) }, o && /* @__PURE__ */ e.createElement(e.Fragment, null, i && /* @__PURE__ */ e.createElement(d, { className: t.alert, type: b.success, onDismiss: () => this.setState({ isCopied: !1 }) }, /* @__PURE__ */ e.createElement(a, { i18nKey: "ProductKeyDialog.alert.copied" }, "Your key has been copied.")), /* @__PURE__ */ e.createElement("div", { className: t.productInfoContainer }, /* @__PURE__ */ e.createElement("img", { src: c, alt: m.productCover, loading: "lazy" }), /* @__PURE__ */ e.createElement("div", { className: t.itemName }, o.name)), /* @__PURE__ */ e.createElement("div", { className: r(t.copyClipboard) }, /* @__PURE__ */ e.createElement("p", { className: t.productKey }, /* @__PURE__ */ e.createElement(a, { i18nKey: "ProductKeyDialog.label.productKey" }, "Product Key")), /* @__PURE__ */ e.createElement("div", { className: t.grantedKeyContainer }, /* @__PURE__ */ e.createElement("input", { readOnly: !0, type: "text", className: t.grantedKey, value: o.grantedCode || "" }), /* @__PURE__ */ e.createElement(D, { text: String(o.grantedCode) }, /* @__PURE__ */ e.createElement("button", { className: r("btn btn-primary", t.btnCopy), onClick: () => this.setState({ isCopied: !0 }) }, /* @__PURE__ */ e.createElement(a, { i18nKey: "ProductKeyDialog.button.copy" }, "Copy")))))))), /* @__PURE__ */ e.createElement(f, { className: t.dialogFooter }, /* @__PURE__ */ e.createElement(
      u,
      {
        className: r("btn big btn-ghost uppercase"),
        buttonType: y.TEXT,
        buttonStyle: g.NONE,
        onClick: n
      },
      /* @__PURE__ */ e.createElement(a, { i18nKey: "ProductKeyDialog.button.close" }, "Close")
    )));
  }
}
export {
  H as ProductKeyDialog
};
