import { c as nt, p as St, h as ct, f as h, i as T, r as f, b as v, d as it, u as lt, s as X, k as $t, e as At, a as Z, t as H, n as zt, o as Rt } from "./AssetItem-BxjLUzNd.js";
import { t as ot, J as vt, L as Tt, w as n, x as c, z as _, C as r, y as w, r as ut, l as Pt, A as tt, Q as et, p as M, E as t, v as jt, I as Ot, V as Ct, M as Et } from "./index-BBXAtvZr.js";
import { e as at, i as st } from "./each-D1jTQ_vC.js";
function rt(I, u, d, $) {
  if (d === "sui")
    return `https://suiscan.xyz/${$}/tx/${u}`;
  switch (String(I.chainId)) {
    case "137":
      return `https://polygonscan.com/tx/${u}`;
    case "88888":
      return `https://chiliscan.com/tx/${u}`;
    case "43114":
      return `https://subnets.avax.network/c-chain/tx/${u}`;
    case "80002":
      return `https://amoy.polygonscan.com/tx/${u}`;
    case "88882":
      return `https://testnet.chiliscan.com/tx/${u}`;
    case "43113":
      return `https://subnets-test.avax.network/c-chain/block/${u}`;
    default:
      return null;
  }
}
var Mt = h('<div class="crtw-my-4 flex justify-center"><div class="crtw-w-64 crtw-h-64 crtw-rounded-xl crtw-shadow-md crtw-bg-white flex items-center justify-center overflow-hidden"><img alt="Token" class="max-w-full max-h-full object-contain"/></div></div>'), Vt = h('<span> </span> <span class="crtw-break-all crtw-whitespace-normal crtw-break-words"> </span>', 1), Yt = h('<div class="crtw-mb-2"><a target="_blank" rel="noopener noreferrer" class="crtw-text-blue-600 crtw-underline"><div class="crtw-break-words"><!></div></a></div>'), Nt = h('<span> </span> <span class="text-gray-500 break-all whitespace-normal"> </span>', 1), Ut = h('<span> </span> <span class="crtw-break-all crtw-whitespace-normal crtw-break-words"> </span>', 1), qt = h('<div class="crtw-mb-3"><p class="crtw-text-red-600 break-words"><!></p></div>'), Ft = h('<div class="crtw-mt-6"><div class="crtw-text-lg crtw-font-semibold crtw-mb-2">Successful</div> <!> <div>Failed</div> <!> <button class="crtw-bg-black hover:crtw-bg-gray-800 crtw-text-white crtw-px-4 crtw-py-2 crtw-rounded-md crtw-mt-4">Try Again</button></div>'), Jt = h('If you are not seeing your new token, please contact <a href="mailto:support@credenza3.com" class="text-blue-600 underline">support@credenza3.com</a>.', 1), Lt = h(
  `Typically, your purchase will be processed within a few seconds. In the
      event of unusually high traffic, you may have to wait as much as a minute
      or so. If several minutes pass and you are not seeing your purchase,
      please contact <a class="crtw-underline" href="mailto:support@credenza3.com">support@credenza3.com</a>.`,
  1
), Qt = h('<div><div class="crtw-text-black-900 crtw-text-xl md:crtw-text-2xl crtw-font-semibold crtw-pt-5 crtw-mb-3.5 crtw-text-center"> </div> <div class="crtw-mb-3.5 crtw-text-sm crtw-text-justify"> </div> <!> <div class="crtw-mb-3.5 crtw-text-sm crtw-text-justify"><!></div></div>');
function pt(I, u) {
  if (new.target) return nt({ component: pt, ...I });
  ot(u, !1);
  let d = St(u, "options", 12);
  const { openUI: $ } = vt(Tt);
  let { title: N, subtitle: P, orders: g, networkType: U, tokenImage: A, isSui: q } = d();
  const dt = (g ?? []).filter((e) => e.tx), z = (g ?? []).filter((e) => !e.tx);
  function mt() {
    var e;
    if (z.some((b) => b.asset)) {
      const b = z.filter((o) => o.asset).map((o) => ({
        packageId: o.asset.packageId,
        type: o.asset.type,
        assetId: o.asset.assetId,
        amount: o.asset.amount
      }));
      if (!b.length) return;
      $(et.PAYMENT, {
        subtitle: "Retrying failed orders",
        payments: { credenzaStoredValue: { disabled: !1 } },
        assets: b
      });
      return;
    }
    const x = [], y = [];
    for (const b of z) {
      const o = b.directive;
      o.type !== "membership" ? x.push({
        contractAddress: o.resource_id,
        tokenId: (e = o.value) === null || e === void 0 ? void 0 : e.token_id,
        amount: o.value.amount
      }) : y.push({ contractAddress: o.resource_id });
    }
    !x.length && !y.length || $(et.PAYMENT, {
      subtitle: "Retrying failed orders",
      payments: { credenzaStoredValue: { disabled: !1 } },
      tokens: x,
      memberships: y
    });
  }
  var ft = {
    get options() {
      return d();
    },
    set options(e) {
      d(e), Pt();
    },
    $set: lt,
    $on: (e, p) => it(u, e, p)
  };
  ct();
  var F = Qt(), J = n(F), _t = n(J, !0);
  c(J);
  var L = _(J, 2), wt = n(L, !0);
  c(L);
  var K = _(L, 2);
  {
    var ht = (e) => {
      var p = Mt(), x = n(p), y = n(x);
      c(x), c(p), w(() => X(y, "src", A)), v(e, p);
    };
    T(K, (e) => {
      A && e(ht);
    });
  }
  var W = _(K, 2), gt = n(W);
  {
    var xt = (e) => {
      var p = Ft(), x = _(n(p), 2);
      at(x, 1, () => dt, st, (j, i) => {
        var V = Z(), Q = M(V);
        {
          var a = (S) => {
            var R = Yt(), O = n(R), Y = n(O), B = n(Y);
            {
              var D = (s) => {
                var l = H();
                w(() => f(l, (t(i), r(() => t(i).metadata.name)))), v(s, l);
              }, G = (s) => {
                var l = Vt(), m = M(l), C = n(m, !0);
                c(m);
                var k = _(m, 2), E = n(k);
                c(k), w(() => {
                  f(C, (t(i), r(() => t(i).directive.type))), f(E, `(${t(i), r(() => t(i).directive.resource_id) ?? ""})`);
                }), v(s, l);
              };
              T(B, (s) => {
                t(i), r(() => t(i).metadata?.name) ? s(D) : s(G, !1);
              });
            }
            c(Y), c(O), c(R), w((s) => X(O, "href", s), [
              () => (jt(rt), t(i), r(() => rt({ chainId: t(i).directive?.chain_id || "" }, t(i).tx, t(i).directive.chain_type, U || "")))
            ]), v(S, R);
          };
          T(Q, (S) => {
            t(i), r(() => t(i).tx) && S(a);
          });
        }
        v(j, V);
      });
      var y = _(x, 2);
      let b;
      var o = _(y, 2);
      {
        var kt = (j) => {
          var i = Z(), V = M(i);
          at(V, 1, () => z, st, (Q, a) => {
            var S = qt(), R = n(S), O = n(R);
            {
              var Y = (s) => {
                var l = H();
                w(() => f(l, (t(a), r(() => t(a).metadata.name)))), v(s, l);
              }, B = (s) => {
                var l = Nt(), m = M(l), C = n(m, !0);
                c(m);
                var k = _(m, 2), E = n(k);
                c(k), w(() => {
                  f(C, (t(a), r(() => t(a).directive.type))), f(E, `(${t(a), r(() => t(a).directive.resource_id) ?? ""})`);
                }), v(s, l);
              }, D = (s) => {
                var l = H();
                w(() => f(l, `AssetId ${t(a), r(() => t(a).asset.assetId) ?? ""} : ${t(a), r(() => t(a).error) ?? ""}`)), v(s, l);
              }, G = (s) => {
                var l = Ut(), m = M(l), C = n(m, !0);
                c(m);
                var k = _(m, 2), E = n(k);
                c(k), w(() => {
                  f(C, (t(a), r(() => t(a).asset?.type))), f(E, `(${t(a), r(() => t(a).asset?.packageId) ?? ""}) : ${t(a), r(() => t(a).error) ?? ""}`);
                }), v(s, l);
              };
              T(O, (s) => {
                t(a), r(() => t(a).metadata?.name) ? s(Y) : (t(a), r(() => t(a).directive?.type) ? s(B, 1) : (t(a), r(() => t(a).asset?.assetId) ? s(D, 2) : s(G, !1)));
              });
            }
            c(R), c(S), v(Q, S);
          }), v(j, i);
        };
        T(o, (j) => {
          r(() => z.length) && j(kt);
        });
      }
      var It = _(o, 2);
      c(p), w(() => b = $t(y, 1, "crtw-text-lg crtw-font-semibold crtw-mt-6 crtw-mb-2", null, b, { hidden: !z.length })), At("click", It, mt), v(e, p);
    }, bt = (e) => {
      var p = Jt();
      tt(2), v(e, p);
    }, yt = (e) => {
      var p = Lt();
      tt(2), v(e, p);
    };
    T(gt, (e) => {
      r(() => g.length) ? e(xt) : q ? e(bt, 1) : e(yt, !1);
    });
  }
  return c(W), c(F), w(() => {
    f(_t, N), f(wt, P);
  }), v(I, F), ut(ft);
}
function Bt(I, u) {
  if (new.target) return nt({ component: Bt, ...I });
  ot(u, !1);
  const d = () => Rt(Et, "$pageOptsStore", $), [$, N] = zt();
  let P = vt(Ot);
  var g = {
    $set: lt,
    $on: (A, q) => it(u, A, q)
  };
  ct();
  {
    let A = Ct(() => ({
      title: d()?.title || P.content?.paymentResult?.title || "Success!",
      subtitle: d()?.subtitle || P.content?.paymentResult?.subtitle || "Your payment was successful!",
      description: d()?.description || P.content?.paymentResult?.description,
      orders: d()?.orders || [],
      tokenImage: d()?.tokenImage || ""
    }));
    pt(I, {
      get options() {
        return t(A);
      }
    });
  }
  var U = ut(g);
  return N(), U;
}
export {
  Bt as default
};
//# sourceMappingURL=PaymentResult--4lT5uK5.js.map
