@instockng/storefront-ui 1.0.10 → 1.0.12

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.
Files changed (98) hide show
  1. package/README.md +26 -0
  2. package/dist/components/Checkout.d.ts.map +1 -1
  3. package/dist/components/ShoppingCart.d.ts.map +1 -1
  4. package/dist/contexts/CartContext.d.ts.map +1 -1
  5. package/dist/index10.mjs +144 -141
  6. package/dist/index101.mjs +1 -1
  7. package/dist/index102.mjs +3 -3
  8. package/dist/index103.mjs +3 -3
  9. package/dist/index105.mjs +1 -1
  10. package/dist/index111.mjs +1 -1
  11. package/dist/index20.mjs +2 -2
  12. package/dist/index21.mjs +1 -1
  13. package/dist/index28.mjs +11 -11
  14. package/dist/index3.mjs +88 -78
  15. package/dist/index37.mjs +1 -1
  16. package/dist/index41.mjs +36 -23
  17. package/dist/index42.mjs +44 -36
  18. package/dist/index43.mjs +99 -44
  19. package/dist/index44.mjs +112 -99
  20. package/dist/index45.mjs +44 -80
  21. package/dist/index46.mjs +64 -53
  22. package/dist/index47.mjs +65 -48
  23. package/dist/index48.mjs +54 -73
  24. package/dist/index49.mjs +52 -63
  25. package/dist/index50.mjs +14 -70
  26. package/dist/index51.mjs +13 -14
  27. package/dist/index52.mjs +58 -13
  28. package/dist/index53.mjs +101 -34
  29. package/dist/index54.mjs +99 -95
  30. package/dist/index55.mjs +22 -132
  31. package/dist/index62.mjs +30 -231
  32. package/dist/index63.mjs +42 -5
  33. package/dist/index64.mjs +228 -127
  34. package/dist/index65.mjs +4 -66
  35. package/dist/index66.mjs +124 -77
  36. package/dist/index67.mjs +65 -26
  37. package/dist/index68.mjs +84 -6
  38. package/dist/index69.mjs +26 -72
  39. package/dist/index70.mjs +8 -3
  40. package/dist/index71.mjs +75 -2
  41. package/dist/index72.mjs +3 -82
  42. package/dist/index73.mjs +2 -54
  43. package/dist/index74.mjs +82 -5
  44. package/dist/index75.mjs +53 -4
  45. package/dist/index76.mjs +5 -178
  46. package/dist/index77.mjs +5 -53
  47. package/dist/index78.mjs +178 -68
  48. package/dist/index79.mjs +50 -31
  49. package/dist/index8.mjs +8 -7
  50. package/dist/index80.mjs +69 -43
  51. package/dist/index81.mjs +2 -2
  52. package/dist/index82.mjs +1 -1
  53. package/dist/index83.mjs +6 -6
  54. package/dist/index84.mjs +2 -2
  55. package/dist/index85.mjs +2 -2
  56. package/dist/index87.mjs +2 -2
  57. package/dist/index88.mjs +2 -2
  58. package/dist/index89.mjs +1 -1
  59. package/dist/index91.mjs +4 -4
  60. package/dist/index92.mjs +3 -3
  61. package/dist/index93.mjs +12 -30
  62. package/dist/index94.mjs +7 -11
  63. package/dist/index95.mjs +30 -3
  64. package/dist/index96.mjs +10 -3
  65. package/dist/index97.mjs +4 -13
  66. package/dist/index98.mjs +4 -7
  67. package/dist/index99.mjs +1 -1
  68. package/dist/styles.css +1 -0
  69. package/package.json +14 -13
  70. package/src/components/CartItem.stories.tsx +94 -0
  71. package/src/components/CartItem.tsx +141 -0
  72. package/src/components/Checkout.stories.tsx +380 -0
  73. package/src/components/Checkout.tsx +954 -0
  74. package/src/components/DiscountCodeInput.stories.tsx +76 -0
  75. package/src/components/DiscountCodeInput.tsx +162 -0
  76. package/src/components/OrderConfirmation.stories.tsx +142 -0
  77. package/src/components/OrderConfirmation.tsx +301 -0
  78. package/src/components/ProductCard.stories.tsx +112 -0
  79. package/src/components/ProductCard.tsx +195 -0
  80. package/src/components/ProductGrid.stories.tsx +137 -0
  81. package/src/components/ProductGrid.tsx +141 -0
  82. package/src/components/ShoppingCart.stories.tsx +459 -0
  83. package/src/components/ShoppingCart.tsx +263 -0
  84. package/src/components/ui/badge.tsx +37 -0
  85. package/src/components/ui/button.tsx +71 -0
  86. package/src/components/ui/card.tsx +79 -0
  87. package/src/components/ui/form-input.tsx +78 -0
  88. package/src/components/ui/form-select.tsx +73 -0
  89. package/src/components/ui/modal.tsx +181 -0
  90. package/src/contexts/CartContext.tsx +316 -0
  91. package/src/hooks/usePaystackPayment.ts +137 -0
  92. package/src/index.ts +51 -0
  93. package/src/lib/utils.ts +45 -0
  94. package/src/paystack.svg +67 -0
  95. package/src/providers/StorefrontProvider.tsx +70 -0
  96. package/src/styles.css +1 -0
  97. package/src/test-utils/MockCartProvider.tsx +424 -0
  98. package/src/vite-env.d.ts +12 -0
package/dist/index20.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import "./index42.mjs";
3
- import r from "./index43.mjs";
2
+ import "./index41.mjs";
3
+ import r from "./index42.mjs";
4
4
  let e = null;
5
5
  function p(t) {
6
6
  return e = r.create({
package/dist/index21.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { hc as e } from "./index44.mjs";
2
+ import { hc as e } from "./index43.mjs";
3
3
  function n(s) {
4
4
  const r = `${s}/v1`;
5
5
  return {
package/dist/index28.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
  'use client';
2
- import { useCreateOrder as s, useDeleteOrder as r, useGetOrder as u, useListOrders as o, useUpdateOrder as a, useUpdateOrderStatus as n } from "./index45.mjs";
3
- import { useCreateBrand as i, useDeleteBrand as p, useGetBrand as C, useListBrands as D, useUpdateBrand as c } from "./index46.mjs";
4
- import { useCreateProduct as G, useDeleteProduct as f, useGetProduct as m, useListProducts as v, useUpdateProduct as x } from "./index47.mjs";
5
- import { useCreateVariant as L, useDeleteVariant as S, useGetVariantInventory as U, useListProductVariants as O, useSearchVariants as V, useUpdateVariant as h } from "./index48.mjs";
6
- import { useCreateWarehouse as I, useDeleteWarehouse as P, useGetWarehouseInventory as A, useListWarehouses as W, useUpdateWarehouse as Z } from "./index49.mjs";
7
- import { useAdjustInventory as k, useGetInventoryTransactions as w, useGetLowStockVariants as T, useListInventory as j, useTransferInventory as E } from "./index50.mjs";
8
- import { useGetCustomerHistory as g } from "./index51.mjs";
9
- import { useGetStats as z } from "./index52.mjs";
10
- import { useCleanupExpiredCarts as J, useGetAbandonedCart as K, useGetAbandonedCartStats as M, useListAbandonedCarts as N } from "./index53.mjs";
11
- import { useBulkGenerateDiscountCodes as R, useCreateDiscountCode as X, useDeleteDiscountCode as Y, useGetDiscountCode as _, useGetDiscountCodeAnalytics as $, useGetDiscountCodeOverviewStats as ee, useListDiscountCodes as te, useUpdateDiscountCode as se } from "./index54.mjs";
12
- import { useCreateDeliveryZone as ue, useCreateState as oe, useDeleteDeliveryZone as ae, useDeleteState as ne, useListDeliveryZones as de, useListStates as ie, useUpdateDeliveryZone as pe, useUpdateState as Ce } from "./index55.mjs";
2
+ import { useCreateOrder as s, useDeleteOrder as r, useGetOrder as u, useListOrders as o, useUpdateOrder as a, useUpdateOrderStatus as n } from "./index44.mjs";
3
+ import { useCreateBrand as i, useDeleteBrand as p, useGetBrand as C, useListBrands as D, useUpdateBrand as c } from "./index45.mjs";
4
+ import { useCreateProduct as G, useDeleteProduct as f, useGetProduct as m, useListProducts as v, useUpdateProduct as x } from "./index46.mjs";
5
+ import { useCreateVariant as L, useDeleteVariant as S, useGetVariantInventory as U, useListProductVariants as O, useSearchVariants as V, useUpdateVariant as h } from "./index47.mjs";
6
+ import { useCreateWarehouse as I, useDeleteWarehouse as P, useGetWarehouseInventory as A, useListWarehouses as W, useUpdateWarehouse as Z } from "./index48.mjs";
7
+ import { useAdjustInventory as k, useGetInventoryTransactions as w, useGetLowStockVariants as T, useListInventory as j, useTransferInventory as E } from "./index49.mjs";
8
+ import { useGetCustomerHistory as g } from "./index50.mjs";
9
+ import { useGetStats as z } from "./index51.mjs";
10
+ import { useCleanupExpiredCarts as J, useGetAbandonedCart as K, useGetAbandonedCartStats as M, useListAbandonedCarts as N } from "./index52.mjs";
11
+ import { useBulkGenerateDiscountCodes as R, useCreateDiscountCode as X, useDeleteDiscountCode as Y, useGetDiscountCode as _, useGetDiscountCodeAnalytics as $, useGetDiscountCodeOverviewStats as ee, useListDiscountCodes as te, useUpdateDiscountCode as se } from "./index53.mjs";
12
+ import { useCreateDeliveryZone as ue, useCreateState as oe, useDeleteDeliveryZone as ae, useDeleteState as ne, useListDeliveryZones as de, useListStates as ie, useUpdateDeliveryZone as pe, useUpdateState as Ce } from "./index54.mjs";
13
13
  export {
14
14
  k as useAdjustInventory,
15
15
  R as useBulkGenerateDiscountCodes,
package/dist/index3.mjs CHANGED
@@ -1,135 +1,145 @@
1
1
  'use client';
2
- import { jsxs as T, jsx as z } from "react/jsx-runtime";
3
- import { createContext as G, useState as C, useRef as I, useEffect as m, useCallback as r, useContext as H } from "react";
2
+ import { jsxs as Y, jsx as q } from "react/jsx-runtime";
3
+ import { createContext as z, useState as d, useRef as w, useEffect as a, useCallback as r, useContext as B } from "react";
4
4
  import "./index18.mjs";
5
- import { useGetCart as K, useCreateCart as Y, useAddCartItem as q, useUpdateCartItem as B, useRemoveCartItem as J, useApplyDiscount as Q, useRemoveDiscount as V, useUpdateCart as W, useCheckoutCart as X } from "./index29.mjs";
5
+ import { useGetCart as J, useCreateCart as Q, useAddCartItem as V, useUpdateCartItem as W, useRemoveCartItem as X, useApplyDiscount as Z, useRemoveDiscount as $, useUpdateCart as tt, useCheckoutCart as et } from "./index29.mjs";
6
6
  import "@tanstack/react-query";
7
- import { ShoppingCart as Z } from "./index8.mjs";
8
- const c = "oms_cart_id", y = G(null);
9
- function at({ children: a, brandSlug: h, initialCartId: u, shoppingCartProps: v }) {
10
- const [t, i] = C(() => {
11
- if (u) return u;
12
- if (typeof window < "u") {
13
- const n = new URLSearchParams(window.location.search).get("cartId");
14
- return n || localStorage.getItem(c);
7
+ import { ShoppingCart as rt } from "./index8.mjs";
8
+ const m = "oms_cart_id", D = z(null);
9
+ function it({ children: c, brandSlug: f, initialCartId: u, shoppingCartProps: E }) {
10
+ const [t, s] = d(u || null), [p, C] = d(!1), [M, g] = d(!1), I = w(!1), h = w(!1), l = w(!1);
11
+ a(() => {
12
+ g(!0);
13
+ }, []), a(() => {
14
+ if (u || I.current) return;
15
+ I.current = !0;
16
+ const n = new URLSearchParams(window.location.search).get("cartId");
17
+ if (n) {
18
+ s(n);
19
+ return;
15
20
  }
16
- return null;
17
- }), [f, d] = C(!1), { data: S, isLoading: D, error: s, refetch: o } = K(t || "", {
21
+ const v = localStorage.getItem(m);
22
+ v && s(v);
23
+ }, [u]);
24
+ const { data: A, isLoading: R, error: i, refetch: o } = J(t || "", {
18
25
  enabled: !!t,
19
26
  retry: !1
20
27
  // Don't retry on failure - cart might be invalid/expired
21
- }), w = I(!1), l = I(!1), g = Y({
28
+ }), y = Q({
22
29
  onSuccess: (e) => {
23
30
  if ("error" in e) {
24
31
  console.error("Failed to create cart:", e.error);
25
32
  return;
26
33
  }
27
- i(e.id);
34
+ s(e.id);
28
35
  },
29
36
  onError: (e) => {
30
37
  console.error("Failed to create cart:", e);
31
38
  }
32
39
  });
33
- m(() => {
34
- !w.current && !t && !u && (w.current = !0, setTimeout(() => {
35
- g.mutate(h);
36
- }, 0));
37
- }, []), m(() => {
38
- s && t && !l.current && (l.current = !0, console.warn("Cart fetch failed, clearing invalid cart:", s), Promise.resolve().then(() => {
39
- i(null), typeof window < "u" && localStorage.removeItem(c), l.current = !1;
40
- }));
41
- }, [s, t]);
42
- const E = q(t || "", {
40
+ a(() => {
41
+ if (h.current) return;
42
+ h.current = !0;
43
+ const e = setTimeout(() => {
44
+ !t && !u && y.mutate(f);
45
+ }, 150);
46
+ return () => clearTimeout(e);
47
+ }, []), a(() => {
48
+ i && t && !l.current && (l.current = !0, console.warn("Cart fetch failed, creating new cart:", i), s(null), typeof window < "u" && localStorage.removeItem(m), setTimeout(() => {
49
+ y.mutate(f), l.current = !1;
50
+ }, 100));
51
+ }, [i, t, f]);
52
+ const x = V(t || "", {
43
53
  onSuccess: () => o()
44
- }), A = B(t || "", {
54
+ }), P = W(t || "", {
45
55
  onSuccess: () => o()
46
- }), M = J(t || "", {
56
+ }), N = X(t || "", {
47
57
  onSuccess: () => o()
48
- }), x = Q(t || "", {
58
+ }), F = Z(t || "", {
49
59
  onSuccess: () => o()
50
- }), P = V(t || "", {
60
+ }), T = $(t || "", {
51
61
  onSuccess: () => o()
52
- }), R = W(t || "", {
62
+ }), U = tt(t || "", {
53
63
  onSuccess: () => o()
54
- }), N = X(t || "");
55
- m(() => {
56
- t && typeof window < "u" && localStorage.setItem(c, t);
64
+ }), _ = et(t || "");
65
+ a(() => {
66
+ t && typeof window < "u" && localStorage.setItem(m, t);
57
67
  }, [t]);
58
- const U = r(
68
+ const k = r(
59
69
  async (e, n) => {
60
70
  if (!t) throw new Error("No cart ID");
61
- await E.mutateAsync({ sku: e, quantity: n });
71
+ await x.mutateAsync({ sku: e, quantity: n });
62
72
  },
63
73
  // eslint-disable-next-line react-hooks/exhaustive-deps
64
74
  [t]
65
- ), _ = r(
75
+ ), L = r(
66
76
  async (e, n) => {
67
77
  if (!t) throw new Error("No cart ID");
68
- await A.mutateAsync({ itemId: e, quantity: n });
78
+ await P.mutateAsync({ itemId: e, quantity: n });
69
79
  },
70
80
  // eslint-disable-next-line react-hooks/exhaustive-deps
71
81
  [t]
72
- ), b = r(
82
+ ), j = r(
73
83
  async (e) => {
74
84
  if (!t) throw new Error("No cart ID");
75
- await M.mutateAsync(e);
85
+ await N.mutateAsync(e);
76
86
  },
77
87
  // eslint-disable-next-line react-hooks/exhaustive-deps
78
88
  [t]
79
- ), k = r(
89
+ ), O = r(
80
90
  async (e) => {
81
91
  if (!t) throw new Error("No cart ID");
82
- await x.mutateAsync({ code: e });
92
+ await F.mutateAsync({ code: e });
83
93
  },
84
94
  // eslint-disable-next-line react-hooks/exhaustive-deps
85
95
  [t]
86
- ), F = r(async () => {
96
+ ), b = r(async () => {
87
97
  if (!t) throw new Error("No cart ID");
88
- await P.mutateAsync();
89
- }, [t]), j = r(() => {
90
- i(null), typeof window < "u" && localStorage.removeItem(c);
91
- }, []), L = r(() => {
92
- d(!0);
93
- }, []), p = r(() => {
94
- d(!1);
95
- }, []), O = {
96
- cart: S || null,
98
+ await T.mutateAsync();
99
+ }, [t]), G = r(() => {
100
+ s(null), typeof window < "u" && localStorage.removeItem(m);
101
+ }, []), H = r(() => {
102
+ C(!0);
103
+ }, []), S = r(() => {
104
+ C(!1);
105
+ }, []), K = {
106
+ cart: A || null,
97
107
  cartId: t,
98
- isLoading: D,
99
- error: s,
100
- updateCartMutation: R,
101
- checkoutMutation: N,
102
- addItem: U,
103
- updateItem: _,
104
- removeItem: b,
105
- applyDiscount: k,
106
- removeDiscount: F,
107
- clearCart: j,
108
+ isLoading: R,
109
+ error: i,
110
+ updateCartMutation: U,
111
+ checkoutMutation: _,
112
+ addItem: k,
113
+ updateItem: L,
114
+ removeItem: j,
115
+ applyDiscount: O,
116
+ removeDiscount: b,
117
+ clearCart: G,
108
118
  refetch: o,
109
- isOpen: f,
110
- open: L,
111
- close: p
119
+ isOpen: p,
120
+ open: H,
121
+ close: S
112
122
  };
113
- return /* @__PURE__ */ T(y.Provider, { value: O, children: [
114
- a,
115
- /* @__PURE__ */ z(
116
- Z,
123
+ return /* @__PURE__ */ Y(D.Provider, { value: K, children: [
124
+ c,
125
+ M && /* @__PURE__ */ q(
126
+ rt,
117
127
  {
118
- isOpen: f,
119
- onClose: p,
120
- ...v
128
+ isOpen: p,
129
+ onClose: S,
130
+ ...E
121
131
  }
122
132
  )
123
133
  ] });
124
134
  }
125
- function st() {
126
- const a = H(y);
127
- if (!a)
135
+ function mt() {
136
+ const c = B(D);
137
+ if (!c)
128
138
  throw new Error("useCart must be used within CartProvider");
129
- return a;
139
+ return c;
130
140
  }
131
141
  export {
132
- y as CartContext,
133
- at as CartProvider,
134
- st as useCart
142
+ D as CartContext,
143
+ it as CartProvider,
144
+ mt as useCart
135
145
  };
package/dist/index37.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import * as l from "react";
3
- import { composeRefs as m } from "./index41.mjs";
3
+ import { composeRefs as m } from "./index55.mjs";
4
4
  import { jsx as u } from "react/jsx-runtime";
5
5
  // @__NO_SIDE_EFFECTS__
6
6
  function y(e) {
package/dist/index41.mjs CHANGED
@@ -1,26 +1,39 @@
1
1
  'use client';
2
- import "react";
3
- function i(n, o) {
4
- if (typeof n == "function")
5
- return n(o);
6
- n != null && (n.current = o);
7
- }
8
- function f(...n) {
9
- return (o) => {
10
- let u = !1;
11
- const c = n.map((t) => {
12
- const e = i(t, o);
13
- return !u && typeof e == "function" && (u = !0), e;
14
- });
15
- if (u)
16
- return () => {
17
- for (let t = 0; t < c.length; t++) {
18
- const e = c[t];
19
- typeof e == "function" ? e() : i(n[t], null);
20
- }
21
- };
22
- };
23
- }
2
+ import o from "./index42.mjs";
3
+ const {
4
+ Axios: e,
5
+ AxiosError: a,
6
+ CanceledError: s,
7
+ isCancel: t,
8
+ CancelToken: i,
9
+ VERSION: l,
10
+ all: n,
11
+ Cancel: d,
12
+ isAxiosError: x,
13
+ spread: C,
14
+ toFormData: c,
15
+ AxiosHeaders: m,
16
+ HttpStatusCode: p,
17
+ formToJSON: A,
18
+ getAdapter: f,
19
+ mergeConfig: E
20
+ } = o;
24
21
  export {
25
- f as composeRefs
22
+ e as Axios,
23
+ a as AxiosError,
24
+ m as AxiosHeaders,
25
+ d as Cancel,
26
+ i as CancelToken,
27
+ s as CanceledError,
28
+ p as HttpStatusCode,
29
+ l as VERSION,
30
+ n as all,
31
+ o as default,
32
+ A as formToJSON,
33
+ f as getAdapter,
34
+ x as isAxiosError,
35
+ t as isCancel,
36
+ E as mergeConfig,
37
+ C as spread,
38
+ c as toFormData
26
39
  };
package/dist/index42.mjs CHANGED
@@ -1,39 +1,47 @@
1
1
  'use client';
2
- import o from "./index43.mjs";
3
- const {
4
- Axios: e,
5
- AxiosError: a,
6
- CanceledError: s,
7
- isCancel: t,
8
- CancelToken: i,
9
- VERSION: l,
10
- all: n,
11
- Cancel: d,
12
- isAxiosError: x,
13
- spread: C,
14
- toFormData: c,
15
- AxiosHeaders: m,
16
- HttpStatusCode: p,
17
- formToJSON: A,
18
- getAdapter: f,
19
- mergeConfig: E
20
- } = o;
2
+ import a from "./index64.mjs";
3
+ import p from "./index65.mjs";
4
+ import m from "./index66.mjs";
5
+ import i from "./index67.mjs";
6
+ import f from "./index68.mjs";
7
+ import l from "./index69.mjs";
8
+ import c from "./index70.mjs";
9
+ import d from "./index71.mjs";
10
+ import u from "./index72.mjs";
11
+ import { VERSION as x } from "./index73.mjs";
12
+ import C from "./index74.mjs";
13
+ import A from "./index75.mjs";
14
+ import E from "./index76.mjs";
15
+ import O from "./index77.mjs";
16
+ import S from "./index78.mjs";
17
+ import H from "./index79.mjs";
18
+ import T from "./index80.mjs";
19
+ function n(o) {
20
+ const t = new m(o), e = p(m.prototype.request, t);
21
+ return a.extend(e, m.prototype, t, { allOwnKeys: !0 }), a.extend(e, t, null, { allOwnKeys: !0 }), e.create = function(s) {
22
+ return n(i(o, s));
23
+ }, e;
24
+ }
25
+ const r = n(f);
26
+ r.Axios = m;
27
+ r.CanceledError = c;
28
+ r.CancelToken = d;
29
+ r.isCancel = u;
30
+ r.VERSION = x;
31
+ r.toFormData = C;
32
+ r.AxiosError = A;
33
+ r.Cancel = r.CanceledError;
34
+ r.all = function(t) {
35
+ return Promise.all(t);
36
+ };
37
+ r.spread = E;
38
+ r.isAxiosError = O;
39
+ r.mergeConfig = i;
40
+ r.AxiosHeaders = S;
41
+ r.formToJSON = (o) => l(a.isHTMLForm(o) ? new FormData(o) : o);
42
+ r.getAdapter = H.getAdapter;
43
+ r.HttpStatusCode = T;
44
+ r.default = r;
21
45
  export {
22
- e as Axios,
23
- a as AxiosError,
24
- m as AxiosHeaders,
25
- d as Cancel,
26
- i as CancelToken,
27
- s as CanceledError,
28
- p as HttpStatusCode,
29
- l as VERSION,
30
- n as all,
31
- o as default,
32
- A as formToJSON,
33
- f as getAdapter,
34
- x as isAxiosError,
35
- t as isCancel,
36
- E as mergeConfig,
37
- C as spread,
38
- c as toFormData
46
+ r as default
39
47
  };
package/dist/index43.mjs CHANGED
@@ -1,47 +1,102 @@
1
1
  'use client';
2
- import a from "./index62.mjs";
3
- import p from "./index63.mjs";
4
- import m from "./index64.mjs";
5
- import i from "./index65.mjs";
6
- import f from "./index66.mjs";
7
- import l from "./index67.mjs";
8
- import c from "./index68.mjs";
9
- import d from "./index69.mjs";
10
- import u from "./index70.mjs";
11
- import { VERSION as x } from "./index71.mjs";
12
- import C from "./index72.mjs";
13
- import A from "./index73.mjs";
14
- import E from "./index74.mjs";
15
- import O from "./index75.mjs";
16
- import S from "./index76.mjs";
17
- import H from "./index77.mjs";
18
- import T from "./index78.mjs";
19
- function n(o) {
20
- const t = new m(o), e = p(m.prototype.request, t);
21
- return a.extend(e, m.prototype, t, { allOwnKeys: !0 }), a.extend(e, t, null, { allOwnKeys: !0 }), e.create = function(s) {
22
- return n(i(o, s));
23
- }, e;
24
- }
25
- const r = n(f);
26
- r.Axios = m;
27
- r.CanceledError = c;
28
- r.CancelToken = d;
29
- r.isCancel = u;
30
- r.VERSION = x;
31
- r.toFormData = C;
32
- r.AxiosError = A;
33
- r.Cancel = r.CanceledError;
34
- r.all = function(t) {
35
- return Promise.all(t);
36
- };
37
- r.spread = E;
38
- r.isAxiosError = O;
39
- r.mergeConfig = i;
40
- r.AxiosHeaders = S;
41
- r.formToJSON = (o) => l(a.isHTMLForm(o) ? new FormData(o) : o);
42
- r.getAdapter = H.getAdapter;
43
- r.HttpStatusCode = T;
44
- r.default = r;
2
+ var p = Object.defineProperty;
3
+ var k = (r, e, i) => e in r ? p(r, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[e] = i;
4
+ var h = (r, e, i) => k(r, typeof e != "symbol" ? e + "" : e, i);
5
+ import { serialize as j } from "./index62.mjs";
6
+ import { mergePath as U, replaceUrlParam as P, buildSearchParams as S, removeIndexString as w, replaceUrlProtocol as x, deepMerge as C } from "./index63.mjs";
7
+ var v = (r, e) => new Proxy(() => {
8
+ }, {
9
+ get(t, s) {
10
+ if (!(typeof s != "string" || s === "then"))
11
+ return v(r, [...e, s]);
12
+ },
13
+ apply(t, s, a) {
14
+ return r({
15
+ path: e,
16
+ args: a
17
+ });
18
+ }
19
+ }), T = class {
20
+ constructor(r, e) {
21
+ h(this, "url");
22
+ h(this, "method");
23
+ h(this, "queryParams");
24
+ h(this, "pathParams", {});
25
+ h(this, "rBody");
26
+ h(this, "cType");
27
+ h(this, "fetch", async (r, e) => {
28
+ if (r) {
29
+ if (r.query && (this.queryParams = S(r.query)), r.form) {
30
+ const o = new FormData();
31
+ for (const [c, f] of Object.entries(r.form))
32
+ if (Array.isArray(f))
33
+ for (const l of f)
34
+ o.append(c, l);
35
+ else
36
+ o.append(c, f);
37
+ this.rBody = o;
38
+ }
39
+ r.json && (this.rBody = JSON.stringify(r.json), this.cType = "application/json"), r.param && (this.pathParams = r.param);
40
+ }
41
+ let i = this.method.toUpperCase();
42
+ const t = {
43
+ ...r == null ? void 0 : r.header,
44
+ ...typeof (e == null ? void 0 : e.headers) == "function" ? await e.headers() : e == null ? void 0 : e.headers
45
+ };
46
+ if (r != null && r.cookie) {
47
+ const o = [];
48
+ for (const [c, f] of Object.entries(r.cookie))
49
+ o.push(j(c, f, { path: "/" }));
50
+ t.Cookie = o.join(",");
51
+ }
52
+ this.cType && (t["Content-Type"] = this.cType);
53
+ const s = new Headers(t ?? void 0);
54
+ let a = this.url;
55
+ a = w(a), a = P(a, this.pathParams), this.queryParams && (a = a + "?" + this.queryParams.toString()), i = this.method.toUpperCase();
56
+ const u = !(i === "GET" || i === "HEAD");
57
+ return ((e == null ? void 0 : e.fetch) || fetch)(a, {
58
+ body: u ? this.rBody : void 0,
59
+ method: i,
60
+ headers: s,
61
+ ...e == null ? void 0 : e.init
62
+ });
63
+ });
64
+ this.url = r, this.method = e;
65
+ }
66
+ }, E = (r, e) => v(function i(t) {
67
+ var l;
68
+ const s = [...t.path], a = s.slice(-3).reverse();
69
+ if (a[0] === "toString")
70
+ return a[1] === "name" ? a[2] || "" : i.toString();
71
+ if (a[0] === "valueOf")
72
+ return a[1] === "name" ? a[2] || "" : i;
73
+ let u = "";
74
+ if (/^\$/.test(a[0])) {
75
+ const n = s.pop();
76
+ n && (u = n.replace(/^\$/, ""));
77
+ }
78
+ const o = s.join("/"), c = U(r, o);
79
+ if (u === "url") {
80
+ let n = c;
81
+ return t.args[0] && (t.args[0].param && (n = P(c, t.args[0].param)), t.args[0].query && (n = n + "?" + S(t.args[0].query).toString())), n = w(n), new URL(n);
82
+ }
83
+ if (u === "ws") {
84
+ const n = x(
85
+ t.args[0] && t.args[0].param ? P(c, t.args[0].param) : c,
86
+ "ws"
87
+ ), y = new URL(n), b = (l = t.args[0]) == null ? void 0 : l.query;
88
+ return b && Object.entries(b).forEach(([m, d]) => {
89
+ Array.isArray(d) ? d.forEach((q) => y.searchParams.append(m, q)) : y.searchParams.set(m, d);
90
+ }), ((...m) => (e == null ? void 0 : e.webSocket) !== void 0 && typeof e.webSocket == "function" ? e.webSocket(...m) : new WebSocket(...m))(y.toString());
91
+ }
92
+ const f = new T(c, u);
93
+ if (u) {
94
+ e ?? (e = {});
95
+ const n = C(e, { ...t.args[1] });
96
+ return f.fetch(t.args[0], n);
97
+ }
98
+ return f;
99
+ }, []);
45
100
  export {
46
- r as default
101
+ E as hc
47
102
  };