import { c as nt, p as St, h as ct, f as h, i as R, o as f, b as v, d as it, u as ot, s as X, k as $t, e as At, a as Z, t as J } from "./AssetItem-CFsdMEwW.js";
import { v as lt, M as vt, O as zt, x as n, y as c, A as _, D as r, z as w, t as ut, n as Tt, C as tt, T as et, r as E, I as t, w as Rt, L as Ot, Y as Pt, E as jt, F as Yt, Q as Ct } from "./index-BxjwuJ6T.js";
import { e as at, i as st } from "./each-BgMcYdMq.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 Et = 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>'), Mt = h('<span> </span> <span class="crtw-break-all crtw-whitespace-normal crtw-break-words"> </span>', 1), Ft = 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), Vt = h('<div class="crtw-mb-3"><p class="crtw-text-red-600 break-words"><!></p></div>'), qt = 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>'), Dt = 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 });
  lt(u, !1);
  let d = St(u, "options", 12);
  const { openUI: $ } = vt(zt);
  let { title: N, subtitle: O, orders: g, networkType: U, tokenImage: A, isSui: V } = 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((l) => l.asset).map((l) => ({
        packageId: l.asset.packageId,
        type: l.asset.type,
        assetId: l.asset.assetId,
        amount: l.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 l = b.directive;
      l.type !== "membership" ? x.push({
        contractAddress: l.resource_id,
        tokenId: (e = l.value) === null || e === void 0 ? void 0 : e.token_id,
        amount: l.value.amount
      }) : y.push({ contractAddress: l.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), Tt();
    },
    $set: ot,
    $on: (e, p) => it(u, e, p)
  };
  ct();
  var q = Qt(), D = n(q), _t = n(D, !0);
  c(D);
  var L = _(D, 2), wt = n(L, !0);
  c(L);
  var K = _(L, 2);
  {
    var ht = (e) => {
      var p = Et(), x = n(p), y = n(x);
      c(x), c(p), w(() => X(y, "src", A)), v(e, p);
    };
    R(K, (e) => {
      A && e(ht);
    });
  }
  var W = _(K, 2), gt = n(W);
  {
    var xt = (e) => {
      var p = qt(), x = _(n(p), 2);
      at(x, 1, () => dt, st, (P, i) => {
        var M = Z(), Q = E(M);
        {
          var a = (S) => {
            var T = Ft(), j = n(T), F = n(j), B = n(F);
            {
              var G = (s) => {
                var o = J();
                w(() => f(o, (t(i), r(() => t(i).metadata.name)))), v(s, o);
              }, H = (s) => {
                var o = Mt(), m = E(o), Y = n(m, !0);
                c(m);
                var k = _(m, 2), C = n(k);
                c(k), w(() => {
                  f(Y, (t(i), r(() => t(i).directive.type))), f(C, `(${t(i), r(() => t(i).directive.resource_id) ?? ""})`);
                }), v(s, o);
              };
              R(B, (s) => {
                t(i), r(() => t(i).metadata?.name) ? s(G) : s(H, -1);
              });
            }
            c(F), c(j), c(T), w((s) => X(j, "href", s), [
              () => (Rt(rt), t(i), r(() => rt({ chainId: t(i).directive?.chain_id || "" }, t(i).tx, t(i).directive.chain_type, U || "")))
            ]), v(S, T);
          };
          R(Q, (S) => {
            t(i), r(() => t(i).tx) && S(a);
          });
        }
        v(P, M);
      });
      var y = _(x, 2);
      let b;
      var l = _(y, 2);
      {
        var kt = (P) => {
          var i = Z(), M = E(i);
          at(M, 1, () => z, st, (Q, a) => {
            var S = Vt(), T = n(S), j = n(T);
            {
              var F = (s) => {
                var o = J();
                w(() => f(o, (t(a), r(() => t(a).metadata.name)))), v(s, o);
              }, B = (s) => {
                var o = Nt(), m = E(o), Y = n(m, !0);
                c(m);
                var k = _(m, 2), C = n(k);
                c(k), w(() => {
                  f(Y, (t(a), r(() => t(a).directive.type))), f(C, `(${t(a), r(() => t(a).directive.resource_id) ?? ""})`);
                }), v(s, o);
              }, G = (s) => {
                var o = J();
                w(() => f(o, `AssetId ${t(a), r(() => t(a).asset.assetId) ?? ""} : ${t(a), r(() => t(a).error) ?? ""}`)), v(s, o);
              }, H = (s) => {
                var o = Ut(), m = E(o), Y = n(m, !0);
                c(m);
                var k = _(m, 2), C = n(k);
                c(k), w(() => {
                  f(Y, (t(a), r(() => t(a).asset?.type))), f(C, `(${t(a), r(() => t(a).asset?.packageId) ?? ""}) : ${t(a), r(() => t(a).error) ?? ""}`);
                }), v(s, o);
              };
              R(j, (s) => {
                t(a), r(() => t(a).metadata?.name) ? s(F) : (t(a), r(() => t(a).directive?.type) ? s(B, 1) : (t(a), r(() => t(a).asset?.assetId) ? s(G, 2) : s(H, -1)));
              });
            }
            c(T), c(S), v(Q, S);
          }), v(P, i);
        };
        R(l, (P) => {
          r(() => z.length) && P(kt);
        });
      }
      var It = _(l, 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 = Dt();
      tt(2), v(e, p);
    }, yt = (e) => {
      var p = Lt();
      tt(2), v(e, p);
    };
    R(gt, (e) => {
      r(() => g.length) ? e(xt) : V ? e(bt, 1) : e(yt, -1);
    });
  }
  return c(W), c(q), w(() => {
    f(_t, N), f(wt, O);
  }), v(I, q), ut(ft);
}
function Bt(I, u) {
  if (new.target) return nt({ component: Bt, ...I });
  lt(u, !1);
  const d = () => Yt(Ct, "$pageOptsStore", $), [$, N] = jt();
  let O = vt(Ot);
  var g = {
    $set: ot,
    $on: (A, V) => it(u, A, V)
  };
  ct();
  {
    let A = Pt(() => ({
      title: d()?.title || O.content?.paymentResult?.title || "Success!",
      subtitle: d()?.subtitle || O.content?.paymentResult?.subtitle || "Your payment was successful!",
      description: d()?.description || O.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-DeTVN83L.js.map
