import { c as E, p as Y, h as st, f as j, i as H, o as B, e as nt, b as I, d as J, u as K, y as Q, s as it, a as ot, A as ct } from "./AssetItem-CFsdMEwW.js";
import { a as lt } from "./index-client-DJaMHbvZ.js";
import { v as N, r as F, I as l, Y as R, A as k, x as L, w as v, D as p, y as x, z as D, t as P, n as z, C as V, bP as W, c4 as dt, c5 as O, G as q, M as U, c6 as vt, L as ut, bh as ft } from "./index-BxjwuJ6T.js";
import { e as X, i as Z } from "./each-BgMcYdMq.js";
import { C as T } from "./ContentHeader-IUWmor6Y.js";
import { L as pt } from "./Loader-BMEbL3GG.js";
var gt = j('<img alt="Asset" class="crtw-w-full crtw-h-full crtw-object-cover"/>'), wt = j('<p class="crtw-text-xl crtw-font-bold crtw-text-gray-900"> <span class="crtw-text-[10px] crtw-text-gray-400 crtw-align-top crtw-uppercase">usd</span></p>'), mt = j('<p class="crtw-text-xs crtw-text-gray-500 crtw-leading-tight"> </p>'), _t = j('<!> <button class="crtw-text-gray-800 crtw-absolute crtw-top-4 crtw-left-4">&larr; Back</button> <div class="crtx-flex crtw-max-w-full crtw-aspect-square crtw-bg-[#B4A7D6] crtw-rounded-sm crtw-mb-4 crtw-overflow-hidden"><!></div> <div class="crtw-space-y-1"><!> <!></div> <div class="crtw-mt-[10px]"><p class="crtw-text-xs crtw-text-gray-400 crtw-leading-tight"> </p> <p class="crtw-text-xs crtw-text-gray-400 crtw-leading-tight"> </p></div>', 1);
function $(g, s) {
  if (new.target) return E({ component: $, ...g });
  N(s, !1);
  let t = Y(s, "asset", 12), u = Y(s, "onClose", 12);
  var c = {
    get asset() {
      return t();
    },
    set asset(a) {
      t(a), z();
    },
    get onClose() {
      return u();
    },
    set onClose(a) {
      u(a), z();
    },
    $set: K,
    $on: (a, o) => J(s, a, o)
  };
  st();
  var y = _t(), w = F(y);
  {
    let a = R(() => (v(t()), p(() => t().metadata?.name ?? ""))), o = R(() => (v(t()), p(() => t().metadata?.description ?? "")));
    T(w, {
      get text() {
        return l(a);
      },
      get description() {
        return l(o);
      }
    });
  }
  var h = k(w, 2), n = k(h, 2), A = L(n);
  {
    var m = (a) => {
      var o = gt();
      D((S) => it(o, "src", S), [
        () => (v(Q), v(t()), p(() => Q(t().metadata?.image || t().metadata?.image_url)))
      ]), I(a, o);
    };
    H(A, (a) => {
      v(t()), p(() => t().metadata?.image || t().metadata?.image_url) && a(m);
    });
  }
  x(n);
  var d = k(n, 2), M = L(d);
  {
    var e = (a) => {
      var o = wt(), S = L(o);
      V(), x(o), D(() => B(S, `${v(t()), p(() => t().metadata?.price) ?? ""} `)), I(a, o);
    };
    H(M, (a) => {
      v(t()), p(() => t().metadata?.price) && a(e);
    });
  }
  var r = k(M, 2);
  X(
    r,
    1,
    () => (v(t()), p(() => Object.entries(t().metadata ?? {}).filter(([a]) => !["image", "image_url", "price", "name", "description"].includes(a)))),
    Z,
    (a, o) => {
      var S = W(() => dt(l(o), 2));
      let et = () => l(S)[0], at = () => l(S)[1];
      var G = mt(), rt = L(G);
      x(G), D(() => B(rt, `${et() ?? ""}: ${at() ?? ""}`)), I(a, G);
    }
  ), x(d);
  var f = k(d, 2), _ = L(f), b = L(_);
  x(_);
  var i = k(_, 2), C = L(i);
  return x(i), x(f), D(() => {
    B(b, `Contract: ${v(t()), p(() => t().contractAddress) ?? ""}`), B(C, `Token Id: ${v(t()), p(() => t().tokenId) ?? ""}`);
  }), nt("click", h, function(...a) {
    u()?.apply(this, a);
  }), I(g, y), P(c);
}
var xt = j(`<!> <div class="crtw-w-full crtw-text-center">You don't have any assets yet.</div>`, 1), yt = j('<!> <div class="crtw-flex crtw-flex-wrap crtw-justify-center crtw-w-full crtw-gap-2"></div>', 1);
function tt(g, s) {
  if (new.target) return E({ component: tt, ...g });
  N(s, !0);
  let t = Y(s, "options", 7), u = Y(s, "isLoading", 7), c = O(null);
  function y() {
    q(c, null);
  }
  var w = {
    get options() {
      return t();
    },
    set options(e) {
      t(e), z();
    },
    get isLoading() {
      return u();
    },
    set isLoading(e) {
      u(e), z();
    },
    $set: K,
    $on: (e, r) => J(s, e, r)
  }, h = ot(), n = F(h);
  {
    var A = (e) => {
      pt(e, {});
    }, m = (e) => {
      $(e, {
        get asset() {
          return l(c);
        },
        onClose: y
      });
    }, d = (e) => {
      var r = xt(), f = F(r);
      T(f, {
        get text() {
          return t().title;
        },
        get description() {
          return t().description;
        }
      }), V(2), I(e, r);
    }, M = (e) => {
      var r = yt(), f = F(r);
      T(f, {
        get text() {
          return t().title;
        },
        get description() {
          return t().description;
        }
      });
      var _ = k(f, 2);
      X(_, 21, () => t().assets, Z, (b, i) => {
        ct(b, {
          get asset() {
            return l(i);
          },
          onSelect: (C) => q(c, C, !0)
        });
      }), x(_), I(e, r);
    };
    H(n, (e) => {
      u() ? e(A) : l(c) ? e(m, 1) : t().assets?.length ? e(M, -1) : e(d, 2);
    });
  }
  return I(g, h), P(w);
}
function ht(g, s) {
  if (new.target) return E({ component: ht, ...g });
  N(s, !0);
  var t = this && this.__awaiter || function(n, A, m, d) {
    function M(e) {
      return e instanceof m ? e : new m(function(r) {
        r(e);
      });
    }
    return new (m || (m = Promise))(function(e, r) {
      function f(i) {
        try {
          b(d.next(i));
        } catch (C) {
          r(C);
        }
      }
      function _(i) {
        try {
          b(d.throw(i));
        } catch (C) {
          r(C);
        }
      }
      function b(i) {
        i.done ? e(i.value) : M(i.value).then(f, _);
      }
      b((d = d.apply(n, A || [])).next());
    });
  };
  const { getAssets: u } = U(vt), c = U(ut).walletAssets;
  let y = O(ft([])), w = O(!1);
  lt(() => t(void 0, void 0, void 0, function* () {
    if (c?.length) {
      q(w, !0);
      try {
        q(y, yield u({ assetsConfig: c, opts: { fetchMetadata: !0 } }), !0);
      } catch {
      }
      q(w, !1);
    }
  }));
  var h = {
    $set: K,
    $on: (n, A) => J(s, n, A)
  };
  {
    let n = W(() => ({ title: "My Assets", description: "", assets: l(y) }));
    tt(g, {
      get options() {
        return l(n);
      },
      get isLoading() {
        return l(w);
      }
    });
  }
  return P(h);
}
export {
  ht as default
};
//# sourceMappingURL=Assets-Bk9Jz9KB.js.map
