import { c as de, m as nt, p as A, f as G, i as ye, k as De, e as $e, b as D, d as ce, u as me, t as Ce, r as ve, h as ke, s as at, g as Se, a as Ie, j as it, n as Fe, o as ue, q as st } from "./AssetItem-BxjLUzNd.js";
import { a as Ne, o as rt } from "./index-client-C5PXnhDi.js";
import { t as Te, w as W, x as q, y as ge, r as fe, l as L, m as F, bI as X, n as pe, D as C, v as O, o as xe, z as j, E as t, V as le, C as ae, A as pt, p as oe, bJ as Oe, K as ee, P as te, J, by as Ue, L as Ae, I as we, bK as ze, bu as Le, a0 as We, _ as qe, bL as je, M as ne, O as ie, Q as se, bM as ot, bN as Ve, Z as Ye, $ as re, a1 as ut, bO as Pe, bP as _e, bB as yt, bQ as lt, bA as dt } from "./index-BBXAtvZr.js";
import { a as ct } from "./App-BwT5MYkN.js";
import { B as mt } from "./ButtonBack-DvsFRnLL.js";
import { p as Tt } from "./event-modifiers-D4czZCB6.js";
import { L as Je } from "./Loader-Byv7_nwE.js";
import { B as Ke } from "./Button-CqLZSfSk.js";
const ft = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='22'%20height='22'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='%23bbb'%20d='M17%209.761v-4.761c0-2.761-2.238-5-5-5-2.763%200-5%202.239-5%205v4.761c-1.827%201.466-3%203.714-3%206.239%200%204.418%203.582%208%208%208s8-3.582%208-8c0-2.525-1.173-4.773-3-6.239zm-8-4.761c0-1.654%201.346-3%203-3s3%201.346%203%203v3.587c-.927-.376-1.938-.587-3-.587s-2.073.211-3%20.587v-3.587zm4%2011.723v2.277h-2v-2.277c-.596-.347-1-.984-1-1.723%200-1.104.896-2%202-2s2%20.896%202%202c0%20.738-.404%201.376-1%201.723z'/%3e%3c/svg%3e";
var bt = G('<button type="submit"><!></button>');
const vt = {
  hash: "svelte-m3cnza",
  code: ".active.svelte-m3cnza {background-color:#ffff;font-weight:500;color:#000;}.btn-disabled.svelte-m3cnza {pointer-events:none;background-color:#d0d2d5;}"
};
function Be(m, a) {
  if (new.target) return de({ component: Be, ...m });
  Te(a, !1), nt(m, vt);
  let i = A(a, "onClick", 12), f = A(a, "text", 12), g = A(a, "disabled", 12, !1), u = A(a, "isLoading", 12, !1), b = A(a, "isActive", 12, !1);
  var p = {
    get onClick() {
      return i();
    },
    set onClick(o) {
      i(o), L();
    },
    get text() {
      return f();
    },
    set text(o) {
      f(o), L();
    },
    get disabled() {
      return g();
    },
    set disabled(o) {
      g(o), L();
    },
    get isLoading() {
      return u();
    },
    set isLoading(o) {
      u(o), L();
    },
    get isActive() {
      return b();
    },
    set isActive(o) {
      b(o), L();
    },
    $set: me,
    $on: (o, M) => ce(a, o, M)
  }, w = bt();
  let k;
  var r = W(w);
  {
    var E = (o) => {
      Je(o, {});
    }, y = (o) => {
      var M = Ce();
      ge(() => ve(M, f())), D(o, M);
    };
    ye(r, (o) => {
      u() ? o(E) : o(y, !1);
    });
  }
  return q(w), ge(() => k = De(w, 1, `crtw-flex crtw-justify-center crtw-items-center crtw-w-full crtw-h-[50px] crtw-cursor-pointer crtw-border crtw-border-gray-300
  crtw-rounded crtw-font-['poppins'] crtw-text-gray-600 svelte-m3cnza`, null, k, {
    "btn-disabled": g() || u(),
    active: b()
  })), $e("click", w, Tt(function(...o) {
    i()?.apply(this, o);
  })), D(m, w), fe(p);
}
var gt = G("<div> </div>"), wt = G("<!> <!>", 1), kt = G('<div><div class="crtw-text-right crtw-text-[13px] crtw-text-gray-400 crtw-mb-6"><div class="crtw-break-words"> </div> <div> </div></div> <div class="crtw-font-bold crtw-text-xl"> </div> <div class="crtw-flex crtw-justify-between crtw-mb-3 crtw-text-gray-600 crtw-font-bold"><!></div> <div class="crtw-flex crtw-bg-gray-200 crtw-rounded-md crtw-p-px"><!> <!></div> <hr class="crtw-block crtw-border-t-2 crtw-border-gray-200 crtw-w-1/2 crtw-mx-auto crtw-mt-3.5 crtw-mb-[15px]"/> <!> <div class="crtw-flex crtw-w-full crtw-justify-center crtw-items-center"><img alt=""/><span class="crtw-text-sm crtw-text-gray-400 crtw-ml-1">Payments are secure and encrypted</span></div> <div class="crtw-mt-1.5"><!></div></div>');
function Ze(m, a) {
  if (new.target) return de({ component: Ze, ...m });
  Te(a, !1);
  const i = F();
  let f = A(a, "isLoading", 12), g = A(a, "options", 12), { user: u, title: b, subtitle: p, onBackClick: w, isCardDisabled: k } = g(), r = F(k ? X.CREDENZA_BALANCE : X.CREDIT_CARD);
  pe(() => O(g()), () => {
    C(i, g().isCredezaValueDisabled);
  }), xe();
  var E = {
    get isLoading() {
      return f();
    },
    set isLoading(n) {
      f(n), L();
    },
    get options() {
      return g();
    },
    set options(n) {
      g(n), L();
    },
    $set: me,
    $on: (n, v) => ce(a, n, v)
  };
  ke();
  var y = kt();
  let o;
  var M = W(y), T = W(M), h = W(T, !0);
  q(T);
  var z = j(T, 2), V = W(z, !0);
  q(z), q(M);
  var N = j(M, 2), R = W(N, !0);
  q(N);
  var $ = j(N, 2), Z = W($);
  {
    var H = (n) => {
      var v = gt(), s = W(v, !0);
      q(v), ge(() => ve(s, p)), D(n, v);
    };
    ye(Z, (n) => {
      p && n(H);
    });
  }
  q($);
  var _ = j($, 2), U = W(_);
  {
    let n = le(() => (t(r), O(X), ae(() => t(r) === X.CREDIT_CARD)));
    Be(U, {
      text: "Credit Card",
      onClick: () => C(r, X.CREDIT_CARD),
      get isActive() {
        return t(n);
      },
      get disabled() {
        return k;
      }
    });
  }
  var c = j(U, 2);
  {
    let n = le(() => (t(r), O(X), ae(() => t(r) === X.CREDENZA_BALANCE)));
    Be(c, {
      text: "Credenza Balance",
      onClick: () => C(r, X.CREDENZA_BALANCE),
      get isActive() {
        return t(n);
      },
      get disabled() {
        return t(i);
      }
    });
  }
  q(_);
  var e = j(_, 4);
  {
    var l = (n) => {
      var v = wt(), s = oe(v);
      Se(s, a, "card-provider-switch", {});
      var I = j(s, 2);
      Se(I, a, "credit-card", {}), D(n, v);
    }, d = (n) => {
      var v = Ie(), s = oe(v);
      Se(s, a, "cred-balance", {}), D(n, v);
    };
    ye(e, (n) => {
      t(r), O(X), ae(() => t(r) === X.CREDIT_CARD) ? n(l) : (t(r), O(X), ae(() => t(r) === X.CREDENZA_BALANCE) && n(d, 1));
    });
  }
  var P = j(e, 2), x = W(P);
  pt(), q(P);
  var B = j(P, 2), S = W(B);
  return mt(S, {
    get onClick() {
      return w;
    }
  }), q(B), q(y), ge(() => {
    o = De(y, 1, "cpui-payment crtw-text-left crtw-w-full", null, o, { "crtw-hidden": f() }), ve(h, ae(() => u?.email || u?.pending?.email || "")), ve(V, ae(() => u?.phone || u?.pending?.phone || "")), ve(R, b), at(x, "src", ft);
  }), D(m, y), fe(E);
}
var Mt = G('<div class="crtw-text-base crtw-mb-1.5">Credit card details</div> <div id="cpui-card-element" class="crtw-border crtw-border-gray-300 crtw-rounded crtw-px-2.5 crtw-py-4 crtw-mb-2.5 crtw-w-full"></div> <div id="card-errors" role="alert"></div> <!>', 1);
function Ge(m, a) {
  if (new.target) return de({ component: Ge, ...m });
  Te(a, !1);
  let i = A(a, "options", 12), f = A(a, "isPaymentDisabled", 12), g = A(a, "isLoading", 12), u = A(a, "totalToPay", 12);
  const b = 0.5, p = +u() < b;
  let { isCardFocused: w, onPay: k, currencySymbol: r = "$" } = i();
  var E = {
    get options() {
      return i();
    },
    set options(T) {
      i(T), L();
    },
    get isPaymentDisabled() {
      return f();
    },
    set isPaymentDisabled(T) {
      f(T), L();
    },
    get isLoading() {
      return g();
    },
    set isLoading(T) {
      g(T), L();
    },
    get totalToPay() {
      return u();
    },
    set totalToPay(T) {
      u(T), L();
    },
    $set: me,
    $on: (T, h) => ce(a, T, h)
  }, y = Mt(), o = j(oe(y), 2), M = j(o, 4);
  {
    let T = le(() => p ? `Minimum card payment: ${r}${b}` : `Pay ${r}${u()}`), h = le(() => f() || p);
    Ke(M, {
      get text() {
        return t(T);
      },
      get onClick() {
        return k;
      },
      get disabled() {
        return t(h);
      },
      get isLoading() {
        return g();
      },
      set isLoading(z) {
        g(z);
      },
      $$legacy: !0
    });
  }
  return ge(() => it(o, w ? "border-color: #121e2b" : "")), D(m, y), fe(E);
}
var ht = G('You do not have enough stored value to make this payment. <span class="crtw-text-black crtw-cursor-pointer" role="button" tabindex="0"> </span>', 1), _t = G('<div class="crtw-w-full crtw-text-center crtw-my-5"><div class="crtw-text-3xl crtw-text-black crtw-font-bold"><!></div> <div class="crtw-mb-5 crtw-text-gray-600"><!></div> <!></div>');
function He(m, a) {
  if (new.target) return de({ component: He, ...m });
  Te(a, !1);
  const i = F(), f = F(), g = F(), u = F(), b = F();
  let p = A(a, "options", 12), { credAlias: w, onPay: k, onGetCred: r } = p();
  pe(() => O(p()), () => {
    C(i, p().isLoading);
  }), pe(() => O(p()), () => {
    C(f, p().isPaymentDisabled);
  }), pe(() => O(p()), () => {
    C(g, p().formattedBalance);
  }), pe(() => O(p()), () => {
    C(u, p().totalToPay);
  }), pe(() => O(p()), () => {
    C(b, p().balance);
  }), xe();
  var E = {
    get options() {
      return p();
    },
    set options(_) {
      p(_), L();
    },
    $set: me,
    $on: (_, U) => ce(a, _, U)
  };
  ke();
  var y = _t(), o = W(y), M = W(o);
  {
    var T = (_) => {
      var U = Ce("INSUFFICIENT FUNDS");
      D(_, U);
    }, h = Oe(() => (t(u), t(b), ae(() => Number(t(u)) > t(b)))), z = (_) => {
      var U = Ce();
      ge(() => ve(U, `${t(g) ?? ""} ${w ?? ""}`)), D(_, U);
    };
    ye(M, (_) => {
      t(h) ? _(T) : _(z, !1);
    });
  }
  q(o);
  var V = j(o, 2), N = W(V);
  {
    var R = (_) => {
      var U = ht(), c = j(oe(U)), e = W(c);
      q(c), ge(() => ve(e, `Click to get some ${w ?? ""}`)), $e("click", c, r), D(_, U);
    }, $ = Oe(() => (t(u), t(b), ae(() => Number(t(u)) > t(b)))), Z = (_) => {
      var U = Ce("Your balance after purchase");
      D(_, U);
    };
    ye(N, (_) => {
      t($) ? _(R) : _(Z, !1);
    });
  }
  q(V);
  var H = j(V, 2);
  {
    let _ = le(() => `Pay ${t(u)} ${w}`);
    Ke(H, {
      get text() {
        return t(_);
      },
      get onClick() {
        return k;
      },
      get disabled() {
        return t(f);
      },
      get isLoading() {
        return t(i);
      }
    });
  }
  return q(y), D(m, y), fe(E);
}
var Ct = G('<div id="ctui-wallet-pay" class="crtw-w-full crtw-my-4" style="dispay: none;"><div id="ctui-payment-request-button"></div></div>');
function Qe(m, a) {
  if (new.target) return de({ component: Qe, ...m });
  Te(a, !1);
  var i = this && this.__awaiter || function(r, E, y, o) {
    function M(T) {
      return T instanceof y ? T : new y(function(h) {
        h(T);
      });
    }
    return new (y || (y = Promise))(function(T, h) {
      function z(R) {
        try {
          N(o.next(R));
        } catch ($) {
          h($);
        }
      }
      function V(R) {
        try {
          N(o.throw(R));
        } catch ($) {
          h($);
        }
      }
      function N(R) {
        R.done ? T(R.value) : M(R.value).then(z, V);
      }
      N((o = o.apply(r, E || [])).next());
    });
  };
  let f = A(a, "doPayment", 12), g = A(a, "stripe", 12), u = A(a, "stripeElements", 12), b = A(a, "priceCents", 12), p = A(a, "isLoading", 12);
  Ne(() => i(void 0, void 0, void 0, function* () {
    const r = g().paymentRequest({
      country: "US",
      currency: "usd",
      total: { label: "Apple/Google payment", amount: b() },
      requestPayerName: !0,
      requestPayerEmail: !0
    });
    if (!(yield r.canMakePayment())) return;
    const y = document.getElementById("ctui-wallet-pay");
    y && (y.style.display = "crtw-block"), u().create("paymentRequestButton", {
      paymentRequest: r,
      style: { paymentRequestButton: { height: "48px" } }
    }).mount("#ctui-payment-request-button"), r.on("token", (M) => i(void 0, void 0, void 0, function* () {
      p(!0);
      try {
        yield f()(M.token.id), yield M.complete("success");
      } catch (T) {
        yield M.complete("error"), ee(te.ERROR, { error: T });
      }
      p(!1);
    }));
  }));
  var w = {
    get doPayment() {
      return f();
    },
    set doPayment(r) {
      f(r), L();
    },
    get stripe() {
      return g();
    },
    set stripe(r) {
      g(r), L();
    },
    get stripeElements() {
      return u();
    },
    set stripeElements(r) {
      u(r), L();
    },
    get priceCents() {
      return b();
    },
    set priceCents(r) {
      b(r), L();
    },
    get isLoading() {
      return p();
    },
    set isLoading(r) {
      p(r), L();
    },
    $set: me,
    $on: (r, E) => ce(a, r, E)
  };
  ke();
  var k = Ct();
  return D(m, k), fe(w);
}
const Pt = {
  base: {
    color: "#121e2b",
    fontSize: "12px",
    "::placeholder": {
      color: "#d9d9d9"
    }
  },
  invalid: {
    color: "#fa755a"
  }
}, It = (m) => new Promise((a, i) => {
  const f = document.createElement("script");
  f.src = m, document.body.appendChild(f), f.addEventListener("load", () => a(f)), f.addEventListener("error", () => i(f));
}), Jt = async (m, a, i = 5) => {
  let f = 0;
  for (; f < i; ) {
    const g = await fetch(`${m}/orders/completed/${a}`, {
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${J(Ue)}`
      },
      method: "GET"
    });
    if (g.status === 204) {
      if (f++, f < i)
        continue;
      throw new Error("No content received after multiple attempts");
    }
    if (!g.ok) throw new Error("Failed to get order details");
    const u = await g.json();
    if (u.status === "PAYMENT_ERROR")
      throw new Error(`Order failed: ${u.status}`);
    return u;
  }
}, xt = (m, a) => {
  if (m.every((i) => i === null))
    throw new Error(`All transactions failed. 
${a}`);
}, At = (m) => {
  const a = m.filter((i) => i.error).map(
    (i) => `Name: ${i.metadata?.name || i.directive.resource_id}, reason: ${i.error}`
  ).join(`
`);
  if (m?.every((i) => i.status === "ERROR"))
    throw new Error("All transactions failed.}");
  return a;
}, Lt = async ({
  hash: m,
  stripeChargeId: a,
  title: i,
  subtitle: f,
  amount: g,
  currency: u
}) => {
  const { credenza: b, receiptTarget: p, clientId: w } = J(we), k = p ? p.filter(
    (E) => {
      const y = J(Le);
      if (y)
        return y[E];
    }
  ) : [ot.EMAIL];
  let r = 0;
  for (const E of k) {
    const y = await fetch(`${b.evmApiUrl}/contracts/receipt`, {
      method: "POST",
      body: JSON.stringify({
        ...m ? { tx: m } : { charge_id: a },
        ...g ? { amount: g } : {},
        ...u ? { currency: u } : {},
        target: E,
        title: i,
        subtitle: f,
        source: Ve(w).name
      }),
      headers: {
        Authorization: `Bearer ${J(Ue)}`,
        "Content-Type": "application/json"
      }
    });
    y.ok ? r++ : console.warn(`Failed to send receipt to ${E}:`, y.status);
  }
  return r > 0;
}, Et = async (m, a, i) => {
  const { toastAlert: f } = J(Ae), g = J(we), u = At(m.items);
  (i.tokens?.length || i.memberships?.length) && xt(m.chain_txs, u), ee(te.PAYMENT, {
    type: ze.CARD,
    results: { ...m, tokens: i.tokens, memberships: i.memberships, licenses: i.licenses }
  }), f("Your payment was successful"), ee(te.RECHECK_BALANCE, m.chain_txs);
  const b = J(Le);
  b && We.track("cp_payment_fiat", {
    $email: b.email,
    $phone: b.phone,
    chain: g.chainId,
    clientId: g.clientId,
    address: await qe(),
    location: window.location.href,
    tokens: i?.tokens,
    memberships: i?.memberships,
    licenses: i?.licenses,
    total: a / 100,
    description: (i?.title ?? "") + `(${i?.subtitle ?? ""})`
  }), await je(), a === 0 && ne.set({ subtitle: "Your claim was successful!", receipt: !1 }), u && ne.set({
    title: "Done!",
    subtitle: "Your payment was partly successful",
    orders: m.items
  }), ie.set(se.PAYMENT_RESULT);
};
var Rt = G("<!> <!>", 1);
function Xe(m, a) {
  if (new.target) return de({ component: Xe, ...m });
  Te(a, !1);
  const i = () => ue(ne, "$pageOptsStore", f), [f, g] = Fe(), u = F(), b = F();
  var p = this && this.__awaiter || function(e, l, d, P) {
    function x(B) {
      return B instanceof d ? B : new d(function(S) {
        S(B);
      });
    }
    return new (d || (d = Promise))(function(B, S) {
      function n(I) {
        try {
          s(P.next(I));
        } catch (K) {
          S(K);
        }
      }
      function v(I) {
        try {
          s(P.throw(I));
        } catch (K) {
          S(K);
        }
      }
      function s(I) {
        I.done ? B(I.value) : x(I.value).then(n, v);
      }
      s((P = P.apply(e, l || [])).next());
    });
  };
  let w = A(a, "priceCents", 12), k = A(a, "isLoading", 12), r = A(a, "isPriceLoading", 12);
  const { toastAlert: E } = J(Ae), y = J(we);
  let o, M = F(), T = F(), h, z = F(), V = F(!1);
  Ne(() => p(void 0, void 0, void 0, function* () {
    var e;
    try {
      if (!o) {
        if (!window.Stripe && (yield It("https://js.stripe.com/v3/"), !window.Stripe))
          throw {};
        o = window.Stripe;
      }
    } catch {
      return console.log("Please include stripe to use payments.");
    }
    if (t(M)) return;
    const l = Ve(y.clientId).name;
    C(M, o((e = y.stripe.pk[l]) !== null && e !== void 0 ? e : y.stripe.pk.DEFAULT)), C(T, t(M).elements()), h = t(T).create("card", { style: Pt }), h.mount("#cpui-card-element"), h.on("change", (d) => {
      C(z, d.complete && !d.error);
    }), h.on("focus", () => C(V, !0)), h.on("blur", () => C(V, !1));
  }));
  const N = () => p(void 0, void 0, void 0, function* () {
    try {
      if (!t(z)) return;
      k(!0);
      const e = yield t(M).createToken(h);
      if (e.error) throw e.error;
      yield R(e.token.id);
    } catch (e) {
      ee(te.ERROR, { error: e });
    }
    k(!1);
  }), R = (e) => p(void 0, void 0, void 0, function* () {
    try {
      const { processPayment: l } = yield import("./Stripe.service-Da85d2QQ.js"), d = yield l(e);
      yield Et(d, w(), i());
    } catch (l) {
      E(`Payment error: ${l.message || l}`, "failure"), ne.set({ errorMessage: l.message || l }), ie.set(se.ERROR), ee(te.ERROR, { error: l });
    }
  });
  pe(() => O(w()), () => {
    C(u, (w() / 100).toFixed(2));
  }), pe(
    () => (t(z), O(k()), O(r())),
    () => {
      C(b, !t(z) || k() || r());
    }
  ), xe();
  var $ = {
    get priceCents() {
      return w();
    },
    set priceCents(e) {
      w(e), L();
    },
    get isLoading() {
      return k();
    },
    set isLoading(e) {
      k(e), L();
    },
    get isPriceLoading() {
      return r();
    },
    set isPriceLoading(e) {
      r(e), L();
    },
    $set: me,
    $on: (e, l) => ce(a, e, l)
  };
  ke();
  var Z = Rt(), H = oe(Z);
  {
    let e = le(() => ({ isCardFocused: t(V), onPay: N }));
    Ge(H, {
      get options() {
        return t(e);
      },
      get isPaymentDisabled() {
        return t(b);
      },
      set isPaymentDisabled(l) {
        C(b, l);
      },
      get isLoading() {
        return k();
      },
      set isLoading(l) {
        k(l);
      },
      get totalToPay() {
        return t(u);
      },
      set totalToPay(l) {
        C(u, l);
      },
      $$legacy: !0
    });
  }
  var _ = j(H, 2);
  {
    var U = (e) => {
      Qe(e, {
        doPayment: R,
        get stripe() {
          return t(M);
        },
        get stripeElements() {
          return t(T);
        },
        get priceCents() {
          return w();
        },
        get isLoading() {
          return k();
        },
        set isLoading(l) {
          k(l);
        },
        $$legacy: !0
      });
    };
    ye(_, (e) => {
      t(M) && t(T) && e(U);
    });
  }
  D(m, Z);
  var c = fe($);
  return g(), c;
}
const St = /* @__PURE__ */ JSON.parse('[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceToken","type":"uint256"}],"name":"Redeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"addAvailableCurrencyTokenContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"addOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"contentTokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"}],"name":"buyLicenseWithEther","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"contentTokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"}],"name":"buyLicenseWithToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"contentTokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"currencyTokenContract","type":"address"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"}],"name":"buyLicenseWithToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_requestedAmount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"buyWithEther","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_requestedAmount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_currencyTokenContract","type":"address"}],"name":"buyWithToken","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_requestedAmount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"buyWithToken","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"clearOwners","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contentNftContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAvailableCurrencyTokenContractsList","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBeneficiaryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDefaultCurrencyTokenContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDescription","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwners","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPriceEther","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPriceFiat","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"currencyContract","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPriceToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPriceToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenLicenseContentNftId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenLicenseExpiresAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenLicenseType","outputs":[{"internalType":"enum ContentNftTypes.LicenseType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTrustedForwarder","outputs":[{"internalType":"address","name":"forwarder","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"image","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"isAvailableCurrencyTokenContract","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"string","name":"tokenURI","type":"string"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mintBatch","outputs":[{"internalType":"uint256[]","name":"arr","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nonceUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"priceToken","type":"uint256"},{"internalType":"uint256","name":"contentNftId","type":"uint256"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"},{"internalType":"uint256","name":"expiresAt","type":"uint256"},{"internalType":"string","name":"uri","type":"string"}],"internalType":"struct LicenseNftContract.LicenseNFTVoucher","name":"voucher","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"removeAvailableCurrencyTokenContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"removeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"setBaseUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"addr","type":"address"}],"name":"setBeneficiaryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"setContentNftContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"}],"name":"setDefaultCurrencyTokenContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"description","type":"string"}],"name":"setDescription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newImage","type":"string"}],"name":"setImage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceFiat","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"currencyContract","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newSymbol","type":"string"}],"name":"setSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"_tokenURI","type":"string"}],"name":"setTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"string","name":"_tokenURI","type":"string"}],"name":"setTokenURIByIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_forwarder","type":"address"}],"name":"setTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenURIByIndex","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}]');
var Bt = G('<div class="crtw-w-full crtw-justify-items-center crtw-my-5"><!></div>');
function et(m, a) {
  if (new.target) return de({ component: et, ...m });
  Te(a, !1);
  const i = () => ue(ne, "$pageOptsStore", g), f = () => ue(ut, "$clientPublicStore", g), [g, u] = Fe();
  var b = this && this.__awaiter || function(n, v, s, I) {
    function K(Y) {
      return Y instanceof s ? Y : new s(function(Q) {
        Q(Y);
      });
    }
    return new (s || (s = Promise))(function(Y, Q) {
      function Me(be) {
        try {
          Ee(I.next(be));
        } catch (Re) {
          Q(Re);
        }
      }
      function he(be) {
        try {
          Ee(I.throw(be));
        } catch (Re) {
          Q(Re);
        }
      }
      function Ee(be) {
        be.done ? Y(be.value) : K(be.value).then(Me, he);
      }
      Ee((I = I.apply(n, v || [])).next());
    });
  };
  let p = A(a, "totalPriceToken", 12), w = A(a, "isLoading", 12), k = A(a, "isPriceLoading", 12), r = A(a, "pricesByToken", 12);
  const { getCREDContract: E, toastAlert: y } = J(Ae), { chainId: o, clientId: M } = J(we);
  let T = F(!1), h = F(BigInt(0)), z = F(), V = "", N, R = F(), $, Z, H;
  const _ = (n, v, s) => b(void 0, void 0, void 0, function* () {
    y(`<a href="${yt(v.hash)}" target="_blank">Purchase TX #${n}</a> was created`), ee(te.PAYMENT, { type: ze.ERC20, data: v }), ee(te.RECHECK_BALANCE), yield Lt({
      hash: v.hash,
      title: i().title,
      subtitle: i().subtitle,
      currency: "CRED",
      amount: +re.formatUnits(s, t(R))
    }), ee(te.RECEIPT, { hash: v.hash });
  }), U = (n, v) => b(void 0, void 0, void 0, function* () {
    try {
      const { credenzaSellableMinAbi: s } = yield import("./abi-DIVtyi6o.js"), I = new re.Contract(n.contractAddress, s, Z), K = n.tokenId || n.membershipTokenId || Pe, Y = r()[`${n.contractAddress}/${K}`], Q = yield N.approve.populateTransaction(yield I.getAddress(), Y);
      yield _e(Q, N);
      const Me = yield I.buyWithToken.populateTransaction(K, n.amount || 1, $), he = yield _e(Me, I);
      yield _(v, he, Y);
    } catch (s) {
      y(`Payment error: ${s.message || s}`, "failure"), ne.set({ errorMessage: s.message }), ie.set(se.ERROR), ee(te.ERROR, { error: s });
    }
  }), c = (n, v) => b(void 0, void 0, void 0, function* () {
    if (n.licenseContractAddress)
      try {
        const s = new re.Contract(n.licenseContractAddress, St, Z), I = r()[`${n.contractAddress}/${n.contentTokenId}`], K = yield N.approve.populateTransaction(yield s.getAddress(), I);
        yield _e(K, N), yield new Promise((he) => setTimeout(he, 3e3));
        const Y = s.interface.getFunction("buyLicenseWithToken", ["uint", "address", "uint"]);
        if (!Y) throw new Error("buyLicenseWithToken function not found");
        const Q = yield s[Y.format()].populateTransaction(n.contentTokenId, $, n.licenseType), Me = yield _e(Q, s);
        yield _(v, Me, I);
      } catch (s) {
        y(`Payment error: ${s.message || s}`, "failure"), ne.set({ errorMessage: s.message }), ie.set(se.ERROR), ee(te.ERROR, { error: s });
      }
  }), e = () => b(void 0, void 0, void 0, function* () {
    var n, v;
    try {
      if (BigInt(p()) > t(h)) return;
      w(!0);
      const s = [
        ...i().tokens || [],
        ...i().memberships || []
      ].map((Y, Q) => U(Y, Q + 1)), I = [...i().licenses || []].map((Y, Q) => c(Y, Q + 1));
      yield Promise.all([
        ...s,
        ...I
      ]);
      const K = J(Le);
      K && We.track("cp_payment_stored_value", {
        $email: K.email,
        $phone: K.phone,
        chain: o,
        clientId: M,
        address: $,
        location: window.location.href,
        tokens: i().tokens,
        memberships: i().memberships,
        total: p(),
        description: ((n = i() === null || i() === void 0 ? void 0 : i().title) !== null && n !== void 0 ? n : "") + `(${(v = i() === null || i() === void 0 ? void 0 : i().subtitle) !== null && v !== void 0 ? v : ""})`
      }), yield je(), p() === 0 && ne.set({ subtitle: "Your claim was successful!", receipt: !1 }), ie.set(se.PAYMENT_RESULT);
    } catch (s) {
      y(`Payment error: ${s.message || s}`, "failure"), ne.set({ errorMessage: s.message }), ie.set(se.ERROR), ee(te.ERROR, { error: s });
    } finally {
      w(!1);
    }
  });
  Ne(() => b(void 0, void 0, void 0, function* () {
    try {
      C(T, !0), H = yield E();
      const n = J(Ye);
      if (!n) return;
      Z = yield n.getSigner(), N = H.contract, C(R, H.decimals), [$, V] = yield Promise.all([qe(), N.symbol()]), C(h, yield N.balanceOf($)), C(z, `${re.formatUnits(BigInt(t(h)) - BigInt(p()), t(R))}`);
    } catch (n) {
      console.log(n);
    } finally {
      C(T, !1);
    }
  }));
  var l = {
    get totalPriceToken() {
      return p();
    },
    set totalPriceToken(n) {
      p(n), L();
    },
    get isLoading() {
      return w();
    },
    set isLoading(n) {
      w(n), L();
    },
    get isPriceLoading() {
      return k();
    },
    set isPriceLoading(n) {
      k(n), L();
    },
    get pricesByToken() {
      return r();
    },
    set pricesByToken(n) {
      r(n), L();
    },
    $set: me,
    $on: (n, v) => ce(a, n, v)
  };
  ke();
  var d = Ie(), P = oe(d);
  {
    var x = (n) => {
      var v = Bt(), s = W(v);
      Je(s, {}), q(v), D(n, v);
    }, B = (n) => {
      {
        let v = le(() => (t(z), O(re), t(h), t(R), f(), O(ie), O(se), O(p()), O(w()), O(k()), ae(() => ({
          formattedBalance: t(z),
          balance: Number((+re.formatUnits(BigInt(t(h)), t(R))).toFixed(2)),
          credAlias: f()?.ui_settings.cred_alias,
          onPay: e,
          onGetCred: () => ie.set(se.WALLET),
          totalToPay: (+re.formatUnits(p(), t(R))).toFixed(2),
          isLoading: w(),
          isPaymentDisabled: !Number(t(h)) || BigInt(p()) > t(h) || k()
        }))));
        He(n, {
          get options() {
            return t(v);
          }
        });
      }
    };
    ye(P, (n) => {
      t(T) ? n(x) : n(B, !1);
    });
  }
  D(m, d);
  var S = fe(l);
  return u(), S;
}
const Ft = /* @__PURE__ */ JSON.parse('[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint8","name":"_platformFee","type":"uint8"},{"internalType":"uint8","name":"_defaultAgencyFee","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceToken","type":"uint256"}],"name":"Redeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"addAvailableCurrencyTokenContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"addOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"buyWithEther","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"currencyTokenContract","type":"address"}],"name":"buyWithToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"buyWithToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"clearOwners","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAgencyFee","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAvailableCurrencyTokenContractsList","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBeneficiaryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDefaultCurrencyTokenContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDescription","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"}],"name":"getLicensePriceEther","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"}],"name":"getLicensePriceFiat","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"}],"name":"getLicensePriceToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwners","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPriceEther","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPriceFiat","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"currencyContract","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPriceToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPriceToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenLicenseInfo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTrustedForwarder","outputs":[{"internalType":"address","name":"forwarder","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"image","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"isAvailableCurrencyTokenContract","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"string","name":"tokenURI","type":"string"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mintBatch","outputs":[{"internalType":"uint256[]","name":"arr","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"string","name":"tokenURI","type":"string"},{"internalType":"string","name":"licenseInfo","type":"string"},{"internalType":"uint256","name":"fullLicensePriceFiat","type":"uint256"},{"internalType":"uint256","name":"fullLicensePriceToken","type":"uint256"},{"internalType":"uint256","name":"fullLicensePriceEther","type":"uint256"},{"internalType":"uint256","name":"timeLicensePriceFiat","type":"uint256"},{"internalType":"uint256","name":"timeLicensePriceToken","type":"uint256"},{"internalType":"uint256","name":"timeLicensePriceEther","type":"uint256"},{"internalType":"uint256","name":"oneTimeLicensePriceFiat","type":"uint256"},{"internalType":"uint256","name":"oneTimeLicensePriceToken","type":"uint256"},{"internalType":"uint256","name":"oneTimeLicensePriceEther","type":"uint256"}],"name":"mintWithPrices","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nonceUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"platformAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"platformFee","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"publisherAgency","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"publisherAgencyFee","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"priceToken","type":"uint256"},{"internalType":"string","name":"licenseInfo","type":"string"},{"internalType":"string","name":"uri","type":"string"}],"internalType":"struct ContentNftContract.ContentNFTVoucher","name":"voucher","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"removeAvailableCurrencyTokenContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"removeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"setBaseUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"addr","type":"address"}],"name":"setBeneficiaryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"agencyFee","type":"uint8"}],"name":"setDefaultAgencyFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"}],"name":"setDefaultCurrencyTokenContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"description","type":"string"}],"name":"setDescription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newImage","type":"string"}],"name":"setImage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"},{"internalType":"uint256","name":"priceEther","type":"uint256"}],"name":"setLicensePriceEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"},{"internalType":"uint256","name":"priceFiat","type":"uint256"}],"name":"setLicensePriceFiat","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum ContentNftTypes.LicenseType","name":"licenseType","type":"uint8"},{"internalType":"uint256","name":"priceToken","type":"uint256"}],"name":"setLicensePriceToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"newOwner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setPlatformAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"fee","type":"uint8"}],"name":"setPlatformFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceFiat","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"currencyContract","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"publisher","type":"address"},{"internalType":"address","name":"agency","type":"address"}],"name":"setPublisherAgency","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"publisher","type":"address"},{"internalType":"uint8","name":"agencyFee","type":"uint8"}],"name":"setPublisherAgencyFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newSymbol","type":"string"}],"name":"setSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"licenseInfo","type":"string"}],"name":"setTokenLicenseInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"_tokenURI","type":"string"}],"name":"setTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"string","name":"_tokenURI","type":"string"}],"name":"setTokenURIByIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_forwarder","type":"address"}],"name":"setTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenURIByIndex","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}]');
var Nt = G('<div slot="credit-card"><!></div>'), Ot = G('<div slot="cred-balance"><!></div>'), Dt = G("<!> <!>", 1);
function tt(m, a) {
  if (new.target) return de({ component: tt, ...m });
  Te(a, !1);
  const i = () => ue(we, "$configStore", p), f = () => ue(Ye, "$providerStore", p), g = () => ue(dt, "$contractsStore", p), u = () => ue(Le, "$userStore", p), b = () => ue(ne, "$pageOptsStore", p), [p, w] = Fe();
  var k = this && this.__awaiter || function(c, e, l, d) {
    function P(x) {
      return x instanceof l ? x : new l(function(B) {
        B(x);
      });
    }
    return new (l || (l = Promise))(function(x, B) {
      function S(s) {
        try {
          v(d.next(s));
        } catch (I) {
          B(I);
        }
      }
      function n(s) {
        try {
          v(d.throw(s));
        } catch (I) {
          B(I);
        }
      }
      function v(s) {
        s.done ? x(s.value) : P(s.value).then(S, n);
      }
      v((d = d.apply(c, e || [])).next());
    });
  };
  const { close: r } = J(Ae), E = J(we).chainId;
  let y = F(0), o = F(0), M = F(!1), T = F(!1), h = F({});
  const z = (c, e, l) => k(void 0, void 0, void 0, function* () {
    let d = 0, P = 0;
    if (l) {
      const S = new re.Contract(c, Ft, f());
      return d = yield S.getLicensePriceFiat(String(e), l).then((n) => Number(n)), P = yield S.getLicensePriceToken(String(e), l).then((n) => Number(n)), [d, P];
    }
    const { credenzaSellableMinAbi: x } = yield import("./abi-DIVtyi6o.js"), B = new re.Contract(c, x, f());
    return d = yield B.getPriceFiat(e).then((S) => Number(S)), P = 0, d === 0 ? [d, P] = yield Promise.all([
      B.getPriceFiat(Pe).then((S) => Number(S)),
      B.getPriceToken(Pe).then((S) => Number(S))
    ]) : P = yield B.getPriceToken(e).then((S) => Number(S)), [d, P];
  }), V = (c) => k(void 0, void 0, void 0, function* () {
    try {
      C(M, !0);
      for (const e of c)
        if (e.contractAddress === g().erc20Cred.address)
          C(y, t(y) + e.amount * 100);
        else {
          const l = e.membershipTokenId || Pe, d = e.tokenId || e.contentTokenId || l;
          let [P, x] = yield z(e.contractAddress, d, e.licenseType);
          e?.amount && e?.amount !== 0 && (P *= e.amount, x *= e.amount), C(y, t(y) + P), C(o, t(o) + x), lt(h, t(h)[`${e.contractAddress}/${d}`] = x);
        }
    } catch (e) {
      ee(te.ERROR, e);
    } finally {
      C(M, !1);
    }
  }), N = ne.subscribe((c) => k(void 0, void 0, void 0, function* () {
    var e, l, d;
    !(!((e = c?.tokens) === null || e === void 0) && e.length) && !(!((l = c?.memberships) === null || l === void 0) && l.length) && !(!((d = c?.licenses) === null || d === void 0) && d.length) || (yield V([
      ...c?.tokens || [],
      ...c?.memberships || [],
      ...c?.licenses || []
    ]));
  }));
  rt(N), pe(() => i(), () => {
    i().chainId !== E && r();
  }), xe();
  var R = {
    $set: me,
    $on: (c, e) => ce(a, c, e)
  };
  ke();
  var $ = Dt(), Z = oe($);
  {
    var H = (c) => {
      var e = Ie(), l = oe(e);
      ct(l, () => import("./ProgressVideo-CP6gx21o.js"), null, (d, P) => {
        var x = Ie(), B = oe(x);
        st(B, () => t(P).default, (S, n) => {
          n(S, {});
        }), D(d, x);
      }), D(c, e);
    };
    ye(Z, (c) => {
      t(T) && c(H);
    });
  }
  var _ = j(Z, 2);
  {
    let c = le(() => (u(), b(), O(ie), O(se), t(y), ae(() => ({
      user: u(),
      title: b().title || "Order Summary",
      subtitle: b().subtitle,
      onBackClick: () => ie.set(se.WALLET),
      isCardDisabled: b().payments?.card?.disabled,
      isCredezaValueDisabled: !t(y) || b().payments?.credenzaStoredValue?.disabled
    }))));
    Ze(_, {
      get options() {
        return t(c);
      },
      get isLoading() {
        return t(T);
      },
      set isLoading(e) {
        C(T, e);
      },
      $$slots: {
        "credit-card": (e, l) => {
          var d = Nt(), P = W(d);
          Xe(P, {
            get priceCents() {
              return t(y);
            },
            get isPriceLoading() {
              return t(M);
            },
            get isLoading() {
              return t(T);
            },
            set isLoading(x) {
              C(T, x);
            },
            $$legacy: !0
          }), q(d), D(e, d);
        },
        "cred-balance": (e, l) => {
          var d = Ot(), P = W(d);
          et(P, {
            get pricesByToken() {
              return t(h);
            },
            get totalPriceToken() {
              return t(o);
            },
            get isPriceLoading() {
              return t(M);
            },
            get isLoading() {
              return t(T);
            },
            set isLoading(x) {
              C(T, x);
            },
            $$legacy: !0
          }), q(d), D(e, d);
        }
      },
      $$legacy: !0
    });
  }
  D(m, $);
  var U = fe(R);
  return w(), U;
}
const Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: tt
}, Symbol.toStringTag, { value: "Module" }));
export {
  Kt as P,
  Jt as g,
  Lt as r
};
//# sourceMappingURL=Payment-x0BHQwG3.js.map
