@chainrails/react 0.0.31 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -587,68 +587,68 @@ function at() {
587
587
  }
588
588
  });
589
589
  }
590
- function y() {
590
+ function m() {
591
591
  return H || at(), H;
592
592
  }
593
593
  class ct {
594
594
  async getById(e) {
595
- return await y().get("intents/" + e).json();
595
+ return await m().get("intents/" + e).json();
596
596
  }
597
597
  async getForSender(e) {
598
- return await y().get("intents/user/" + e).json();
598
+ return await m().get("intents/user/" + e).json();
599
599
  }
600
600
  async getForAddress(e) {
601
- return await y().get("intents/address/" + e).json();
601
+ return await m().get("intents/address/" + e).json();
602
602
  }
603
603
  async getAll(e) {
604
- return await y().get("intents", { searchParams: e }).json();
604
+ return await m().get("intents", { searchParams: e }).json();
605
605
  }
606
606
  async create(e) {
607
- return await y().post("intents", { json: e }).json();
607
+ return await m().post("intents", { json: e }).json();
608
608
  }
609
609
  async update(e, s) {
610
- return await y().post("intents", { json: s }).json();
610
+ return await m().post("intents", { json: s }).json();
611
611
  }
612
612
  async triggerProcessing(e) {
613
- return await y().post(`intents/${e}/trigger-processing`).json();
613
+ return await m().post(`intents/${e}/trigger-processing`).json();
614
614
  }
615
615
  }
616
616
  class ut {
617
617
  async getFromSpecificBridge(e) {
618
- return await y().get("quotes/single", { searchParams: e }).json();
618
+ return await m().get("quotes/single", { searchParams: e }).json();
619
619
  }
620
620
  async getFromAllBridges(e) {
621
- return await y().get("quotes/multiple", { searchParams: e }).json();
621
+ return await m().get("quotes/multiple", { searchParams: e }).json();
622
622
  }
623
623
  async getBestAcrossBridges(e) {
624
- return await y().get("quotes/best", { searchParams: e }).json();
624
+ return await m().get("quotes/best", { searchParams: e }).json();
625
625
  }
626
626
  async getAll(e) {
627
- return await y().get("quotes/multi-source", { searchParams: e }).json();
627
+ return await m().get("quotes/multi-source", { searchParams: e }).json();
628
628
  }
629
629
  }
630
630
  class lt {
631
631
  async getOptimalRoutes(e) {
632
- return await y().get("router/optimal-route", { searchParams: e }).json();
632
+ return await m().get("router/optimal-route", { searchParams: e }).json();
633
633
  }
634
634
  async getAllSupportedBridges() {
635
- return await y().get("router/supported-bridges/all").json();
635
+ return await m().get("router/supported-bridges/all").json();
636
636
  }
637
637
  async getSupportedBridges(e) {
638
- return await y().get("router/supported-bridges/route", { searchParams: e }).json();
638
+ return await m().get("router/supported-bridges/route", { searchParams: e }).json();
639
639
  }
640
640
  async getSupportedRoutes(e, s) {
641
- return await y().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
641
+ return await m().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
642
642
  }
643
643
  }
644
644
  class ft {
645
645
  async getSupported(e) {
646
- return await y().get("chains", { searchParams: e }).json();
646
+ return await m().get("chains", { searchParams: e }).json();
647
647
  }
648
648
  }
649
649
  class ht {
650
650
  async getClientInfo() {
651
- return await y().get("client/auth/client-info").json();
651
+ return await m().get("client/auth/client-info").json();
652
652
  }
653
653
  }
654
654
  const xt = {
@@ -682,34 +682,34 @@ function Lt(t) {
682
682
  close: a,
683
683
  onCancel: c,
684
684
  onSuccess: u,
685
- session_token: p
686
- } = t, [m, g] = le(!0), w = W(null);
685
+ session_token: d
686
+ } = t, [w, y] = le(!0), g = W(null);
687
687
  F(() => {
688
688
  C();
689
689
  const l = document.body.style.overflow;
690
690
  i ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = l || "";
691
- const d = (f) => {
691
+ const p = (f) => {
692
692
  f.data === "closed" && (a(), c?.()), f.data === "completed" && (window.setTimeout(a, 2e3), u?.());
693
693
  };
694
- return window.addEventListener("message", d), () => {
695
- document.body.style.overflow = l || "", window.removeEventListener("message", d);
694
+ return window.addEventListener("message", p), () => {
695
+ document.body.style.overflow = l || "", window.removeEventListener("message", p);
696
696
  };
697
697
  }, [i, c, u]);
698
698
  function P() {
699
- g(!1), C();
699
+ y(!1), C();
700
700
  }
701
701
  function C() {
702
- if (!p) return;
702
+ if (!d) return;
703
703
  const l = {
704
704
  type: "session",
705
- session_token: p,
705
+ session_token: d,
706
706
  environment: h.getEnv() || z.PRODUCTION
707
707
  };
708
- w.current?.contentWindow?.postMessage(l, "https://app.chainrails.io"), w.current?.contentWindow?.postMessage(l, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
708
+ g.current?.contentWindow?.postMessage(l, "https://app.chainrails.io"), g.current?.contentWindow?.postMessage(l, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
709
709
  }
710
- return p ? /* @__PURE__ */ se("div", {
711
- className: dt("payment-modal-wrapper", m ? "loading" : "not-loading", i ? "open" : "closed"),
712
- children: [m && /* @__PURE__ */ S("div", {
710
+ return d ? /* @__PURE__ */ se("div", {
711
+ className: dt("payment-modal-wrapper", w ? "loading" : "not-loading", i ? "open" : "closed"),
712
+ children: [w && /* @__PURE__ */ S("div", {
713
713
  role: "status",
714
714
  className: "payment-modal-loader",
715
715
  children: /* @__PURE__ */ se("svg", {
@@ -730,9 +730,9 @@ function Lt(t) {
730
730
  allow: "clipboard-read *; clipboard-write *",
731
731
  src: h.getPayModalUrl(r, s, e, n),
732
732
  onLoad: P,
733
- className: `payment-modal ${m ? "invisible" : "visible"}`,
733
+ className: `payment-modal ${w ? "invisible" : "visible"}`,
734
734
  "data-id": n,
735
- ref: w
735
+ ref: g
736
736
  })]
737
737
  }) : /* @__PURE__ */ S(Ue, {});
738
738
  }
@@ -756,8 +756,8 @@ const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) =>
756
756
  if (u || (u = {}, s[A].set(t, u)), a === v)
757
757
  u[v] = !0;
758
758
  else {
759
- let p = u[a];
760
- p || (p = /* @__PURE__ */ new Set(), u[a] = p), p.add(c);
759
+ let d = u[a];
760
+ d || (d = /* @__PURE__ */ new Set(), u[a] = d), d.add(c);
761
761
  }
762
762
  }
763
763
  }, i = () => {
@@ -831,25 +831,25 @@ const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) =>
831
831
  $.set(t, e);
832
832
  }, bt = (t, e, s) => {
833
833
  const r = [], n = /* @__PURE__ */ new WeakSet(), i = (o, a) => {
834
- var c, u, p;
834
+ var c, u, d;
835
835
  if (n.has(o))
836
836
  return;
837
837
  _(o) && n.add(o);
838
- const m = _(o) && e.get(Z(o));
839
- if (m) {
840
- if ((c = m[J]) === null || c === void 0 || c.forEach((g) => {
841
- const w = `:has(${String(g)})`;
842
- r.push(a ? [...a, w] : [w]);
843
- }), m[v] === !0) {
844
- const g = ":ownKeys";
838
+ const w = _(o) && e.get(Z(o));
839
+ if (w) {
840
+ if ((c = w[J]) === null || c === void 0 || c.forEach((y) => {
841
+ const g = `:has(${String(y)})`;
845
842
  r.push(a ? [...a, g] : [g]);
843
+ }), w[v] === !0) {
844
+ const y = ":ownKeys";
845
+ r.push(a ? [...a, y] : [y]);
846
846
  } else
847
- (u = m[G]) === null || u === void 0 || u.forEach((g) => {
848
- const w = `:hasOwn(${String(g)})`;
849
- r.push(a ? [...a, w] : [w]);
847
+ (u = w[G]) === null || u === void 0 || u.forEach((y) => {
848
+ const g = `:hasOwn(${String(y)})`;
849
+ r.push(a ? [...a, g] : [g]);
850
850
  });
851
- (p = m[X]) === null || p === void 0 || p.forEach((g) => {
852
- "value" in (Object.getOwnPropertyDescriptor(o, g) || {}) && i(o[g], a ? [...a, g] : [g]);
851
+ (d = w[X]) === null || d === void 0 || d.forEach((y) => {
852
+ "value" in (Object.getOwnPropertyDescriptor(o, y) || {}) && i(o[y], a ? [...a, y] : [y]);
853
853
  });
854
854
  } else a && r.push(a);
855
855
  };
@@ -894,8 +894,8 @@ const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) =>
894
894
  if (c && (ce(u, o) || j.has(o) && ce(u, j.get(o))))
895
895
  return !0;
896
896
  s(i), Q(o) && (o = Rt(o) || o);
897
- const p = !E.has(o) && At(o) ? Oe(o) : o;
898
- return e(i, p), Reflect.set(n, i, p, a), r(["set", [i], o, u]), !0;
897
+ const d = !E.has(o) && At(o) ? Oe(o) : o;
898
+ return e(i, d), Reflect.set(n, i, d, a), r(["set", [i], o, u]), !0;
899
899
  }
900
900
  }), E = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakSet(), ae = /* @__PURE__ */ new WeakMap(), L = [1], j = /* @__PURE__ */ new WeakMap();
901
901
  let ce = Object.is, St = (t, e) => new Proxy(t, e), At = Et, vt = ve, Ot = Pt;
@@ -906,18 +906,18 @@ function Oe(t = {}) {
906
906
  if (e)
907
907
  return e;
908
908
  let s = L[0];
909
- const r = /* @__PURE__ */ new Set(), n = (l, d = ++L[0]) => {
910
- s !== d && (i = s = d, r.forEach((f) => f(l, d)));
909
+ const r = /* @__PURE__ */ new Set(), n = (l, p = ++L[0]) => {
910
+ s !== p && (i = s = p, r.forEach((f) => f(l, p)));
911
911
  };
912
912
  let i = s;
913
- const o = (l = L[0]) => (i !== l && (i = l, c.forEach(([d]) => {
914
- const f = d[1](l);
913
+ const o = (l = L[0]) => (i !== l && (i = l, c.forEach(([p]) => {
914
+ const f = p[1](l);
915
915
  f > s && (s = f);
916
- })), s), a = (l) => (d, f) => {
917
- const T = [...d];
916
+ })), s), a = (l) => (p, f) => {
917
+ const T = [...p];
918
918
  T[1] = [l, ...T[1]], n(T, f);
919
- }, c = /* @__PURE__ */ new Map(), u = (l, d) => {
920
- const f = !ee.has(d) && E.get(d);
919
+ }, c = /* @__PURE__ */ new Map(), u = (l, p) => {
920
+ const f = !ee.has(p) && E.get(p);
921
921
  if (f) {
922
922
  if ((U ? "production" : void 0) !== "production" && c.has(l))
923
923
  throw new Error("prop listener already exists");
@@ -927,11 +927,11 @@ function Oe(t = {}) {
927
927
  } else
928
928
  c.set(l, [f]);
929
929
  }
930
- }, p = (l) => {
931
- var d;
930
+ }, d = (l) => {
931
+ var p;
932
932
  const f = c.get(l);
933
- f && (c.delete(l), (d = f[1]) == null || d.call(f));
934
- }, m = (l) => (r.add(l), r.size === 1 && c.forEach(([f, T], k) => {
933
+ f && (c.delete(l), (p = f[1]) == null || p.call(f));
934
+ }, w = (l) => (r.add(l), r.size === 1 && c.forEach(([f, T], k) => {
935
935
  if ((U ? "production" : void 0) !== "production" && T)
936
936
  throw new Error("remove already exists");
937
937
  const Ce = f[2](a(k));
@@ -941,22 +941,22 @@ function Oe(t = {}) {
941
941
  T && (T(), c.set(k, [f]));
942
942
  });
943
943
  });
944
- let g = !0;
945
- const w = Ot(
946
- () => g,
944
+ let y = !0;
945
+ const g = Ot(
946
+ () => y,
947
947
  u,
948
- p,
948
+ d,
949
949
  n
950
- ), P = St(t, w);
950
+ ), P = St(t, g);
951
951
  j.set(t, P);
952
- const C = [t, o, m];
952
+ const C = [t, o, w];
953
953
  return E.set(P, C), Reflect.ownKeys(t).forEach((l) => {
954
- const d = Object.getOwnPropertyDescriptor(
954
+ const p = Object.getOwnPropertyDescriptor(
955
955
  t,
956
956
  l
957
957
  );
958
- "value" in d && d.writable && (P[l] = t[l]);
959
- }), g = !1, P;
958
+ "value" in p && p.writable && (P[l] = t[l]);
959
+ }), y = !1, P;
960
960
  }
961
961
  function Ct(t, e, s) {
962
962
  const r = E.get(t);
@@ -964,8 +964,8 @@ function Ct(t, e, s) {
964
964
  let n;
965
965
  const i = [], o = r[2];
966
966
  let a = !1;
967
- const u = o((p) => {
968
- i.push(p), n || (n = Promise.resolve().then(() => {
967
+ const u = o((d) => {
968
+ i.push(d), n || (n = Promise.resolve().then(() => {
969
969
  n = void 0, a && e(i.splice(0));
970
970
  }));
971
971
  });
@@ -1027,38 +1027,50 @@ const R = Oe({
1027
1027
  error: null
1028
1028
  });
1029
1029
  function Dt({
1030
- url: t,
1031
- params: e,
1032
- callbacks: s
1030
+ auth_url: t,
1031
+ chain: e,
1032
+ token: s,
1033
+ amount: r,
1034
+ to: n,
1035
+ onCancel: i,
1036
+ onSuccess: o
1033
1037
  }) {
1034
- const r = Ut(R), [n, i] = le(!1);
1035
- function o() {
1036
- i(!0);
1038
+ const a = Ut(R), [c, u] = le(!1);
1039
+ function d() {
1040
+ u(!0);
1037
1041
  }
1038
- function a() {
1039
- i(!1);
1042
+ function w() {
1043
+ u(!1);
1040
1044
  }
1041
- const c = () => {
1045
+ const y = () => {
1042
1046
  R.isPending = !0, R.error = null, fetch(t, {
1043
1047
  method: "POST",
1044
1048
  headers: {
1045
1049
  "Content-Type": "application/json"
1046
1050
  },
1047
1051
  body: JSON.stringify({
1048
- amount: e?.amount
1052
+ chain: e,
1053
+ token: s,
1054
+ amount: r,
1055
+ to: n
1049
1056
  })
1050
- }).then((u) => u.json()).then((u) => {
1051
- R.data = u, s?.onSuccess?.(), R.isPending = !1;
1052
- }).catch((u) => {
1053
- R.error = u?.toString(), s?.onError?.(), R.isPending = !1;
1057
+ }).then((g) => g.json()).then((g) => {
1058
+ R.data = g, R.isPending = !1;
1059
+ }).catch((g) => {
1060
+ R.error = g?.toString(), R.isPending = !1;
1054
1061
  });
1055
1062
  };
1056
- return F(c, []), {
1057
- ...r,
1058
- isOpen: n,
1059
- open: o,
1060
- close: a,
1061
- refetch: c
1063
+ return F(y, []), {
1064
+ ...a,
1065
+ chain: e,
1066
+ token: s,
1067
+ to: n,
1068
+ isOpen: c,
1069
+ open: d,
1070
+ close: w,
1071
+ refetch: y,
1072
+ onSuccess: o,
1073
+ onCancel: i
1062
1074
  };
1063
1075
  }
1064
1076
  export {
@@ -1067,5 +1079,5 @@ export {
1067
1079
  ot as chains,
1068
1080
  xt as crapi,
1069
1081
  it as tokens,
1070
- Dt as useGetSessionToken
1082
+ Dt as usePaymentSession
1071
1083
  };
@@ -587,68 +587,68 @@ function at() {
587
587
  }
588
588
  });
589
589
  }
590
- function y() {
590
+ function m() {
591
591
  return H || at(), H;
592
592
  }
593
593
  class ct {
594
594
  async getById(e) {
595
- return await y().get("intents/" + e).json();
595
+ return await m().get("intents/" + e).json();
596
596
  }
597
597
  async getForSender(e) {
598
- return await y().get("intents/user/" + e).json();
598
+ return await m().get("intents/user/" + e).json();
599
599
  }
600
600
  async getForAddress(e) {
601
- return await y().get("intents/address/" + e).json();
601
+ return await m().get("intents/address/" + e).json();
602
602
  }
603
603
  async getAll(e) {
604
- return await y().get("intents", { searchParams: e }).json();
604
+ return await m().get("intents", { searchParams: e }).json();
605
605
  }
606
606
  async create(e) {
607
- return await y().post("intents", { json: e }).json();
607
+ return await m().post("intents", { json: e }).json();
608
608
  }
609
609
  async update(e, s) {
610
- return await y().post("intents", { json: s }).json();
610
+ return await m().post("intents", { json: s }).json();
611
611
  }
612
612
  async triggerProcessing(e) {
613
- return await y().post(`intents/${e}/trigger-processing`).json();
613
+ return await m().post(`intents/${e}/trigger-processing`).json();
614
614
  }
615
615
  }
616
616
  class ut {
617
617
  async getFromSpecificBridge(e) {
618
- return await y().get("quotes/single", { searchParams: e }).json();
618
+ return await m().get("quotes/single", { searchParams: e }).json();
619
619
  }
620
620
  async getFromAllBridges(e) {
621
- return await y().get("quotes/multiple", { searchParams: e }).json();
621
+ return await m().get("quotes/multiple", { searchParams: e }).json();
622
622
  }
623
623
  async getBestAcrossBridges(e) {
624
- return await y().get("quotes/best", { searchParams: e }).json();
624
+ return await m().get("quotes/best", { searchParams: e }).json();
625
625
  }
626
626
  async getAll(e) {
627
- return await y().get("quotes/multi-source", { searchParams: e }).json();
627
+ return await m().get("quotes/multi-source", { searchParams: e }).json();
628
628
  }
629
629
  }
630
630
  class lt {
631
631
  async getOptimalRoutes(e) {
632
- return await y().get("router/optimal-route", { searchParams: e }).json();
632
+ return await m().get("router/optimal-route", { searchParams: e }).json();
633
633
  }
634
634
  async getAllSupportedBridges() {
635
- return await y().get("router/supported-bridges/all").json();
635
+ return await m().get("router/supported-bridges/all").json();
636
636
  }
637
637
  async getSupportedBridges(e) {
638
- return await y().get("router/supported-bridges/route", { searchParams: e }).json();
638
+ return await m().get("router/supported-bridges/route", { searchParams: e }).json();
639
639
  }
640
640
  async getSupportedRoutes(e, s) {
641
- return await y().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
641
+ return await m().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
642
642
  }
643
643
  }
644
644
  class ft {
645
645
  async getSupported(e) {
646
- return await y().get("chains", { searchParams: e }).json();
646
+ return await m().get("chains", { searchParams: e }).json();
647
647
  }
648
648
  }
649
649
  class ht {
650
650
  async getClientInfo() {
651
- return await y().get("client/auth/client-info").json();
651
+ return await m().get("client/auth/client-info").json();
652
652
  }
653
653
  }
654
654
  const xt = {
@@ -682,34 +682,34 @@ function Lt(t) {
682
682
  close: a,
683
683
  onCancel: c,
684
684
  onSuccess: u,
685
- session_token: p
686
- } = t, [m, g] = le(!0), w = W(null);
685
+ session_token: d
686
+ } = t, [w, y] = le(!0), g = W(null);
687
687
  F(() => {
688
688
  C();
689
689
  const l = document.body.style.overflow;
690
690
  i ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = l || "";
691
- const d = (f) => {
691
+ const p = (f) => {
692
692
  f.data === "closed" && (a(), c?.()), f.data === "completed" && (window.setTimeout(a, 2e3), u?.());
693
693
  };
694
- return window.addEventListener("message", d), () => {
695
- document.body.style.overflow = l || "", window.removeEventListener("message", d);
694
+ return window.addEventListener("message", p), () => {
695
+ document.body.style.overflow = l || "", window.removeEventListener("message", p);
696
696
  };
697
697
  }, [i, c, u]);
698
698
  function P() {
699
- g(!1), C();
699
+ y(!1), C();
700
700
  }
701
701
  function C() {
702
- if (!p) return;
702
+ if (!d) return;
703
703
  const l = {
704
704
  type: "session",
705
- session_token: p,
705
+ session_token: d,
706
706
  environment: h.getEnv() || z.PRODUCTION
707
707
  };
708
- w.current?.contentWindow?.postMessage(l, "https://app.chainrails.io"), w.current?.contentWindow?.postMessage(l, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
708
+ g.current?.contentWindow?.postMessage(l, "https://app.chainrails.io"), g.current?.contentWindow?.postMessage(l, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
709
709
  }
710
- return p ? /* @__PURE__ */ se("div", {
711
- className: dt("payment-modal-wrapper", m ? "loading" : "not-loading", i ? "open" : "closed"),
712
- children: [m && /* @__PURE__ */ S("div", {
710
+ return d ? /* @__PURE__ */ se("div", {
711
+ className: dt("payment-modal-wrapper", w ? "loading" : "not-loading", i ? "open" : "closed"),
712
+ children: [w && /* @__PURE__ */ S("div", {
713
713
  role: "status",
714
714
  className: "payment-modal-loader",
715
715
  children: /* @__PURE__ */ se("svg", {
@@ -730,9 +730,9 @@ function Lt(t) {
730
730
  allow: "clipboard-read *; clipboard-write *",
731
731
  src: h.getPayModalUrl(r, s, e, n),
732
732
  onLoad: P,
733
- className: `payment-modal ${m ? "invisible" : "visible"}`,
733
+ className: `payment-modal ${w ? "invisible" : "visible"}`,
734
734
  "data-id": n,
735
- ref: w
735
+ ref: g
736
736
  })]
737
737
  }) : /* @__PURE__ */ S(Ue, {});
738
738
  }
@@ -756,8 +756,8 @@ const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) =>
756
756
  if (u || (u = {}, s[A].set(t, u)), a === v)
757
757
  u[v] = !0;
758
758
  else {
759
- let p = u[a];
760
- p || (p = /* @__PURE__ */ new Set(), u[a] = p), p.add(c);
759
+ let d = u[a];
760
+ d || (d = /* @__PURE__ */ new Set(), u[a] = d), d.add(c);
761
761
  }
762
762
  }
763
763
  }, i = () => {
@@ -831,25 +831,25 @@ const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) =>
831
831
  $.set(t, e);
832
832
  }, bt = (t, e, s) => {
833
833
  const r = [], n = /* @__PURE__ */ new WeakSet(), i = (o, a) => {
834
- var c, u, p;
834
+ var c, u, d;
835
835
  if (n.has(o))
836
836
  return;
837
837
  _(o) && n.add(o);
838
- const m = _(o) && e.get(Z(o));
839
- if (m) {
840
- if ((c = m[J]) === null || c === void 0 || c.forEach((g) => {
841
- const w = `:has(${String(g)})`;
842
- r.push(a ? [...a, w] : [w]);
843
- }), m[v] === !0) {
844
- const g = ":ownKeys";
838
+ const w = _(o) && e.get(Z(o));
839
+ if (w) {
840
+ if ((c = w[J]) === null || c === void 0 || c.forEach((y) => {
841
+ const g = `:has(${String(y)})`;
845
842
  r.push(a ? [...a, g] : [g]);
843
+ }), w[v] === !0) {
844
+ const y = ":ownKeys";
845
+ r.push(a ? [...a, y] : [y]);
846
846
  } else
847
- (u = m[G]) === null || u === void 0 || u.forEach((g) => {
848
- const w = `:hasOwn(${String(g)})`;
849
- r.push(a ? [...a, w] : [w]);
847
+ (u = w[G]) === null || u === void 0 || u.forEach((y) => {
848
+ const g = `:hasOwn(${String(y)})`;
849
+ r.push(a ? [...a, g] : [g]);
850
850
  });
851
- (p = m[X]) === null || p === void 0 || p.forEach((g) => {
852
- "value" in (Object.getOwnPropertyDescriptor(o, g) || {}) && i(o[g], a ? [...a, g] : [g]);
851
+ (d = w[X]) === null || d === void 0 || d.forEach((y) => {
852
+ "value" in (Object.getOwnPropertyDescriptor(o, y) || {}) && i(o[y], a ? [...a, y] : [y]);
853
853
  });
854
854
  } else a && r.push(a);
855
855
  };
@@ -894,8 +894,8 @@ const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) =>
894
894
  if (c && (ce(u, o) || j.has(o) && ce(u, j.get(o))))
895
895
  return !0;
896
896
  s(i), Q(o) && (o = Rt(o) || o);
897
- const p = !E.has(o) && At(o) ? Oe(o) : o;
898
- return e(i, p), Reflect.set(n, i, p, a), r(["set", [i], o, u]), !0;
897
+ const d = !E.has(o) && At(o) ? Oe(o) : o;
898
+ return e(i, d), Reflect.set(n, i, d, a), r(["set", [i], o, u]), !0;
899
899
  }
900
900
  }), E = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakSet(), ae = /* @__PURE__ */ new WeakMap(), L = [1], j = /* @__PURE__ */ new WeakMap();
901
901
  let ce = Object.is, St = (t, e) => new Proxy(t, e), At = Et, vt = ve, Ot = Pt;
@@ -906,18 +906,18 @@ function Oe(t = {}) {
906
906
  if (e)
907
907
  return e;
908
908
  let s = L[0];
909
- const r = /* @__PURE__ */ new Set(), n = (l, d = ++L[0]) => {
910
- s !== d && (i = s = d, r.forEach((f) => f(l, d)));
909
+ const r = /* @__PURE__ */ new Set(), n = (l, p = ++L[0]) => {
910
+ s !== p && (i = s = p, r.forEach((f) => f(l, p)));
911
911
  };
912
912
  let i = s;
913
- const o = (l = L[0]) => (i !== l && (i = l, c.forEach(([d]) => {
914
- const f = d[1](l);
913
+ const o = (l = L[0]) => (i !== l && (i = l, c.forEach(([p]) => {
914
+ const f = p[1](l);
915
915
  f > s && (s = f);
916
- })), s), a = (l) => (d, f) => {
917
- const T = [...d];
916
+ })), s), a = (l) => (p, f) => {
917
+ const T = [...p];
918
918
  T[1] = [l, ...T[1]], n(T, f);
919
- }, c = /* @__PURE__ */ new Map(), u = (l, d) => {
920
- const f = !ee.has(d) && E.get(d);
919
+ }, c = /* @__PURE__ */ new Map(), u = (l, p) => {
920
+ const f = !ee.has(p) && E.get(p);
921
921
  if (f) {
922
922
  if ((U ? "production" : void 0) !== "production" && c.has(l))
923
923
  throw new Error("prop listener already exists");
@@ -927,11 +927,11 @@ function Oe(t = {}) {
927
927
  } else
928
928
  c.set(l, [f]);
929
929
  }
930
- }, p = (l) => {
931
- var d;
930
+ }, d = (l) => {
931
+ var p;
932
932
  const f = c.get(l);
933
- f && (c.delete(l), (d = f[1]) == null || d.call(f));
934
- }, m = (l) => (r.add(l), r.size === 1 && c.forEach(([f, T], k) => {
933
+ f && (c.delete(l), (p = f[1]) == null || p.call(f));
934
+ }, w = (l) => (r.add(l), r.size === 1 && c.forEach(([f, T], k) => {
935
935
  if ((U ? "production" : void 0) !== "production" && T)
936
936
  throw new Error("remove already exists");
937
937
  const Ce = f[2](a(k));
@@ -941,22 +941,22 @@ function Oe(t = {}) {
941
941
  T && (T(), c.set(k, [f]));
942
942
  });
943
943
  });
944
- let g = !0;
945
- const w = Ot(
946
- () => g,
944
+ let y = !0;
945
+ const g = Ot(
946
+ () => y,
947
947
  u,
948
- p,
948
+ d,
949
949
  n
950
- ), P = St(t, w);
950
+ ), P = St(t, g);
951
951
  j.set(t, P);
952
- const C = [t, o, m];
952
+ const C = [t, o, w];
953
953
  return E.set(P, C), Reflect.ownKeys(t).forEach((l) => {
954
- const d = Object.getOwnPropertyDescriptor(
954
+ const p = Object.getOwnPropertyDescriptor(
955
955
  t,
956
956
  l
957
957
  );
958
- "value" in d && d.writable && (P[l] = t[l]);
959
- }), g = !1, P;
958
+ "value" in p && p.writable && (P[l] = t[l]);
959
+ }), y = !1, P;
960
960
  }
961
961
  function Ct(t, e, s) {
962
962
  const r = E.get(t);
@@ -964,8 +964,8 @@ function Ct(t, e, s) {
964
964
  let n;
965
965
  const i = [], o = r[2];
966
966
  let a = !1;
967
- const u = o((p) => {
968
- i.push(p), n || (n = Promise.resolve().then(() => {
967
+ const u = o((d) => {
968
+ i.push(d), n || (n = Promise.resolve().then(() => {
969
969
  n = void 0, a && e(i.splice(0));
970
970
  }));
971
971
  });
@@ -1027,38 +1027,50 @@ const R = Oe({
1027
1027
  error: null
1028
1028
  });
1029
1029
  function Dt({
1030
- url: t,
1031
- params: e,
1032
- callbacks: s
1030
+ auth_url: t,
1031
+ chain: e,
1032
+ token: s,
1033
+ amount: r,
1034
+ to: n,
1035
+ onCancel: i,
1036
+ onSuccess: o
1033
1037
  }) {
1034
- const r = Ut(R), [n, i] = le(!1);
1035
- function o() {
1036
- i(!0);
1038
+ const a = Ut(R), [c, u] = le(!1);
1039
+ function d() {
1040
+ u(!0);
1037
1041
  }
1038
- function a() {
1039
- i(!1);
1042
+ function w() {
1043
+ u(!1);
1040
1044
  }
1041
- const c = () => {
1045
+ const y = () => {
1042
1046
  R.isPending = !0, R.error = null, fetch(t, {
1043
1047
  method: "POST",
1044
1048
  headers: {
1045
1049
  "Content-Type": "application/json"
1046
1050
  },
1047
1051
  body: JSON.stringify({
1048
- amount: e?.amount
1052
+ chain: e,
1053
+ token: s,
1054
+ amount: r,
1055
+ to: n
1049
1056
  })
1050
- }).then((u) => u.json()).then((u) => {
1051
- R.data = u, s?.onSuccess?.(), R.isPending = !1;
1052
- }).catch((u) => {
1053
- R.error = u?.toString(), s?.onError?.(), R.isPending = !1;
1057
+ }).then((g) => g.json()).then((g) => {
1058
+ R.data = g, R.isPending = !1;
1059
+ }).catch((g) => {
1060
+ R.error = g?.toString(), R.isPending = !1;
1054
1061
  });
1055
1062
  };
1056
- return F(c, []), {
1057
- ...r,
1058
- isOpen: n,
1059
- open: o,
1060
- close: a,
1061
- refetch: c
1063
+ return F(y, []), {
1064
+ ...a,
1065
+ chain: e,
1066
+ token: s,
1067
+ to: n,
1068
+ isOpen: c,
1069
+ open: d,
1070
+ close: w,
1071
+ refetch: y,
1072
+ onSuccess: o,
1073
+ onCancel: i
1062
1074
  };
1063
1075
  }
1064
1076
  export {
@@ -1067,5 +1079,5 @@ export {
1067
1079
  ot as chains,
1068
1080
  xt as crapi,
1069
1081
  it as tokens,
1070
- Dt as useGetSessionToken
1082
+ Dt as usePaymentSession
1071
1083
  };
@@ -1,2 +1,2 @@
1
- (function(w,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],y):(w=typeof globalThis<"u"?globalThis:w||self,y(w.Chainrails={},w.React,w.jsxRuntime))})(this,(function(w,y,E){"use strict";var te=document.createElement("style");te.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
2
- /*$vite$:1*/`,document.head.appendChild(te);class L extends Error{response;request;options;constructor(e,r,s){const n=e.status||e.status===0?e.status:"",i=e.statusText??"",o=`${n} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=e,this.request=r,this.options=s}}class re extends Error{name="NonError";value;constructor(e){let r="Non-error value was thrown";try{typeof e=="string"?r=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(r=e.message)}catch{}super(r),this.value=e}}class D extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const r=e?.cause?e.cause instanceof Error?e.cause:new re(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",r?{cause:r}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const se=(()=>{let t=!1,e=!1;const r=typeof globalThis.ReadableStream=="function",s=typeof globalThis.Request=="function";if(r&&s)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return t&&!e})(),Oe=typeof globalThis.AbortController=="function",ne=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ke=typeof globalThis.ReadableStream=="function",Ne=typeof globalThis.FormData=="function",oe=["get","post","put","patch","head","delete"],qe={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},I=2147483647,_e=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,ie=Symbol("stop");class ae{options;constructor(e){this.options=e}}const xe=t=>new ae(t),Me={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},je={next:!0},Ue={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Le=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[r,s]of t)e+=_e,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,e+=typeof s=="string"?new TextEncoder().encode(s).length:s.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},ce=(t,e,r)=>{let s,n=0;return t.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),s){n+=s.byteLength;let a=e===0?0:n/e;a>=1&&(a=1-Number.EPSILON),r?.({percent:a,totalBytes:Math.max(e,n),transferredBytes:n},s)}s=i},flush(){s&&(n+=s.byteLength,r?.({percent:1,totalBytes:Math.max(e,n),transferredBytes:n},s))}}))},De=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const r=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(ce(t.body,r,e),{status:t.status,statusText:t.statusText,headers:t.headers})},Ie=(t,e,r)=>{if(!t.body)return t;const s=Le(r??t.body);return new Request(t,{duplex:"half",body:ce(t.body,s,e)})},S=t=>t!==null&&typeof t=="object",N=(...t)=>{for(const e of t)if((!S(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return B({},...t)},ue=(t={},e={})=>{const r=new globalThis.Headers(t),s=e instanceof globalThis.Headers,n=new globalThis.Headers(e);for(const[i,o]of n.entries())s&&o==="undefined"||o===void 0?r.delete(i):r.set(i,o);return r};function q(t,e,r){return Object.hasOwn(e,r)&&e[r]===void 0?[]:B(t[r]??[],e[r]??[])}const le=(t={},e={})=>({beforeRequest:q(t,e,"beforeRequest"),beforeRetry:q(t,e,"beforeRetry"),afterResponse:q(t,e,"afterResponse"),beforeError:q(t,e,"beforeError")}),Be=(t,e)=>{const r=new URLSearchParams;for(const s of[t,e])if(s!==void 0)if(s instanceof URLSearchParams)for(const[n,i]of s.entries())r.append(n,i);else if(Array.isArray(s))for(const n of s){if(!Array.isArray(n)||n.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(n[0]),String(n[1]))}else if(S(s))for(const[n,i]of Object.entries(s))i!==void 0&&r.append(n,String(i));else{const n=new URLSearchParams(s);for(const[i,o]of n.entries())r.append(i,o)}return r},B=(...t)=>{let e={},r={},s={},n;const i=[];for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(S(o)){for(let[a,c]of Object.entries(o)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!S(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");e={...e,context:c==null?{}:{...e.context,...c}};continue}if(a==="searchParams"){c==null?n=void 0:n=n===void 0?c:Be(n,c);continue}S(c)&&a in e&&(c=B(e[a],c)),e={...e,[a]:c}}S(o.hooks)&&(s=le(s,o.hooks),e.hooks=s),S(o.headers)&&(r=ue(r,o.headers),e.headers=r)}return n!==void 0&&(e.searchParams=n),i.length>0&&(i.length===1?e.signal=i[0]:ne?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e.context===void 0&&(e.context={}),e},He=t=>oe.includes(t)?t.toUpperCase():t,fe={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},$e=(t={})=>{if(typeof t=="number")return{...fe,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...fe,...t}};class H extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function Ke(t,e,r,s){return new Promise((n,i)=>{const o=setTimeout(()=>{r&&r.abort(),i(new H(t))},s.timeout);s.fetch(t,e).then(n).catch(i).then(()=>{clearTimeout(o)})})}async function We(t,{signal:e}){return new Promise((r,s)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(i),s(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",n),r()},t)})}const ze=(t,e)=>{const r={};for(const s in e)Object.hasOwn(e,s)&&!(s in Ue)&&!(s in Me)&&(!(s in t)||s in je)&&(r[s]=e[s]);return r},Fe=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function Ye(t){return t instanceof L||t?.name===L.name}function Ve(t){return t instanceof H||t?.name===H.name}class C{static create(e,r){const s=new C(e,r),n=async()=>{if(typeof s.#e.timeout=="number"&&s.#e.timeout>I)throw new RangeError(`The \`timeout\` option cannot be greater than ${I}`);await Promise.resolve();let o=await s.#y();for(const a of s.#e.hooks.afterResponse){const c=s.#l(o.clone()),u=await a(s.request,s.#a(),c,{retryCount:s.#r});if(u instanceof globalThis.Response&&(o=u),u instanceof ae)throw await Promise.all([c.body?.cancel(),o.body?.cancel()]),new D(u.options)}if(s.#l(o),!o.ok&&(typeof s.#e.throwHttpErrors=="function"?s.#e.throwHttpErrors(o.status):s.#e.throwHttpErrors)){let a=new L(o,s.request,s.#a());for(const c of s.#e.hooks.beforeError)a=await c(a,{retryCount:s.#r});throw a}if(s.#e.onDownloadProgress){if(typeof s.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!ke)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return De(o.clone(),s.#e.onDownloadProgress)}return o},i=s.#f(n).finally(async()=>{const o=s.#o,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),s.request.bodyUsed||a.push(s.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(qe))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{s.request.headers.set("accept",s.request.headers.get("accept")||a);const c=await i;if(o==="json"){if(c.status===204)return"";const u=await c.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return c[o]()});return i}static#d(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0)):e}request;#s;#r=0;#t;#e;#o;#n;#i;constructor(e,r={}){if(this.#t=e,this.#e={...r,headers:ue(this.#t.headers,r.headers),hooks:le({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:He(r.method??this.#t.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:$e(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}Oe&&ne&&(this.#n=this.#e.signal??this.#t.signal,this.#s=new globalThis.AbortController,this.#e.signal=this.#n?AbortSignal.any([this.#n,this.#s.signal]):this.#s.signal),se&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const s=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(Ne&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!s&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),Fe(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(C.#d(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!se)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#h(this.request,this.#e.body??void 0)}}#c(){const e=this.#e.retry.delay(this.#r);let r=e;return this.#e.retry.jitter===!0?r=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(r=this.#e.retry.jitter(e),(!Number.isFinite(r)||r<0)&&(r=e)),Math.min(this.#e.retry.backoffLimit,r)}async#p(e){if(this.#r++,this.#r>this.#e.retry.limit)throw e;const r=e instanceof Error?e:new re(e);if(r instanceof D)return r.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const s=await this.#e.retry.shouldRetry({error:r,retryCount:this.#r});if(s===!1)throw e;if(s===!0)return this.#c()}if(Ve(e)&&!this.#e.retry.retryOnTimeout)throw e;if(Ye(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const s=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(s&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let n=Number(s)*1e3;Number.isNaN(n)?n=Date.parse(s)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());const i=this.#e.retry.maxRetryAfter??n;return n<i?n:i}if(e.response.status===413)throw e}return this.#c()}#l(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}async#f(e){try{return await e()}catch(r){const s=Math.min(await this.#p(r),I);if(this.#r<1)throw r;if(await We(s,this.#n?{signal:this.#n}:{}),r instanceof D&&r.customRequest){const n=this.#e.signal?new globalThis.Request(r.customRequest,{signal:this.#e.signal}):new globalThis.Request(r.customRequest);this.#u(n)}for(const n of this.#e.hooks.beforeRetry){const i=await n({request:this.request,options:this.#a(),error:r,retryCount:this.#r});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===ie)return}return this.#f(e)}}async#y(){this.#s?.signal.aborted&&(this.#s=new globalThis.AbortController,this.#e.signal=this.#n?AbortSignal.any([this.#n,this.#s.signal]):this.#s.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const r of this.#e.hooks.beforeRequest){const s=await r(this.request,this.#a(),{retryCount:this.#r});if(s instanceof Response)return s;if(s instanceof globalThis.Request){this.#u(s);break}}const e=ze(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,e):Ke(this.#o,e,this.#s,this.#e)}#a(){if(!this.#i){const{hooks:e,...r}=this.#e;this.#i=Object.freeze(r)}return this.#i}#u(e){this.#i=void 0,this.request=this.#h(e)}#h(e,r){return!this.#e.onUploadProgress||!e.body?e:Ie(e,this.#e.onUploadProgress,r??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const $=t=>{const e=(r,s)=>C.create(r,N(t,s));for(const r of oe)e[r]=(s,n)=>C.create(s,N(t,n,{method:r}));return e.create=r=>$(N(r)),e.extend=r=>(typeof r=="function"&&(r=r(t??{})),$(N(t,r))),e.stop=ie,e.retry=xe,e},Je=$();var he=(t=>(t.ARBITRUM="ARBITRUM_MAINNET",t.ARBITRUM_TESTNET="ARBITRUM_TESTNET",t.AVALANCHE="AVALANCHE_MAINNET",t.AVALANCHE_TESTNET="AVALANCHE_TESTNET",t.BASE="BASE_MAINNET",t.BASE_TESTNET="BASE_TESTNET",t.BSC="BSC_MAINNET",t.ETHEREUM="ETHEREUM_MAINNET",t.ETHEREUM_TESTNET="ETHEREUM_TESTNET",t.STARKNET="STARKNET_MAINNET",t))(he||{}),de=(t=>(t.USDC="USDC",t))(de||{}),K=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(K||{});class f{constructor({api_key:e,env:r}){this.api_key=e,this.jwt="",this.env=r??K.PRODUCTION}static async config(e){if(!f.app){if(!e)throw new Error("Please provide an api_key");f.app=new f(e)}return e&&(f.app.api_key=e.api_key,e.env!==void 0&&(f.app.env=e.env),await this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),f.app}static async updateJWT(){try{const e=await(await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({apiKey:f.app.api_key})})).json();this.app.jwt=e.token}catch{}}static getApiKey(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return f.app.api_key}static getSessionKey(){return f.app.jwt}static getEnv(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return f.app.env==="internal"?"staging":f.app.env}static getBaseUrl(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(f.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(e,r,s,n){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const i=f.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",o=n&&n>0?"/pay/":"/deposit/",a=`_chain_/${e}/_token_/${r}/_to_/${s}${n?"/_amount_/"+n*100:""}`;return i+o+a}}let W=null;function Ge(){W=Je.create({prefixUrl:f.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=f.getSessionKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,r)=>r]},retry:{limit:2}})}function g(){return W||Ge(),W}class Xe{async getById(e){return await g().get("intents/"+e).json()}async getForSender(e){return await g().get("intents/user/"+e).json()}async getForAddress(e){return await g().get("intents/address/"+e).json()}async getAll(e){return await g().get("intents",{searchParams:e}).json()}async create(e){return await g().post("intents",{json:e}).json()}async update(e,r){return await g().post("intents",{json:r}).json()}async triggerProcessing(e){return await g().post(`intents/${e}/trigger-processing`).json()}}class Ze{async getFromSpecificBridge(e){return await g().get("quotes/single",{searchParams:e}).json()}async getFromAllBridges(e){return await g().get("quotes/multiple",{searchParams:e}).json()}async getBestAcrossBridges(e){return await g().get("quotes/best",{searchParams:e}).json()}async getAll(e){return await g().get("quotes/multi-source",{searchParams:e}).json()}}class Qe{async getOptimalRoutes(e){return await g().get("router/optimal-route",{searchParams:e}).json()}async getAllSupportedBridges(){return await g().get("router/supported-bridges/all").json()}async getSupportedBridges(e){return await g().get("router/supported-bridges/route",{searchParams:e}).json()}async getSupportedRoutes(e,r){return await g().get("router/supported-bridges/bridge/"+e,{searchParams:r}).json()}}class et{async getSupported(e){return await g().get("chains",{searchParams:e}).json()}}class tt{async getClientInfo(){return await g().get("client/auth/client-info").json()}}const rt={router:new Qe,quotes:new Ze,intents:new Xe,chains:new et,client:new tt};function pe(t){var e,r,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(e=0;e<n;e++)t[e]&&(r=pe(t[e]))&&(s&&(s+=" "),s+=r)}else for(r in t)t[r]&&(s&&(s+=" "),s+=r);return s}function st(){for(var t,e,r=0,s="",n=arguments.length;r<n;r++)(t=arguments[r])&&(e=pe(t))&&(s&&(s+=" "),s+=e);return s}function nt(t){const{to:e,token:r,chain:s,amount:n,isOpen:i,open:o,close:a,onCancel:c,onSuccess:u,session_token:p}=t,[b,m]=y.useState(!0),T=y.useRef(null);y.useEffect(()=>{j();const l=document.body.style.overflow;i?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=l||"";const d=h=>{h.data==="closed"&&(a(),c?.()),h.data==="completed"&&(window.setTimeout(a,2e3),u?.())};return window.addEventListener("message",d),()=>{document.body.style.overflow=l||"",window.removeEventListener("message",d)}},[i,c,u]);function v(){m(!1),j()}function j(){if(!p)return;const l={type:"session",session_token:p,environment:f.getEnv()||K.PRODUCTION};T.current?.contentWindow?.postMessage(l,"https://app.chainrails.io"),T.current?.contentWindow?.postMessage(l,"https://chainrails-frontend-git-staging-horus-labs.vercel.app")}return p?E.jsxs("div",{className:st("payment-modal-wrapper",b?"loading":"not-loading",i?"open":"closed"),children:[b&&E.jsx("div",{role:"status",className:"payment-modal-loader",children:E.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),E.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),E.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:f.getPayModalUrl(s,r,e,n),onLoad:v,className:`payment-modal ${b?"invisible":"visible"}`,"data-id":n,ref:T})]}):E.jsx(E.Fragment,{})}const ot=Symbol(),z=Symbol(),O="a",ye="f",ge="p",me="c",we="t",F="h",k="w",Y="o",V="k";let it=(t,e)=>new Proxy(t,e);const J=Object.getPrototypeOf,G=new WeakMap,be=t=>t&&(G.has(t)?G.get(t):J(t)===Object.prototype||J(t)===Array.prototype),_=t=>typeof t=="object"&&t!==null,at=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),ct=t=>{if(Array.isArray(t))return Array.from(t);const e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(r=>{r.configurable=!0}),Object.create(J(t),e)},ut=(t,e)=>{const r={[ye]:e};let s=!1;const n=(a,c)=>{if(!s){let u=r[O].get(t);if(u||(u={},r[O].set(t,u)),a===k)u[k]=!0;else{let p=u[a];p||(p=new Set,u[a]=p),p.add(c)}}},i=()=>{s=!0,r[O].delete(t)},o={get(a,c){return c===z?t:(n(V,c),Te(Reflect.get(a,c),r[O],r[me],r[we]))},has(a,c){return c===ot?(i(),!0):(n(F,c),Reflect.has(a,c))},getOwnPropertyDescriptor(a,c){return n(Y,c),Reflect.getOwnPropertyDescriptor(a,c)},ownKeys(a){return n(k),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,r]},X=t=>t[z]||t,Te=(t,e,r,s)=>{if(!be(t))return t;let n=s&&s.get(t);if(!n){const c=X(t);at(c)?n=[c,ct(c)]:n=[c],s?.set(t,n)}const[i,o]=n;let a=r&&r.get(i);return(!a||a[1][ye]!==!!o)&&(a=ut(i,!!o),a[1][ge]=it(o||i,a[0]),r&&r.set(i,a)),a[1][O]=e,a[1][me]=r,a[1][we]=s,a[1][ge]},lt=(t,e)=>{const r=Reflect.ownKeys(t),s=Reflect.ownKeys(e);return r.length!==s.length||r.some((n,i)=>n!==s[i])},Re=(t,e,r,s,n=Object.is)=>{if(n(t,e))return!1;if(!_(t)||!_(e))return!0;const i=r.get(X(t));if(!i)return!0;if(s){if(s.get(t)===e)return!1;s.set(t,e)}let o=null;for(const a of i[F]||[])if(o=Reflect.has(t,a)!==Reflect.has(e,a),o)return o;if(i[k]===!0){if(o=lt(t,e),o)return o}else for(const a of i[Y]||[]){const c=!!Reflect.getOwnPropertyDescriptor(t,a),u=!!Reflect.getOwnPropertyDescriptor(e,a);if(o=c!==u,o)return o}for(const a of i[V]||[])if(o=Re(t[a],e[a],r,s,n),o)return o;if(o===null)throw new Error("invalid used");return o},ft=t=>be(t)&&t[z]||null,Ee=(t,e=!0)=>{G.set(t,e)},ht=(t,e,r)=>{const s=[],n=new WeakSet,i=(o,a)=>{var c,u,p;if(n.has(o))return;_(o)&&n.add(o);const b=_(o)&&e.get(X(o));if(b){if((c=b[F])===null||c===void 0||c.forEach(m=>{const T=`:has(${String(m)})`;s.push(a?[...a,T]:[T])}),b[k]===!0){const m=":ownKeys";s.push(a?[...a,m]:[m])}else(u=b[Y])===null||u===void 0||u.forEach(m=>{const T=`:hasOwn(${String(m)})`;s.push(a?[...a,T]:[T])});(p=b[V])===null||p===void 0||p.forEach(m=>{"value"in(Object.getOwnPropertyDescriptor(o,m)||{})&&i(o[m],a?[...a,m]:[m])})}else a&&s.push(a)};return i(t),s},x={},Z=t=>typeof t=="object"&&t!==null,dt=t=>Z(t)&&!Q.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),Se=(t,e)=>{const r=Pe.get(t);if(r?.[0]===e)return r[1];const s=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return Ee(s,!0),Pe.set(t,[e,s]),Reflect.ownKeys(t).forEach(n=>{if(Object.getOwnPropertyDescriptor(s,n))return;const i=Reflect.get(t,n),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,n),a={value:i,enumerable:o,configurable:!0};if(Q.has(i))Ee(i,!1);else if(P.has(i)){const[c,u]=P.get(i);a.value=Se(c,u())}Object.defineProperty(s,n,a)}),Object.preventExtensions(s)},pt=(t,e,r,s)=>({deleteProperty(n,i){const o=Reflect.get(n,i);r(i);const a=Reflect.deleteProperty(n,i);return a&&s(["delete",[i],o]),a},set(n,i,o,a){const c=!t()&&Reflect.has(n,i),u=Reflect.get(n,i,a);if(c&&(Ae(u,o)||M.has(o)&&Ae(u,M.get(o))))return!0;r(i),Z(o)&&(o=ft(o)||o);const p=!P.has(o)&&gt(o)?ve(o):o;return e(i,p),Reflect.set(n,i,p,a),s(["set",[i],o,u]),!0}}),P=new WeakMap,Q=new WeakSet,Pe=new WeakMap,ee=[1],M=new WeakMap;let Ae=Object.is,yt=(t,e)=>new Proxy(t,e),gt=dt,mt=Se,wt=pt;function ve(t={}){if(!Z(t))throw new Error("object required");const e=M.get(t);if(e)return e;let r=ee[0];const s=new Set,n=(l,d=++ee[0])=>{r!==d&&(i=r=d,s.forEach(h=>h(l,d)))};let i=r;const o=(l=ee[0])=>(i!==l&&(i=l,c.forEach(([d])=>{const h=d[1](l);h>r&&(r=h)})),r),a=l=>(d,h)=>{const R=[...d];R[1]=[l,...R[1]],n(R,h)},c=new Map,u=(l,d)=>{const h=!Q.has(d)&&P.get(d);if(h){if((x?"production":void 0)!=="production"&&c.has(l))throw new Error("prop listener already exists");if(s.size){const R=h[2](a(l));c.set(l,[h,R])}else c.set(l,[h])}},p=l=>{var d;const h=c.get(l);h&&(c.delete(l),(d=h[1])==null||d.call(h))},b=l=>(s.add(l),s.size===1&&c.forEach(([h,R],U)=>{if((x?"production":void 0)!=="production"&&R)throw new Error("remove already exists");const At=h[2](a(U));c.set(U,[h,At])}),()=>{s.delete(l),s.size===0&&c.forEach(([h,R],U)=>{R&&(R(),c.set(U,[h]))})});let m=!0;const T=wt(()=>m,u,p,n),v=yt(t,T);M.set(t,v);const j=[t,o,b];return P.set(v,j),Reflect.ownKeys(t).forEach(l=>{const d=Object.getOwnPropertyDescriptor(t,l);"value"in d&&d.writable&&(v[l]=t[l])}),m=!1,v}function bt(t,e,r){const s=P.get(t);(x?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");let n;const i=[],o=s[2];let a=!1;const u=o(p=>{i.push(p),n||(n=Promise.resolve().then(()=>{n=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,u()}}function Ce(t){const e=P.get(t);(x?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[r,s]=e;return mt(r,s())}const Tt={},Rt=(t,e)=>{const r=y.useRef(void 0);y.useEffect(()=>{r.current=ht(t,e)}),y.useDebugValue(r.current)},Et=new WeakMap;function St(t,e){const s=y.useMemo(()=>t&&new WeakMap,[t]),n=y.useRef(void 0);let i=!0;const o=y.useSyncExternalStore(y.useCallback(c=>{const u=bt(t,c);return c(),u},[t,void 0]),()=>{const c=Ce(t);try{if(!i&&n.current&&!Re(n.current,c,s,new WeakMap))return n.current}catch{}return c},()=>Ce(t));i=!1,y.useLayoutEffect(()=>{n.current=o}),(Tt?"production":void 0)!=="production"&&Rt(o,s);const a=y.useMemo(()=>new WeakMap,[]);return Te(o,s,a,Et)}const A=ve({data:null,isPending:!1,error:null});function Pt({url:t,params:e,callbacks:r}){const s=St(A),[n,i]=y.useState(!1);function o(){i(!0)}function a(){i(!1)}const c=()=>{A.isPending=!0,A.error=null,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:e?.amount})}).then(u=>u.json()).then(u=>{A.data=u,r?.onSuccess?.(),A.isPending=!1}).catch(u=>{A.error=u?.toString(),r?.onError?.(),A.isPending=!1})};return y.useEffect(c,[]),{...s,isOpen:n,open:o,close:a,refetch:c}}w.Chainrails=f,w.PaymentModal=nt,w.chains=he,w.crapi=rt,w.tokens=de,w.useGetSessionToken=Pt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(b,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],g):(b=typeof globalThis<"u"?globalThis:b||self,g(b.Chainrails={},b.React,b.jsxRuntime))})(this,(function(b,g,E){"use strict";var te=document.createElement("style");te.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
2
+ /*$vite$:1*/`,document.head.appendChild(te);class L extends Error{response;request;options;constructor(e,s,r){const n=e.status||e.status===0?e.status:"",i=e.statusText??"",o=`${n} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${s.method} ${s.url}`),this.name="HTTPError",this.response=e,this.request=s,this.options=r}}class se extends Error{name="NonError";value;constructor(e){let s="Non-error value was thrown";try{typeof e=="string"?s=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(s=e.message)}catch{}super(s),this.value=e}}class D extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const s=e?.cause?e.cause instanceof Error?e.cause:new se(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",s?{cause:s}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const re=(()=>{let t=!1,e=!1;const s=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(s&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return t&&!e})(),Oe=typeof globalThis.AbortController=="function",ne=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ke=typeof globalThis.ReadableStream=="function",Ne=typeof globalThis.FormData=="function",oe=["get","post","put","patch","head","delete"],qe={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},I=2147483647,_e=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,ie=Symbol("stop");class ae{options;constructor(e){this.options=e}}const xe=t=>new ae(t),Me={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},je={next:!0},Ue={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Le=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[s,r]of t)e+=_e,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length,e+=typeof r=="string"?new TextEncoder().encode(r).length:r.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},ce=(t,e,s)=>{let r,n=0;return t.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),r){n+=r.byteLength;let a=e===0?0:n/e;a>=1&&(a=1-Number.EPSILON),s?.({percent:a,totalBytes:Math.max(e,n),transferredBytes:n},r)}r=i},flush(){r&&(n+=r.byteLength,s?.({percent:1,totalBytes:Math.max(e,n),transferredBytes:n},r))}}))},De=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const s=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(ce(t.body,s,e),{status:t.status,statusText:t.statusText,headers:t.headers})},Ie=(t,e,s)=>{if(!t.body)return t;const r=Le(s??t.body);return new Request(t,{duplex:"half",body:ce(t.body,r,e)})},P=t=>t!==null&&typeof t=="object",N=(...t)=>{for(const e of t)if((!P(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return B({},...t)},ue=(t={},e={})=>{const s=new globalThis.Headers(t),r=e instanceof globalThis.Headers,n=new globalThis.Headers(e);for(const[i,o]of n.entries())r&&o==="undefined"||o===void 0?s.delete(i):s.set(i,o);return s};function q(t,e,s){return Object.hasOwn(e,s)&&e[s]===void 0?[]:B(t[s]??[],e[s]??[])}const le=(t={},e={})=>({beforeRequest:q(t,e,"beforeRequest"),beforeRetry:q(t,e,"beforeRetry"),afterResponse:q(t,e,"afterResponse"),beforeError:q(t,e,"beforeError")}),Be=(t,e)=>{const s=new URLSearchParams;for(const r of[t,e])if(r!==void 0)if(r instanceof URLSearchParams)for(const[n,i]of r.entries())s.append(n,i);else if(Array.isArray(r))for(const n of r){if(!Array.isArray(n)||n.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");s.append(String(n[0]),String(n[1]))}else if(P(r))for(const[n,i]of Object.entries(r))i!==void 0&&s.append(n,String(i));else{const n=new URLSearchParams(r);for(const[i,o]of n.entries())s.append(i,o)}return s},B=(...t)=>{let e={},s={},r={},n;const i=[];for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(P(o)){for(let[a,c]of Object.entries(o)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!P(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");e={...e,context:c==null?{}:{...e.context,...c}};continue}if(a==="searchParams"){c==null?n=void 0:n=n===void 0?c:Be(n,c);continue}P(c)&&a in e&&(c=B(e[a],c)),e={...e,[a]:c}}P(o.hooks)&&(r=le(r,o.hooks),e.hooks=r),P(o.headers)&&(s=ue(s,o.headers),e.headers=s)}return n!==void 0&&(e.searchParams=n),i.length>0&&(i.length===1?e.signal=i[0]:ne?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e.context===void 0&&(e.context={}),e},He=t=>oe.includes(t)?t.toUpperCase():t,fe={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},$e=(t={})=>{if(typeof t=="number")return{...fe,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...fe,...t}};class H extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function Ke(t,e,s,r){return new Promise((n,i)=>{const o=setTimeout(()=>{s&&s.abort(),i(new H(t))},r.timeout);r.fetch(t,e).then(n).catch(i).then(()=>{clearTimeout(o)})})}async function We(t,{signal:e}){return new Promise((s,r)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(i),r(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",n),s()},t)})}const ze=(t,e)=>{const s={};for(const r in e)Object.hasOwn(e,r)&&!(r in Ue)&&!(r in Me)&&(!(r in t)||r in je)&&(s[r]=e[r]);return s},Fe=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function Ye(t){return t instanceof L||t?.name===L.name}function Ve(t){return t instanceof H||t?.name===H.name}class C{static create(e,s){const r=new C(e,s),n=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>I)throw new RangeError(`The \`timeout\` option cannot be greater than ${I}`);await Promise.resolve();let o=await r.#y();for(const a of r.#e.hooks.afterResponse){const c=r.#l(o.clone()),u=await a(r.request,r.#a(),c,{retryCount:r.#s});if(u instanceof globalThis.Response&&(o=u),u instanceof ae)throw await Promise.all([c.body?.cancel(),o.body?.cancel()]),new D(u.options)}if(r.#l(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let a=new L(o,r.request,r.#a());for(const c of r.#e.hooks.beforeError)a=await c(a,{retryCount:r.#s});throw a}if(r.#e.onDownloadProgress){if(typeof r.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!ke)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return De(o.clone(),r.#e.onDownloadProgress)}return o},i=r.#f(n).finally(async()=>{const o=r.#o,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),r.request.bodyUsed||a.push(r.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(qe))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||a);const c=await i;if(o==="json"){if(c.status===204)return"";const u=await c.text();return u===""?"":s.parseJson?s.parseJson(u):JSON.parse(u)}return c[o]()});return i}static#d(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)):e}request;#r;#s=0;#t;#e;#o;#n;#i;constructor(e,s={}){if(this.#t=e,this.#e={...s,headers:ue(this.#t.headers,s.headers),hooks:le({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:He(s.method??this.#t.method??"GET"),prefixUrl:String(s.prefixUrl||""),retry:$e(s.retry),throwHttpErrors:s.throwHttpErrors??!0,timeout:s.timeout??1e4,fetch:s.fetch??globalThis.fetch.bind(globalThis),context:s.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}Oe&&ne&&(this.#n=this.#e.signal??this.#t.signal,this.#r=new globalThis.AbortController,this.#e.signal=this.#n?AbortSignal.any([this.#n,this.#r.signal]):this.#r.signal),re&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const r=s.headers&&new globalThis.Headers(s.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(Ne&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!r&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),Fe(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(C.#d(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!re)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#h(this.request,this.#e.body??void 0)}}#c(){const e=this.#e.retry.delay(this.#s);let s=e;return this.#e.retry.jitter===!0?s=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(s=this.#e.retry.jitter(e),(!Number.isFinite(s)||s<0)&&(s=e)),Math.min(this.#e.retry.backoffLimit,s)}async#p(e){if(this.#s++,this.#s>this.#e.retry.limit)throw e;const s=e instanceof Error?e:new se(e);if(s instanceof D)return s.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const r=await this.#e.retry.shouldRetry({error:s,retryCount:this.#s});if(r===!1)throw e;if(r===!0)return this.#c()}if(Ve(e)&&!this.#e.retry.retryOnTimeout)throw e;if(Ye(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let n=Number(r)*1e3;Number.isNaN(n)?n=Date.parse(r)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());const i=this.#e.retry.maxRetryAfter??n;return n<i?n:i}if(e.response.status===413)throw e}return this.#c()}#l(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}async#f(e){try{return await e()}catch(s){const r=Math.min(await this.#p(s),I);if(this.#s<1)throw s;if(await We(r,this.#n?{signal:this.#n}:{}),s instanceof D&&s.customRequest){const n=this.#e.signal?new globalThis.Request(s.customRequest,{signal:this.#e.signal}):new globalThis.Request(s.customRequest);this.#u(n)}for(const n of this.#e.hooks.beforeRetry){const i=await n({request:this.request,options:this.#a(),error:s,retryCount:this.#s});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===ie)return}return this.#f(e)}}async#y(){this.#r?.signal.aborted&&(this.#r=new globalThis.AbortController,this.#e.signal=this.#n?AbortSignal.any([this.#n,this.#r.signal]):this.#r.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const s of this.#e.hooks.beforeRequest){const r=await s(this.request,this.#a(),{retryCount:this.#s});if(r instanceof Response)return r;if(r instanceof globalThis.Request){this.#u(r);break}}const e=ze(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,e):Ke(this.#o,e,this.#r,this.#e)}#a(){if(!this.#i){const{hooks:e,...s}=this.#e;this.#i=Object.freeze(s)}return this.#i}#u(e){this.#i=void 0,this.request=this.#h(e)}#h(e,s){return!this.#e.onUploadProgress||!e.body?e:Ie(e,this.#e.onUploadProgress,s??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const $=t=>{const e=(s,r)=>C.create(s,N(t,r));for(const s of oe)e[s]=(r,n)=>C.create(r,N(t,n,{method:s}));return e.create=s=>$(N(s)),e.extend=s=>(typeof s=="function"&&(s=s(t??{})),$(N(t,s))),e.stop=ie,e.retry=xe,e},Je=$();var he=(t=>(t.ARBITRUM="ARBITRUM_MAINNET",t.ARBITRUM_TESTNET="ARBITRUM_TESTNET",t.AVALANCHE="AVALANCHE_MAINNET",t.AVALANCHE_TESTNET="AVALANCHE_TESTNET",t.BASE="BASE_MAINNET",t.BASE_TESTNET="BASE_TESTNET",t.BSC="BSC_MAINNET",t.ETHEREUM="ETHEREUM_MAINNET",t.ETHEREUM_TESTNET="ETHEREUM_TESTNET",t.STARKNET="STARKNET_MAINNET",t))(he||{}),de=(t=>(t.USDC="USDC",t))(de||{}),K=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(K||{});class f{constructor({api_key:e,env:s}){this.api_key=e,this.jwt="",this.env=s??K.PRODUCTION}static async config(e){if(!f.app){if(!e)throw new Error("Please provide an api_key");f.app=new f(e)}return e&&(f.app.api_key=e.api_key,e.env!==void 0&&(f.app.env=e.env),await this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),f.app}static async updateJWT(){try{const e=await(await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({apiKey:f.app.api_key})})).json();this.app.jwt=e.token}catch{}}static getApiKey(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return f.app.api_key}static getSessionKey(){return f.app.jwt}static getEnv(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return f.app.env==="internal"?"staging":f.app.env}static getBaseUrl(){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(f.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(e,s,r,n){if(!f.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const i=f.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",o=n&&n>0?"/pay/":"/deposit/",a=`_chain_/${e}/_token_/${s}/_to_/${r}${n?"/_amount_/"+n*100:""}`;return i+o+a}}let W=null;function Ge(){W=Je.create({prefixUrl:f.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=f.getSessionKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,s)=>s]},retry:{limit:2}})}function m(){return W||Ge(),W}class Xe{async getById(e){return await m().get("intents/"+e).json()}async getForSender(e){return await m().get("intents/user/"+e).json()}async getForAddress(e){return await m().get("intents/address/"+e).json()}async getAll(e){return await m().get("intents",{searchParams:e}).json()}async create(e){return await m().post("intents",{json:e}).json()}async update(e,s){return await m().post("intents",{json:s}).json()}async triggerProcessing(e){return await m().post(`intents/${e}/trigger-processing`).json()}}class Ze{async getFromSpecificBridge(e){return await m().get("quotes/single",{searchParams:e}).json()}async getFromAllBridges(e){return await m().get("quotes/multiple",{searchParams:e}).json()}async getBestAcrossBridges(e){return await m().get("quotes/best",{searchParams:e}).json()}async getAll(e){return await m().get("quotes/multi-source",{searchParams:e}).json()}}class Qe{async getOptimalRoutes(e){return await m().get("router/optimal-route",{searchParams:e}).json()}async getAllSupportedBridges(){return await m().get("router/supported-bridges/all").json()}async getSupportedBridges(e){return await m().get("router/supported-bridges/route",{searchParams:e}).json()}async getSupportedRoutes(e,s){return await m().get("router/supported-bridges/bridge/"+e,{searchParams:s}).json()}}class et{async getSupported(e){return await m().get("chains",{searchParams:e}).json()}}class tt{async getClientInfo(){return await m().get("client/auth/client-info").json()}}const st={router:new Qe,quotes:new Ze,intents:new Xe,chains:new et,client:new tt};function pe(t){var e,s,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(e=0;e<n;e++)t[e]&&(s=pe(t[e]))&&(r&&(r+=" "),r+=s)}else for(s in t)t[s]&&(r&&(r+=" "),r+=s);return r}function rt(){for(var t,e,s=0,r="",n=arguments.length;s<n;s++)(t=arguments[s])&&(e=pe(t))&&(r&&(r+=" "),r+=e);return r}function nt(t){const{to:e,token:s,chain:r,amount:n,isOpen:i,open:o,close:a,onCancel:c,onSuccess:u,session_token:d}=t,[T,y]=g.useState(!0),w=g.useRef(null);g.useEffect(()=>{j();const l=document.body.style.overflow;i?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=l||"";const p=h=>{h.data==="closed"&&(a(),c?.()),h.data==="completed"&&(window.setTimeout(a,2e3),u?.())};return window.addEventListener("message",p),()=>{document.body.style.overflow=l||"",window.removeEventListener("message",p)}},[i,c,u]);function v(){y(!1),j()}function j(){if(!d)return;const l={type:"session",session_token:d,environment:f.getEnv()||K.PRODUCTION};w.current?.contentWindow?.postMessage(l,"https://app.chainrails.io"),w.current?.contentWindow?.postMessage(l,"https://chainrails-frontend-git-staging-horus-labs.vercel.app")}return d?E.jsxs("div",{className:rt("payment-modal-wrapper",T?"loading":"not-loading",i?"open":"closed"),children:[T&&E.jsx("div",{role:"status",className:"payment-modal-loader",children:E.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),E.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),E.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:f.getPayModalUrl(r,s,e,n),onLoad:v,className:`payment-modal ${T?"invisible":"visible"}`,"data-id":n,ref:w})]}):E.jsx(E.Fragment,{})}const ot=Symbol(),z=Symbol(),O="a",ye="f",ge="p",me="c",we="t",F="h",k="w",Y="o",V="k";let it=(t,e)=>new Proxy(t,e);const J=Object.getPrototypeOf,G=new WeakMap,be=t=>t&&(G.has(t)?G.get(t):J(t)===Object.prototype||J(t)===Array.prototype),_=t=>typeof t=="object"&&t!==null,at=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),ct=t=>{if(Array.isArray(t))return Array.from(t);const e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(s=>{s.configurable=!0}),Object.create(J(t),e)},ut=(t,e)=>{const s={[ye]:e};let r=!1;const n=(a,c)=>{if(!r){let u=s[O].get(t);if(u||(u={},s[O].set(t,u)),a===k)u[k]=!0;else{let d=u[a];d||(d=new Set,u[a]=d),d.add(c)}}},i=()=>{r=!0,s[O].delete(t)},o={get(a,c){return c===z?t:(n(V,c),Te(Reflect.get(a,c),s[O],s[me],s[we]))},has(a,c){return c===ot?(i(),!0):(n(F,c),Reflect.has(a,c))},getOwnPropertyDescriptor(a,c){return n(Y,c),Reflect.getOwnPropertyDescriptor(a,c)},ownKeys(a){return n(k),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,s]},X=t=>t[z]||t,Te=(t,e,s,r)=>{if(!be(t))return t;let n=r&&r.get(t);if(!n){const c=X(t);at(c)?n=[c,ct(c)]:n=[c],r?.set(t,n)}const[i,o]=n;let a=s&&s.get(i);return(!a||a[1][ye]!==!!o)&&(a=ut(i,!!o),a[1][ge]=it(o||i,a[0]),s&&s.set(i,a)),a[1][O]=e,a[1][me]=s,a[1][we]=r,a[1][ge]},lt=(t,e)=>{const s=Reflect.ownKeys(t),r=Reflect.ownKeys(e);return s.length!==r.length||s.some((n,i)=>n!==r[i])},Re=(t,e,s,r,n=Object.is)=>{if(n(t,e))return!1;if(!_(t)||!_(e))return!0;const i=s.get(X(t));if(!i)return!0;if(r){if(r.get(t)===e)return!1;r.set(t,e)}let o=null;for(const a of i[F]||[])if(o=Reflect.has(t,a)!==Reflect.has(e,a),o)return o;if(i[k]===!0){if(o=lt(t,e),o)return o}else for(const a of i[Y]||[]){const c=!!Reflect.getOwnPropertyDescriptor(t,a),u=!!Reflect.getOwnPropertyDescriptor(e,a);if(o=c!==u,o)return o}for(const a of i[V]||[])if(o=Re(t[a],e[a],s,r,n),o)return o;if(o===null)throw new Error("invalid used");return o},ft=t=>be(t)&&t[z]||null,Ee=(t,e=!0)=>{G.set(t,e)},ht=(t,e,s)=>{const r=[],n=new WeakSet,i=(o,a)=>{var c,u,d;if(n.has(o))return;_(o)&&n.add(o);const T=_(o)&&e.get(X(o));if(T){if((c=T[F])===null||c===void 0||c.forEach(y=>{const w=`:has(${String(y)})`;r.push(a?[...a,w]:[w])}),T[k]===!0){const y=":ownKeys";r.push(a?[...a,y]:[y])}else(u=T[Y])===null||u===void 0||u.forEach(y=>{const w=`:hasOwn(${String(y)})`;r.push(a?[...a,w]:[w])});(d=T[V])===null||d===void 0||d.forEach(y=>{"value"in(Object.getOwnPropertyDescriptor(o,y)||{})&&i(o[y],a?[...a,y]:[y])})}else a&&r.push(a)};return i(t),r},x={},Z=t=>typeof t=="object"&&t!==null,dt=t=>Z(t)&&!Q.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),Pe=(t,e)=>{const s=Se.get(t);if(s?.[0]===e)return s[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return Ee(r,!0),Se.set(t,[e,r]),Reflect.ownKeys(t).forEach(n=>{if(Object.getOwnPropertyDescriptor(r,n))return;const i=Reflect.get(t,n),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,n),a={value:i,enumerable:o,configurable:!0};if(Q.has(i))Ee(i,!1);else if(S.has(i)){const[c,u]=S.get(i);a.value=Pe(c,u())}Object.defineProperty(r,n,a)}),Object.preventExtensions(r)},pt=(t,e,s,r)=>({deleteProperty(n,i){const o=Reflect.get(n,i);s(i);const a=Reflect.deleteProperty(n,i);return a&&r(["delete",[i],o]),a},set(n,i,o,a){const c=!t()&&Reflect.has(n,i),u=Reflect.get(n,i,a);if(c&&(Ae(u,o)||M.has(o)&&Ae(u,M.get(o))))return!0;s(i),Z(o)&&(o=ft(o)||o);const d=!S.has(o)&&gt(o)?ve(o):o;return e(i,d),Reflect.set(n,i,d,a),r(["set",[i],o,u]),!0}}),S=new WeakMap,Q=new WeakSet,Se=new WeakMap,ee=[1],M=new WeakMap;let Ae=Object.is,yt=(t,e)=>new Proxy(t,e),gt=dt,mt=Pe,wt=pt;function ve(t={}){if(!Z(t))throw new Error("object required");const e=M.get(t);if(e)return e;let s=ee[0];const r=new Set,n=(l,p=++ee[0])=>{s!==p&&(i=s=p,r.forEach(h=>h(l,p)))};let i=s;const o=(l=ee[0])=>(i!==l&&(i=l,c.forEach(([p])=>{const h=p[1](l);h>s&&(s=h)})),s),a=l=>(p,h)=>{const R=[...p];R[1]=[l,...R[1]],n(R,h)},c=new Map,u=(l,p)=>{const h=!Q.has(p)&&S.get(p);if(h){if((x?"production":void 0)!=="production"&&c.has(l))throw new Error("prop listener already exists");if(r.size){const R=h[2](a(l));c.set(l,[h,R])}else c.set(l,[h])}},d=l=>{var p;const h=c.get(l);h&&(c.delete(l),(p=h[1])==null||p.call(h))},T=l=>(r.add(l),r.size===1&&c.forEach(([h,R],U)=>{if((x?"production":void 0)!=="production"&&R)throw new Error("remove already exists");const At=h[2](a(U));c.set(U,[h,At])}),()=>{r.delete(l),r.size===0&&c.forEach(([h,R],U)=>{R&&(R(),c.set(U,[h]))})});let y=!0;const w=wt(()=>y,u,d,n),v=yt(t,w);M.set(t,v);const j=[t,o,T];return S.set(v,j),Reflect.ownKeys(t).forEach(l=>{const p=Object.getOwnPropertyDescriptor(t,l);"value"in p&&p.writable&&(v[l]=t[l])}),y=!1,v}function bt(t,e,s){const r=S.get(t);(x?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let n;const i=[],o=r[2];let a=!1;const u=o(d=>{i.push(d),n||(n=Promise.resolve().then(()=>{n=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,u()}}function Ce(t){const e=S.get(t);(x?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[s,r]=e;return mt(s,r())}const Tt={},Rt=(t,e)=>{const s=g.useRef(void 0);g.useEffect(()=>{s.current=ht(t,e)}),g.useDebugValue(s.current)},Et=new WeakMap;function Pt(t,e){const r=g.useMemo(()=>t&&new WeakMap,[t]),n=g.useRef(void 0);let i=!0;const o=g.useSyncExternalStore(g.useCallback(c=>{const u=bt(t,c);return c(),u},[t,void 0]),()=>{const c=Ce(t);try{if(!i&&n.current&&!Re(n.current,c,r,new WeakMap))return n.current}catch{}return c},()=>Ce(t));i=!1,g.useLayoutEffect(()=>{n.current=o}),(Tt?"production":void 0)!=="production"&&Rt(o,r);const a=g.useMemo(()=>new WeakMap,[]);return Te(o,r,a,Et)}const A=ve({data:null,isPending:!1,error:null});function St({auth_url:t,chain:e,token:s,amount:r,to:n,onCancel:i,onSuccess:o}){const a=Pt(A),[c,u]=g.useState(!1);function d(){u(!0)}function T(){u(!1)}const y=()=>{A.isPending=!0,A.error=null,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chain:e,token:s,amount:r,to:n})}).then(w=>w.json()).then(w=>{A.data=w,A.isPending=!1}).catch(w=>{A.error=w?.toString(),A.isPending=!1})};return g.useEffect(y,[]),{...a,chain:e,token:s,to:n,isOpen:c,open:d,close:T,refetch:y,onSuccess:o,onCancel:i}}b.Chainrails=f,b.PaymentModal=nt,b.chains=he,b.crapi=st,b.tokens=de,b.usePaymentSession=St,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,30 @@
1
+ import { chains } from "@chainrails/sdk";
2
+ interface usePaymentSessionProps {
3
+ auth_url: string;
4
+ chain: chains;
5
+ token: chains;
6
+ to: `0x${string}`;
7
+ amount?: string;
8
+ onCancel?: () => void;
9
+ onSuccess?: () => void;
10
+ }
11
+ export declare function usePaymentSession({ auth_url, chain, token, amount, to, onCancel, onSuccess }: usePaymentSessionProps): {
12
+ chain: chains;
13
+ token: chains;
14
+ to: `0x${string}`;
15
+ isOpen: boolean;
16
+ open: () => void;
17
+ close: () => void;
18
+ refetch: () => void;
19
+ onSuccess: (() => void) | undefined;
20
+ onCancel: (() => void) | undefined;
21
+ data: {
22
+ readonly sessionToken: string;
23
+ readonly sessionId: string;
24
+ readonly expiresAt: string;
25
+ } | null;
26
+ error: string | null;
27
+ isPending: boolean;
28
+ };
29
+ export {};
30
+ //# sourceMappingURL=usePaymentSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePaymentSession.d.ts","sourceRoot":"","sources":["../../src/hooks/usePaymentSession.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAoBzC,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,sBAAsB;;;;;;;;sBAHjG,IAAI;qBADL,IAAI;;+BArBP,MAAM;4BACT,MAAM;4BACN,MAAM;;WAKV,MAAM,GAAG,IAAI;eACT,OAAO;EAsEnB"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./PaymentModal/index.css";
2
2
  export { PaymentModal } from "./PaymentModal";
3
- export { useGetSessionToken } from "./hooks/useGetSessionToken";
3
+ export { usePaymentSession } from "./hooks/usePaymentSession";
4
4
  export { crapi, chains, tokens, Chainrails } from "@chainrails/sdk";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sideEffects": [
4
4
  "**/*.css"
5
5
  ],
6
- "version": "0.0.31",
6
+ "version": "0.0.32",
7
7
  "description": "",
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -1,27 +0,0 @@
1
- interface useGetSessionTokenCallBacks {
2
- onError?: () => void;
3
- onSuccess?: () => void;
4
- onRefetch?: () => void;
5
- }
6
- interface useGetSessionTokenProps {
7
- url: string;
8
- params?: {
9
- amount?: string;
10
- };
11
- callbacks?: useGetSessionTokenCallBacks;
12
- }
13
- export declare function useGetSessionToken({ url, params, callbacks }: useGetSessionTokenProps): {
14
- isOpen: boolean;
15
- open: () => void;
16
- close: () => void;
17
- refetch: () => void;
18
- data: {
19
- readonly sessionToken: string;
20
- readonly sessionId: string;
21
- readonly expiresAt: string;
22
- } | null;
23
- error: string | null;
24
- isPending: boolean;
25
- };
26
- export {};
27
- //# sourceMappingURL=useGetSessionToken.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetSessionToken.d.ts","sourceRoot":"","sources":["../../src/hooks/useGetSessionToken.tsx"],"names":[],"mappings":"AAmBA,UAAU,2BAA2B;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,UAAU,uBAAuB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,SAAS,CAAC,EAAE,2BAA2B,CAAC;CACzC;AAED,wBAAgB,kBAAkB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,uBAAuB;;;;;;+BA7BtE,MAAM;4BACT,MAAM;4BACN,MAAM;;WAKV,MAAM,GAAG,IAAI;eACT,OAAO;EAoEnB"}