@takeshape/purchase-order-chat 1.60.2 → 1.60.3
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.
- package/dist/index.js +1 -1
- package/dist/{purchase-order-chat-wrapper-D6twvEIU.js → purchase-order-chat-wrapper-CtCPGHtH.js} +208 -199
- package/dist/{purchase-order-chat-wrapper-D6twvEIU.js.map → purchase-order-chat-wrapper-CtCPGHtH.js.map} +1 -1
- package/dist/shadow.js +2 -2
- package/dist/tailwind.js +1 -1
- package/package.json +1 -1
package/dist/{purchase-order-chat-wrapper-D6twvEIU.js → purchase-order-chat-wrapper-CtCPGHtH.js}
RENAMED
|
@@ -22,7 +22,7 @@ function Vi(t, e) {
|
|
|
22
22
|
return i != null ? String(i) : "";
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
const Yr = "
|
|
25
|
+
const Yr = "__vite_c_css_pos_initial_88d35ee618544ae783e618c09bb86b96", vt = "__vite_c_css_pos_update_88d35ee618544ae783e618c09bb86b96", Ct = () => typeof window < "u" ? window[Yr] : void 0, zi = (t) => {
|
|
26
26
|
const [e, r] = R(() => Ct() || /* @__PURE__ */ new Map()), [n, i] = R(0);
|
|
27
27
|
return F(() => {
|
|
28
28
|
const s = (o) => {
|
|
@@ -36,7 +36,7 @@ const Yr = "__vite_c_css_pos_initial_01a5a5f6a7504c91b86d80b970afaddc", vt = "__
|
|
|
36
36
|
const o = e.get(s);
|
|
37
37
|
return o ? /* @__PURE__ */ Or("style", { ...o.attributes, key: `${s}-${n}` }, o.css) : null;
|
|
38
38
|
});
|
|
39
|
-
}, He = "bigcommercePurchaseOrderAgent", It = "https://api.takeshape.io", Gt = "https://api-b2b.bigcommerce.com/graphql", Xr = "dl7c39mdpul6hyc489yk0vzxl6jesyx", ot = "[client is providing tool response]", be = "__po_address__", Se = "__po_billing_address__",
|
|
39
|
+
}, He = "bigcommercePurchaseOrderAgent", It = "https://api.takeshape.io", Gt = "https://api-b2b.bigcommerce.com/graphql", Xr = "dl7c39mdpul6hyc489yk0vzxl6jesyx", ot = "[client is providing tool response]", be = "__po_address__", Se = "__po_billing_address__", le = "__checkout_address__", ct = "purchase-order-chat-session", Kt = 3;
|
|
40
40
|
function Zr() {
|
|
41
41
|
if (typeof document < "u")
|
|
42
42
|
try {
|
|
@@ -1702,9 +1702,9 @@ function ir({ onFile: t, onBeforeValidate: e }) {
|
|
|
1702
1702
|
);
|
|
1703
1703
|
return;
|
|
1704
1704
|
}
|
|
1705
|
-
const
|
|
1706
|
-
if (!
|
|
1707
|
-
s(
|
|
1705
|
+
const E = Wn(v);
|
|
1706
|
+
if (!E.valid) {
|
|
1707
|
+
s(E.error ?? null);
|
|
1708
1708
|
return;
|
|
1709
1709
|
}
|
|
1710
1710
|
t(v);
|
|
@@ -1930,7 +1930,7 @@ function St(t) {
|
|
|
1930
1930
|
defaultAddressFilter: c = (b) => b.isDefaultShipping,
|
|
1931
1931
|
addressFilter: l = (b) => b.isShipping,
|
|
1932
1932
|
canShowDefaultAddressWarning: d
|
|
1933
|
-
} = t, h = n ===
|
|
1933
|
+
} = t, h = n === le, u = r.find(c);
|
|
1934
1934
|
let m = d && !!n && !h;
|
|
1935
1935
|
m && u && (m = u.id !== n);
|
|
1936
1936
|
const S = r.filter(l);
|
|
@@ -1974,7 +1974,7 @@ function St(t) {
|
|
|
1974
1974
|
}
|
|
1975
1975
|
) }, b.id)),
|
|
1976
1976
|
S.length > 0 && /* @__PURE__ */ a("option", { disabled: !0, children: "---" }),
|
|
1977
|
-
/* @__PURE__ */ a("option", { value:
|
|
1977
|
+
/* @__PURE__ */ a("option", { value: le, children: "Enter an address at checkout" }, le)
|
|
1978
1978
|
]
|
|
1979
1979
|
}
|
|
1980
1980
|
),
|
|
@@ -2166,13 +2166,13 @@ function dr({
|
|
|
2166
2166
|
l(String(t));
|
|
2167
2167
|
}, [t]);
|
|
2168
2168
|
const m = (w) => {
|
|
2169
|
-
const
|
|
2170
|
-
if (
|
|
2169
|
+
const k = w.target.value;
|
|
2170
|
+
if (k === "") {
|
|
2171
2171
|
l("");
|
|
2172
2172
|
return;
|
|
2173
2173
|
}
|
|
2174
|
-
if (/^\d+$/.test(
|
|
2175
|
-
const g = Number.parseInt(
|
|
2174
|
+
if (/^\d+$/.test(k) && (l(k), !s)) {
|
|
2175
|
+
const g = Number.parseInt(k, 10);
|
|
2176
2176
|
if (!Number.isNaN(g)) {
|
|
2177
2177
|
const A = Math.max(
|
|
2178
2178
|
r,
|
|
@@ -2185,10 +2185,10 @@ function dr({
|
|
|
2185
2185
|
const w = Number.parseInt(c, 10);
|
|
2186
2186
|
if (s)
|
|
2187
2187
|
if (!Number.isNaN(w) && w >= r && w !== t) {
|
|
2188
|
-
const
|
|
2188
|
+
const k = n !== void 0 ? Math.min(w, n) : w;
|
|
2189
2189
|
h("saving");
|
|
2190
2190
|
try {
|
|
2191
|
-
await e(
|
|
2191
|
+
await e(k), h("success"), u.current = setTimeout(() => {
|
|
2192
2192
|
h((g) => g === "success" ? "idle" : g);
|
|
2193
2193
|
}, 1500);
|
|
2194
2194
|
} catch {
|
|
@@ -2202,7 +2202,7 @@ function dr({
|
|
|
2202
2202
|
}, b = (w) => {
|
|
2203
2203
|
w.key === "Enter" && w.currentTarget.blur();
|
|
2204
2204
|
}, x = async (w) => {
|
|
2205
|
-
const
|
|
2205
|
+
const k = Number.parseInt(c, 10), g = Number.isNaN(k) ? t : k, A = Math.max(
|
|
2206
2206
|
r,
|
|
2207
2207
|
n !== void 0 ? Math.min(g + w, n) : g + w
|
|
2208
2208
|
);
|
|
@@ -2220,7 +2220,7 @@ function dr({
|
|
|
2220
2220
|
}
|
|
2221
2221
|
} else
|
|
2222
2222
|
e(A);
|
|
2223
|
-
}, v = t <= r,
|
|
2223
|
+
}, v = t <= r, E = n !== void 0 && t >= n, I = d === "saving";
|
|
2224
2224
|
return /* @__PURE__ */ p("span", { className: `inline-flex items-center gap-0.5 ${i}`, children: [
|
|
2225
2225
|
/* @__PURE__ */ a(
|
|
2226
2226
|
kt,
|
|
@@ -2262,7 +2262,7 @@ function dr({
|
|
|
2262
2262
|
kt,
|
|
2263
2263
|
{
|
|
2264
2264
|
onClick: () => x(1),
|
|
2265
|
-
disabled:
|
|
2265
|
+
disabled: E || I,
|
|
2266
2266
|
"aria-label": "Increase quantity",
|
|
2267
2267
|
children: /* @__PURE__ */ p(
|
|
2268
2268
|
"svg",
|
|
@@ -3285,10 +3285,10 @@ function ms({
|
|
|
3285
3285
|
selectedBillingAddressId: b,
|
|
3286
3286
|
billingAddressUpdateStatus: x,
|
|
3287
3287
|
onBillingAddressChange: v,
|
|
3288
|
-
shipToAddress:
|
|
3288
|
+
shipToAddress: E,
|
|
3289
3289
|
billingAddress: I,
|
|
3290
3290
|
checkoutTotals: w,
|
|
3291
|
-
isLoading:
|
|
3291
|
+
isLoading: k,
|
|
3292
3292
|
poMetadataSet: g = !1,
|
|
3293
3293
|
isDragging: A,
|
|
3294
3294
|
onNewOrder: $,
|
|
@@ -3369,7 +3369,7 @@ function ms({
|
|
|
3369
3369
|
selectedBillingAddressId: b,
|
|
3370
3370
|
billingAddressUpdateStatus: x,
|
|
3371
3371
|
onBillingAddressChange: v,
|
|
3372
|
-
shipToAddress:
|
|
3372
|
+
shipToAddress: E,
|
|
3373
3373
|
billingAddress: I
|
|
3374
3374
|
}
|
|
3375
3375
|
)
|
|
@@ -3415,7 +3415,7 @@ function ms({
|
|
|
3415
3415
|
totalQuantity: te,
|
|
3416
3416
|
availableItemCount: Y.length,
|
|
3417
3417
|
onCheckout: i,
|
|
3418
|
-
isLoading:
|
|
3418
|
+
isLoading: k,
|
|
3419
3419
|
allowCheckout: !!u
|
|
3420
3420
|
}
|
|
3421
3421
|
)
|
|
@@ -3759,9 +3759,9 @@ function Mt({
|
|
|
3759
3759
|
selections: c,
|
|
3760
3760
|
onSelectionChange: l
|
|
3761
3761
|
}) {
|
|
3762
|
-
const [d, h] = R(1), [u, m] = R(!1), [S, b] = R(!1), x = i === "horizontal", v = o && c ? mt(o.variants, c) : null,
|
|
3763
|
-
(W) => W.productEntityId === t.productEntityId && W.variantEntityId ===
|
|
3764
|
-
), w = !!I,
|
|
3762
|
+
const [d, h] = R(1), [u, m] = R(!1), [S, b] = R(!1), x = i === "horizontal", v = o && c ? mt(o.variants, c) : null, E = v?.entityId ?? t.variantEntityId, I = r.find(
|
|
3763
|
+
(W) => W.productEntityId === t.productEntityId && W.variantEntityId === E
|
|
3764
|
+
), w = !!I, k = I?.quantity ?? 0, g = v?.sku ?? t.sku, A = v?.prices?.price?.value ?? t.price, $ = v?.inventory?.aggregated?.availableToSell ?? t.availableQuantity, O = $ !== void 0 && $ > 0 && $ < Bs, Q = v?.inventory?.isInStock ?? t.isInStock, H = v !== null ? (
|
|
3765
3765
|
// Have variant details: check variant stock
|
|
3766
3766
|
!v.isPurchasable || Q === !1 || Q === void 0 && (v.inventory?.aggregated?.availableToSell ?? 0) === 0
|
|
3767
3767
|
) : (
|
|
@@ -3867,7 +3867,7 @@ function Mt({
|
|
|
3867
3867
|
!x && te,
|
|
3868
3868
|
w && /* @__PURE__ */ p("p", { className: "text-xs text-text-tertiary m-0 mb-1", children: [
|
|
3869
3869
|
"In cart (×",
|
|
3870
|
-
|
|
3870
|
+
k,
|
|
3871
3871
|
")"
|
|
3872
3872
|
] }),
|
|
3873
3873
|
/* @__PURE__ */ p(
|
|
@@ -3926,36 +3926,36 @@ function Fs({
|
|
|
3926
3926
|
), h = oe(() => {
|
|
3927
3927
|
const v = /* @__PURE__ */ new Map();
|
|
3928
3928
|
if (d)
|
|
3929
|
-
for (const
|
|
3930
|
-
|
|
3929
|
+
for (const E of d)
|
|
3930
|
+
E.productOptions.length > 0 && v.set(E.entityId, E);
|
|
3931
3931
|
return v;
|
|
3932
3932
|
}, [d]), [u, m] = R(/* @__PURE__ */ new Map());
|
|
3933
3933
|
F(() => {
|
|
3934
3934
|
d && m((v) => {
|
|
3935
|
-
const
|
|
3935
|
+
const E = new Map(v);
|
|
3936
3936
|
for (const I of t) {
|
|
3937
|
-
if (I.productEntityId === void 0 ||
|
|
3937
|
+
if (I.productEntityId === void 0 || E.has(I.id)) continue;
|
|
3938
3938
|
const w = d.find(
|
|
3939
3939
|
(g) => g.entityId === I.productEntityId
|
|
3940
3940
|
);
|
|
3941
3941
|
if (!w || w.productOptions.length === 0) continue;
|
|
3942
|
-
let
|
|
3942
|
+
let k;
|
|
3943
3943
|
if (I.variantEntityId) {
|
|
3944
3944
|
const g = w.variants.find(
|
|
3945
3945
|
(A) => A.entityId === I.variantEntityId
|
|
3946
3946
|
);
|
|
3947
|
-
g ?
|
|
3947
|
+
g ? k = Sr(g) : k = Bt(w);
|
|
3948
3948
|
} else
|
|
3949
|
-
|
|
3950
|
-
|
|
3949
|
+
k = Bt(w);
|
|
3950
|
+
E.set(I.id, k);
|
|
3951
3951
|
}
|
|
3952
|
-
return
|
|
3952
|
+
return E;
|
|
3953
3953
|
});
|
|
3954
3954
|
}, [d, t]);
|
|
3955
|
-
const S = (v,
|
|
3955
|
+
const S = (v, E, I) => {
|
|
3956
3956
|
m((w) => {
|
|
3957
|
-
const
|
|
3958
|
-
return g.set(
|
|
3957
|
+
const k = new Map(w), g = new Map(k.get(v) ?? /* @__PURE__ */ new Map());
|
|
3958
|
+
return g.set(E, I), k.set(v, g), k;
|
|
3959
3959
|
});
|
|
3960
3960
|
};
|
|
3961
3961
|
if (i)
|
|
@@ -3968,7 +3968,7 @@ function Fs({
|
|
|
3968
3968
|
return null;
|
|
3969
3969
|
const [x] = b;
|
|
3970
3970
|
if (b.length === 1 && x) {
|
|
3971
|
-
const v = x.productEntityId !== void 0 ? h.get(x.productEntityId) : void 0,
|
|
3971
|
+
const v = x.productEntityId !== void 0 ? h.get(x.productEntityId) : void 0, E = u.get(x.id);
|
|
3972
3972
|
return /* @__PURE__ */ a("div", { className: `py-2 ${o}`, children: /* @__PURE__ */ a(
|
|
3973
3973
|
Mt,
|
|
3974
3974
|
{
|
|
@@ -3978,13 +3978,13 @@ function Fs({
|
|
|
3978
3978
|
onViewProduct: r,
|
|
3979
3979
|
cart: n,
|
|
3980
3980
|
variantDetails: v,
|
|
3981
|
-
selections:
|
|
3981
|
+
selections: E,
|
|
3982
3982
|
onSelectionChange: v ? (I, w) => S(x.id, I, w) : void 0
|
|
3983
3983
|
}
|
|
3984
3984
|
) });
|
|
3985
3985
|
}
|
|
3986
3986
|
return /* @__PURE__ */ a("div", { className: `flex flex-wrap gap-3 py-2 ${o}`, children: b.map((v) => {
|
|
3987
|
-
const
|
|
3987
|
+
const E = v.productEntityId !== void 0 ? h.get(v.productEntityId) : void 0, I = u.get(v.id);
|
|
3988
3988
|
return /* @__PURE__ */ a(
|
|
3989
3989
|
Mt,
|
|
3990
3990
|
{
|
|
@@ -3992,9 +3992,9 @@ function Fs({
|
|
|
3992
3992
|
onAddToCart: e,
|
|
3993
3993
|
onViewProduct: r,
|
|
3994
3994
|
cart: n,
|
|
3995
|
-
variantDetails:
|
|
3995
|
+
variantDetails: E,
|
|
3996
3996
|
selections: I,
|
|
3997
|
-
onSelectionChange:
|
|
3997
|
+
onSelectionChange: E ? (w, k) => S(v.id, w, k) : void 0
|
|
3998
3998
|
},
|
|
3999
3999
|
v.id
|
|
4000
4000
|
);
|
|
@@ -4020,15 +4020,15 @@ function Os({
|
|
|
4020
4020
|
return;
|
|
4021
4021
|
}
|
|
4022
4022
|
const b = [
|
|
4023
|
-
...new Set(t.products.map((
|
|
4023
|
+
...new Set(t.products.map((E) => E.entityId))
|
|
4024
4024
|
], x = await s.getProductsForDisplay(b), v = [];
|
|
4025
|
-
for (const
|
|
4025
|
+
for (const E of t.products) {
|
|
4026
4026
|
const I = x.find(
|
|
4027
|
-
(
|
|
4027
|
+
(k) => k.entityId === E.entityId
|
|
4028
4028
|
);
|
|
4029
4029
|
if (!I) continue;
|
|
4030
|
-
const w =
|
|
4031
|
-
(
|
|
4030
|
+
const w = E.variantEntityId ? I.variants.find(
|
|
4031
|
+
(k) => k.entityId === E.variantEntityId
|
|
4032
4032
|
) : I.variants[0];
|
|
4033
4033
|
w && v.push({
|
|
4034
4034
|
id: `${I.entityId}-${w.entityId}`,
|
|
@@ -4440,15 +4440,15 @@ function Ft({
|
|
|
4440
4440
|
(w) => w.takeshapeConfig
|
|
4441
4441
|
), x = y((w) => w.chat.threadId), v = y(
|
|
4442
4442
|
(w) => w.parser.threadId
|
|
4443
|
-
),
|
|
4443
|
+
), E = y(
|
|
4444
4444
|
(w) => w.batchProcessing.threadIds
|
|
4445
4445
|
);
|
|
4446
4446
|
F(() => {
|
|
4447
4447
|
e && (i(""), o(""), l(""), h("idle"), m(""), S.current?.focus());
|
|
4448
4448
|
}, [e]), F(() => {
|
|
4449
4449
|
if (!e) return;
|
|
4450
|
-
const w = (
|
|
4451
|
-
|
|
4450
|
+
const w = (k) => {
|
|
4451
|
+
k.key === "Escape" && r();
|
|
4452
4452
|
};
|
|
4453
4453
|
return document.addEventListener("keydown", w), () => document.removeEventListener("keydown", w);
|
|
4454
4454
|
}, [e, r]);
|
|
@@ -4468,8 +4468,8 @@ function Ft({
|
|
|
4468
4468
|
projectId: b.projectId,
|
|
4469
4469
|
...x && { chatThreadId: x },
|
|
4470
4470
|
...v && { parserThreadId: v },
|
|
4471
|
-
...
|
|
4472
|
-
batchThreadIds:
|
|
4471
|
+
...E.length > 0 && {
|
|
4472
|
+
batchThreadIds: E.join(",")
|
|
4473
4473
|
}
|
|
4474
4474
|
}
|
|
4475
4475
|
}
|
|
@@ -4479,9 +4479,9 @@ function Ft({
|
|
|
4479
4479
|
email: s.trim(),
|
|
4480
4480
|
text: c.trim()
|
|
4481
4481
|
}), h("success");
|
|
4482
|
-
} catch (
|
|
4482
|
+
} catch (k) {
|
|
4483
4483
|
h("error"), m(
|
|
4484
|
-
|
|
4484
|
+
k instanceof Error ? k.message : "Failed to send feedback"
|
|
4485
4485
|
);
|
|
4486
4486
|
}
|
|
4487
4487
|
}
|
|
@@ -5029,7 +5029,7 @@ const Ys = Lr(
|
|
|
5029
5029
|
uploadedFileName: S = null,
|
|
5030
5030
|
fileDrop: b
|
|
5031
5031
|
}, x) {
|
|
5032
|
-
const v = D(null),
|
|
5032
|
+
const v = D(null), E = D(!0), [I, w] = R(!1), k = oe(() => {
|
|
5033
5033
|
for (let g = e.length - 1; g >= 0; g--) {
|
|
5034
5034
|
const A = e[g];
|
|
5035
5035
|
if (A?.role === "assistant")
|
|
@@ -5043,16 +5043,16 @@ const Ys = Lr(
|
|
|
5043
5043
|
g && (g.scrollHeight - g.scrollTop - g.clientHeight > 500 || !g.scrollTo ? g.scrollTop = g.scrollHeight : g.scrollTo({
|
|
5044
5044
|
top: g.scrollHeight,
|
|
5045
5045
|
behavior: "smooth"
|
|
5046
|
-
})),
|
|
5046
|
+
})), E.current = !0;
|
|
5047
5047
|
}
|
|
5048
5048
|
})), F(() => {
|
|
5049
5049
|
const g = v.current;
|
|
5050
5050
|
if (!g) return;
|
|
5051
5051
|
const A = () => {
|
|
5052
5052
|
const O = g.scrollHeight - g.scrollTop - g.clientHeight < 50;
|
|
5053
|
-
|
|
5053
|
+
E.current = O;
|
|
5054
5054
|
}, $ = new MutationObserver(() => {
|
|
5055
|
-
|
|
5055
|
+
E.current && (g.scrollTop = g.scrollHeight);
|
|
5056
5056
|
});
|
|
5057
5057
|
return g.addEventListener("scroll", A), $.observe(g, {
|
|
5058
5058
|
childList: !0,
|
|
@@ -5081,7 +5081,7 @@ const Ys = Lr(
|
|
|
5081
5081
|
}
|
|
5082
5082
|
),
|
|
5083
5083
|
e.map((g, A) => {
|
|
5084
|
-
const $ = m && g.role !== "assistant" && A === 0, O = g.role === "assistant" && g.id ===
|
|
5084
|
+
const $ = m && g.role !== "assistant" && A === 0, O = g.role === "assistant" && g.id === k;
|
|
5085
5085
|
return /* @__PURE__ */ a(
|
|
5086
5086
|
Hs,
|
|
5087
5087
|
{
|
|
@@ -5240,10 +5240,10 @@ function Dt({
|
|
|
5240
5240
|
onRemove: b,
|
|
5241
5241
|
onCheckout: x,
|
|
5242
5242
|
onSuggestAlternatives: v,
|
|
5243
|
-
onShowMoreLikeThis:
|
|
5243
|
+
onShowMoreLikeThis: E,
|
|
5244
5244
|
onViewProduct: I,
|
|
5245
5245
|
onAddToCart: w,
|
|
5246
|
-
orderId:
|
|
5246
|
+
orderId: k,
|
|
5247
5247
|
buyerInfo: g,
|
|
5248
5248
|
customerInfo: A,
|
|
5249
5249
|
addresses: $,
|
|
@@ -5265,14 +5265,14 @@ function Dt({
|
|
|
5265
5265
|
}) {
|
|
5266
5266
|
const K = ea(), [J, Pe] = R(
|
|
5267
5267
|
u.length > 0 ? "cart" : "chat"
|
|
5268
|
-
), [fe, me] = R(!1),
|
|
5268
|
+
), [fe, me] = R(!1), de = D(t.length), ge = D(J);
|
|
5269
5269
|
ge.current = J;
|
|
5270
|
-
const f = t.length === 0 && u.length === 0 && !!h,
|
|
5270
|
+
const f = t.length === 0 && u.length === 0 && !!h, N = ir({
|
|
5271
5271
|
onFile: h ?? (() => {
|
|
5272
5272
|
})
|
|
5273
5273
|
});
|
|
5274
5274
|
F(() => {
|
|
5275
|
-
t.length >
|
|
5275
|
+
t.length > de.current && ge.current !== "chat" && me(!0), de.current = t.length;
|
|
5276
5276
|
}, [t.length]), F(() => {
|
|
5277
5277
|
K.isDesktop && me(!1);
|
|
5278
5278
|
}, [K.isDesktop]);
|
|
@@ -5294,7 +5294,7 @@ function Dt({
|
|
|
5294
5294
|
onRetry: o,
|
|
5295
5295
|
hasProcessedDocument: c,
|
|
5296
5296
|
uploadedFileName: l,
|
|
5297
|
-
fileDrop: h ?
|
|
5297
|
+
fileDrop: h ? N : void 0
|
|
5298
5298
|
}
|
|
5299
5299
|
), M = /* @__PURE__ */ a(
|
|
5300
5300
|
ms,
|
|
@@ -5305,9 +5305,9 @@ function Dt({
|
|
|
5305
5305
|
onRemove: b,
|
|
5306
5306
|
onCheckout: x,
|
|
5307
5307
|
onSuggestAlternatives: v,
|
|
5308
|
-
onShowMoreLikeThis:
|
|
5308
|
+
onShowMoreLikeThis: E,
|
|
5309
5309
|
onViewProduct: I,
|
|
5310
|
-
orderId:
|
|
5310
|
+
orderId: k ?? void 0,
|
|
5311
5311
|
buyerInfo: g ?? void 0,
|
|
5312
5312
|
customerInfo: A,
|
|
5313
5313
|
addresses: $,
|
|
@@ -5322,13 +5322,13 @@ function Dt({
|
|
|
5322
5322
|
checkoutTotals: te ?? void 0,
|
|
5323
5323
|
isLoading: W,
|
|
5324
5324
|
poMetadataSet: V,
|
|
5325
|
-
isDragging: f &&
|
|
5325
|
+
isDragging: f && N.isDragging,
|
|
5326
5326
|
onNewOrder: ie,
|
|
5327
5327
|
onExpand: Ie,
|
|
5328
5328
|
onMinimize: _,
|
|
5329
5329
|
className: K.isDesktop ? "rounded-l-none border-0" : ""
|
|
5330
5330
|
}
|
|
5331
|
-
), L = f ?
|
|
5331
|
+
), L = f ? N.dragProps : void 0;
|
|
5332
5332
|
return K.isDesktop ? (
|
|
5333
5333
|
// biome-ignore lint/a11y/noStaticElementInteractions: dnd is optional
|
|
5334
5334
|
/* @__PURE__ */ p(
|
|
@@ -5910,7 +5910,7 @@ function Ia({
|
|
|
5910
5910
|
}
|
|
5911
5911
|
);
|
|
5912
5912
|
}
|
|
5913
|
-
function
|
|
5913
|
+
function he(t) {
|
|
5914
5914
|
return {
|
|
5915
5915
|
firstName: t.firstName,
|
|
5916
5916
|
lastName: t.lastName,
|
|
@@ -6010,11 +6010,11 @@ function ka(t) {
|
|
|
6010
6010
|
(f) => f.cartifact.poItemPrices
|
|
6011
6011
|
), b = y((f) => f.setBcCart), x = y((f) => f.setCheckout), v = y(
|
|
6012
6012
|
(f) => f.setSelectedAddressId
|
|
6013
|
-
),
|
|
6013
|
+
), E = y(
|
|
6014
6014
|
(f) => f.setAddressUpdateStatus
|
|
6015
6015
|
), I = y((f) => f.setIsLoading), w = y(
|
|
6016
6016
|
(f) => f.setProductPaths
|
|
6017
|
-
),
|
|
6017
|
+
), k = y(
|
|
6018
6018
|
(f) => f.cartifact.shipToAddress
|
|
6019
6019
|
), g = y(
|
|
6020
6020
|
(f) => f.cartifact.billingAddress
|
|
@@ -6029,7 +6029,7 @@ function ka(t) {
|
|
|
6029
6029
|
), H = y(
|
|
6030
6030
|
(f) => f.setItemWarnings
|
|
6031
6031
|
), z = oe(() => s ? s.lineItems.physicalItems.map((f) => {
|
|
6032
|
-
const
|
|
6032
|
+
const N = `${f.productEntityId}-${f.variantEntityId}`, T = S[N];
|
|
6033
6033
|
return {
|
|
6034
6034
|
productEntityId: f.productEntityId,
|
|
6035
6035
|
variantEntityId: f.variantEntityId ?? void 0,
|
|
@@ -6038,7 +6038,7 @@ function ka(t) {
|
|
|
6038
6038
|
poPriceCurrencyCode: T?.poCurrency
|
|
6039
6039
|
};
|
|
6040
6040
|
}) : [], [s, S]), ae = D(/* @__PURE__ */ new Set()), ee = B(
|
|
6041
|
-
async (f,
|
|
6041
|
+
async (f, N) => {
|
|
6042
6042
|
if (!n.current)
|
|
6043
6043
|
return;
|
|
6044
6044
|
const T = f.lineItems.physicalItems.map((P) => ({
|
|
@@ -6054,7 +6054,7 @@ function ka(t) {
|
|
|
6054
6054
|
try {
|
|
6055
6055
|
const P = await n.current.setCheckoutShippingAddress(
|
|
6056
6056
|
f.entityId,
|
|
6057
|
-
|
|
6057
|
+
N,
|
|
6058
6058
|
T
|
|
6059
6059
|
);
|
|
6060
6060
|
P && x(P);
|
|
@@ -6066,12 +6066,12 @@ function ka(t) {
|
|
|
6066
6066
|
},
|
|
6067
6067
|
[x]
|
|
6068
6068
|
), se = B(
|
|
6069
|
-
async (f,
|
|
6069
|
+
async (f, N) => {
|
|
6070
6070
|
if (n.current)
|
|
6071
6071
|
try {
|
|
6072
6072
|
const T = await n.current.setCheckoutBillingAddress(
|
|
6073
6073
|
f.entityId,
|
|
6074
|
-
|
|
6074
|
+
N
|
|
6075
6075
|
);
|
|
6076
6076
|
T && x(T);
|
|
6077
6077
|
} catch (T) {
|
|
@@ -6084,17 +6084,17 @@ function ka(t) {
|
|
|
6084
6084
|
);
|
|
6085
6085
|
F(() => {
|
|
6086
6086
|
if (!s || !n.current) return;
|
|
6087
|
-
const
|
|
6087
|
+
const N = [
|
|
6088
6088
|
...new Set(
|
|
6089
6089
|
s.lineItems.physicalItems.map((T) => T.productEntityId)
|
|
6090
6090
|
)
|
|
6091
6091
|
].filter(
|
|
6092
6092
|
(T) => !ae.current.has(T)
|
|
6093
6093
|
);
|
|
6094
|
-
if (
|
|
6095
|
-
for (const T of
|
|
6094
|
+
if (N.length !== 0) {
|
|
6095
|
+
for (const T of N)
|
|
6096
6096
|
ae.current.add(T);
|
|
6097
|
-
n.current.getProductPaths(
|
|
6097
|
+
n.current.getProductPaths(N).then((T) => {
|
|
6098
6098
|
if (T.size > 0) {
|
|
6099
6099
|
const P = {};
|
|
6100
6100
|
for (const [L, U] of T)
|
|
@@ -6109,49 +6109,58 @@ function ka(t) {
|
|
|
6109
6109
|
F(() => {
|
|
6110
6110
|
if (d)
|
|
6111
6111
|
return;
|
|
6112
|
-
if (!
|
|
6113
|
-
l.length === 0
|
|
6112
|
+
if (!k) {
|
|
6113
|
+
if (l.length === 0)
|
|
6114
|
+
v(le);
|
|
6115
|
+
else {
|
|
6116
|
+
const N = l.find(
|
|
6117
|
+
(P) => P.isDefaultShipping
|
|
6118
|
+
), T = l.find((P) => P.isShipping);
|
|
6119
|
+
v(
|
|
6120
|
+
N?.id ?? T?.id ?? le
|
|
6121
|
+
);
|
|
6122
|
+
}
|
|
6114
6123
|
return;
|
|
6115
6124
|
}
|
|
6116
6125
|
let f;
|
|
6117
6126
|
if (l.length > 0) {
|
|
6118
|
-
const
|
|
6119
|
-
|
|
6127
|
+
const N = qt(
|
|
6128
|
+
k,
|
|
6120
6129
|
l
|
|
6121
6130
|
);
|
|
6122
|
-
f =
|
|
6131
|
+
f = N ? N.id : be;
|
|
6123
6132
|
} else
|
|
6124
6133
|
f = be;
|
|
6125
6134
|
Y.current = !1, v(f);
|
|
6126
6135
|
}, [
|
|
6127
6136
|
l,
|
|
6128
|
-
|
|
6137
|
+
k,
|
|
6129
6138
|
v,
|
|
6130
6139
|
d
|
|
6131
6140
|
]), F(() => {
|
|
6132
|
-
if (Y.current || !s || !d || d ===
|
|
6141
|
+
if (Y.current || !s || !d || d === le)
|
|
6133
6142
|
return;
|
|
6134
6143
|
let f;
|
|
6135
|
-
d === be ? f =
|
|
6144
|
+
d === be ? f = k ?? void 0 : f = l.find((N) => N.id === d) ?? void 0, f && (Y.current = !0, ee(
|
|
6136
6145
|
s,
|
|
6137
|
-
|
|
6146
|
+
he(f)
|
|
6138
6147
|
));
|
|
6139
6148
|
}, [
|
|
6140
6149
|
s,
|
|
6141
6150
|
d,
|
|
6142
6151
|
l,
|
|
6143
|
-
|
|
6152
|
+
k,
|
|
6144
6153
|
ee
|
|
6145
6154
|
]), F(() => {
|
|
6146
6155
|
if (!g || A)
|
|
6147
6156
|
return;
|
|
6148
6157
|
let f;
|
|
6149
6158
|
if (l.length > 0) {
|
|
6150
|
-
const
|
|
6159
|
+
const N = qt(
|
|
6151
6160
|
g,
|
|
6152
6161
|
l
|
|
6153
6162
|
);
|
|
6154
|
-
f =
|
|
6163
|
+
f = N ? N.id : Se;
|
|
6155
6164
|
} else
|
|
6156
6165
|
f = Se;
|
|
6157
6166
|
te.current = !1, O(f);
|
|
@@ -6161,12 +6170,12 @@ function ka(t) {
|
|
|
6161
6170
|
O,
|
|
6162
6171
|
A
|
|
6163
6172
|
]), F(() => {
|
|
6164
|
-
if (te.current || !s || !A || A ===
|
|
6173
|
+
if (te.current || !s || !A || A === le)
|
|
6165
6174
|
return;
|
|
6166
6175
|
let f;
|
|
6167
|
-
A === Se ? f = g ?? void 0 : f = l.find((
|
|
6176
|
+
A === Se ? f = g ?? void 0 : f = l.find((N) => N.id === A) ?? void 0, f && (te.current = !0, se(
|
|
6168
6177
|
s,
|
|
6169
|
-
|
|
6178
|
+
he(f)
|
|
6170
6179
|
));
|
|
6171
6180
|
}, [
|
|
6172
6181
|
s,
|
|
@@ -6176,9 +6185,9 @@ function ka(t) {
|
|
|
6176
6185
|
se
|
|
6177
6186
|
]);
|
|
6178
6187
|
const W = D(void 0), V = D(void 0), ie = oe(() => s ? s.lineItems.physicalItems.map((f) => {
|
|
6179
|
-
const
|
|
6188
|
+
const N = z.find(
|
|
6180
6189
|
(L) => L.productEntityId === f.productEntityId && L.variantEntityId === f.variantEntityId
|
|
6181
|
-
), T =
|
|
6190
|
+
), T = N?.poPriceValue, P = f.listPrice.value, M = $r(T, P);
|
|
6182
6191
|
return {
|
|
6183
6192
|
id: f.entityId,
|
|
6184
6193
|
sku: f.sku ?? "",
|
|
@@ -6191,7 +6200,7 @@ function ka(t) {
|
|
|
6191
6200
|
quantity: f.quantity,
|
|
6192
6201
|
bcLineItemEntityId: f.entityId,
|
|
6193
6202
|
poPriceValue: T,
|
|
6194
|
-
poPriceCurrencyCode:
|
|
6203
|
+
poPriceCurrencyCode: N?.poPriceCurrencyCode,
|
|
6195
6204
|
catalogPriceCurrencyCode: f.listPrice.currencyCode,
|
|
6196
6205
|
status: M ? "price-mismatch" : "matched"
|
|
6197
6206
|
};
|
|
@@ -6205,23 +6214,23 @@ function ka(t) {
|
|
|
6205
6214
|
[s, o]
|
|
6206
6215
|
), _ = B(
|
|
6207
6216
|
async (f) => {
|
|
6208
|
-
if (!n.current || !f || !d || d ===
|
|
6217
|
+
if (!n.current || !f || !d || d === le || f.lineItems.physicalItems.length === 0)
|
|
6209
6218
|
return;
|
|
6210
|
-
let
|
|
6219
|
+
let N = null;
|
|
6211
6220
|
if (d === be)
|
|
6212
|
-
|
|
6221
|
+
k && (N = he(k));
|
|
6213
6222
|
else {
|
|
6214
6223
|
const T = l.find(
|
|
6215
6224
|
(P) => P.id === d
|
|
6216
6225
|
);
|
|
6217
|
-
T && (
|
|
6226
|
+
T && (N = he(T));
|
|
6218
6227
|
}
|
|
6219
|
-
|
|
6228
|
+
N && await ee(f, N);
|
|
6220
6229
|
},
|
|
6221
6230
|
[
|
|
6222
6231
|
d,
|
|
6223
6232
|
l,
|
|
6224
|
-
|
|
6233
|
+
k,
|
|
6225
6234
|
ee
|
|
6226
6235
|
]
|
|
6227
6236
|
), j = B(
|
|
@@ -6231,7 +6240,7 @@ function ka(t) {
|
|
|
6231
6240
|
return { cart: s, cartItems: [], errors: [] };
|
|
6232
6241
|
I(!0);
|
|
6233
6242
|
try {
|
|
6234
|
-
const
|
|
6243
|
+
const N = wa(z, f), T = await n.current.getCart();
|
|
6235
6244
|
let P = null;
|
|
6236
6245
|
const M = [];
|
|
6237
6246
|
if (T) {
|
|
@@ -6240,10 +6249,10 @@ function ka(t) {
|
|
|
6240
6249
|
f
|
|
6241
6250
|
);
|
|
6242
6251
|
if (P = T, G.length > 0) {
|
|
6243
|
-
const X = G.map((
|
|
6244
|
-
productEntityId:
|
|
6245
|
-
variantEntityId:
|
|
6246
|
-
quantity:
|
|
6252
|
+
const X = G.map((ue) => ({
|
|
6253
|
+
productEntityId: ue.productEntityId,
|
|
6254
|
+
variantEntityId: ue.variantEntityId,
|
|
6255
|
+
quantity: ue.quantity
|
|
6247
6256
|
})), { cart: Z, errors: ye } = await n.current.addCartLineItems(
|
|
6248
6257
|
T.entityId,
|
|
6249
6258
|
X
|
|
@@ -6278,7 +6287,7 @@ function ka(t) {
|
|
|
6278
6287
|
b(P);
|
|
6279
6288
|
const L = y.getState();
|
|
6280
6289
|
L.setCartEntityId(P?.entityId ?? null);
|
|
6281
|
-
for (const G of
|
|
6290
|
+
for (const G of N)
|
|
6282
6291
|
G.poPriceValue !== void 0 && G.poPriceCurrencyCode !== void 0 && L.setPoItemPrice(
|
|
6283
6292
|
G.productEntityId,
|
|
6284
6293
|
G.variantEntityId,
|
|
@@ -6293,8 +6302,8 @@ function ka(t) {
|
|
|
6293
6302
|
), ce = Object.keys(L.cartifact.poItemPrices);
|
|
6294
6303
|
for (const X of ce)
|
|
6295
6304
|
if (!G.has(X)) {
|
|
6296
|
-
const Z = X.split("-"), ye = Number(Z[0]),
|
|
6297
|
-
!Number.isNaN(ye) && !Number.isNaN(
|
|
6305
|
+
const Z = X.split("-"), ye = Number(Z[0]), ue = Number(Z[1]);
|
|
6306
|
+
!Number.isNaN(ye) && !Number.isNaN(ue) && L.removePoItemPrice(ye, ue);
|
|
6298
6307
|
}
|
|
6299
6308
|
}
|
|
6300
6309
|
if (P && !T && d) {
|
|
@@ -6303,14 +6312,14 @@ function ka(t) {
|
|
|
6303
6312
|
);
|
|
6304
6313
|
G && P.lineItems.physicalItems.length > 0 && (Y.current = !0, await ee(
|
|
6305
6314
|
P,
|
|
6306
|
-
|
|
6315
|
+
he(G)
|
|
6307
6316
|
));
|
|
6308
6317
|
}
|
|
6309
6318
|
if (!P)
|
|
6310
6319
|
return { cart: null, cartItems: [], errors: M };
|
|
6311
6320
|
const { cartItems: U } = Na(
|
|
6312
6321
|
P,
|
|
6313
|
-
|
|
6322
|
+
N
|
|
6314
6323
|
), je = y.getState().cartifact.itemWarnings, Oe = Ea(
|
|
6315
6324
|
je,
|
|
6316
6325
|
U
|
|
@@ -6334,19 +6343,19 @@ function ka(t) {
|
|
|
6334
6343
|
), K = B(
|
|
6335
6344
|
async (f) => {
|
|
6336
6345
|
if (!n.current) return { errors: [] };
|
|
6337
|
-
const
|
|
6346
|
+
const N = [];
|
|
6338
6347
|
for (const M of f) {
|
|
6339
|
-
const L =
|
|
6348
|
+
const L = N.findIndex(
|
|
6340
6349
|
(U) => U.productEntityId === M.productEntityId && U.variantEntityId === M.variantEntityId
|
|
6341
6350
|
);
|
|
6342
6351
|
if (L >= 0) {
|
|
6343
|
-
const U =
|
|
6352
|
+
const U = N[L];
|
|
6344
6353
|
U && (U.quantity += M.quantity, M.poPriceValue !== void 0 && M.poPriceCurrencyCode !== void 0 && (U.poPriceValue = M.poPriceValue, U.poPriceCurrencyCode = M.poPriceCurrencyCode));
|
|
6345
6354
|
} else
|
|
6346
|
-
|
|
6355
|
+
N.push({ ...M });
|
|
6347
6356
|
}
|
|
6348
6357
|
const T = [...z];
|
|
6349
|
-
for (const M of
|
|
6358
|
+
for (const M of N) {
|
|
6350
6359
|
const L = T.findIndex(
|
|
6351
6360
|
(U) => U.productEntityId === M.productEntityId && U.variantEntityId === M.variantEntityId
|
|
6352
6361
|
);
|
|
@@ -6361,7 +6370,7 @@ function ka(t) {
|
|
|
6361
6370
|
},
|
|
6362
6371
|
[j, z]
|
|
6363
6372
|
), J = B(
|
|
6364
|
-
async (f,
|
|
6373
|
+
async (f, N, T, P) => {
|
|
6365
6374
|
if (!n.current || !s?.entityId)
|
|
6366
6375
|
return null;
|
|
6367
6376
|
I(!0);
|
|
@@ -6369,7 +6378,7 @@ function ka(t) {
|
|
|
6369
6378
|
const M = await n.current.updateCartLineItem(
|
|
6370
6379
|
s.entityId,
|
|
6371
6380
|
f,
|
|
6372
|
-
|
|
6381
|
+
N,
|
|
6373
6382
|
T,
|
|
6374
6383
|
P
|
|
6375
6384
|
);
|
|
@@ -6394,14 +6403,14 @@ function ka(t) {
|
|
|
6394
6403
|
return null;
|
|
6395
6404
|
I(!0);
|
|
6396
6405
|
try {
|
|
6397
|
-
const
|
|
6406
|
+
const N = await n.current.deleteCartLineItem(
|
|
6398
6407
|
s.entityId,
|
|
6399
6408
|
f
|
|
6400
6409
|
);
|
|
6401
|
-
b(
|
|
6410
|
+
b(N);
|
|
6402
6411
|
const T = y.getState();
|
|
6403
|
-
if (
|
|
6404
|
-
const P =
|
|
6412
|
+
if (N) {
|
|
6413
|
+
const P = N.lineItems.physicalItems, M = z.filter(
|
|
6405
6414
|
(L) => !P.some(
|
|
6406
6415
|
(U) => U.productEntityId === L.productEntityId && U.variantEntityId === L.variantEntityId
|
|
6407
6416
|
)
|
|
@@ -6411,13 +6420,13 @@ function ka(t) {
|
|
|
6411
6420
|
L.productEntityId,
|
|
6412
6421
|
L.variantEntityId
|
|
6413
6422
|
);
|
|
6414
|
-
await _(
|
|
6423
|
+
await _(N);
|
|
6415
6424
|
} else
|
|
6416
6425
|
T.setCartEntityId(null), T.clearPoItemPrices(), x(null);
|
|
6417
|
-
return
|
|
6418
|
-
} catch (
|
|
6426
|
+
return N;
|
|
6427
|
+
} catch (N) {
|
|
6419
6428
|
return i.current?.(
|
|
6420
|
-
|
|
6429
|
+
N instanceof Error ? N : new Error("Failed to remove item")
|
|
6421
6430
|
), null;
|
|
6422
6431
|
} finally {
|
|
6423
6432
|
I(!1);
|
|
@@ -6438,13 +6447,13 @@ function ka(t) {
|
|
|
6438
6447
|
return console.error("initiateCheckout: No cart entity ID", { bcCart: s }), null;
|
|
6439
6448
|
I(!0);
|
|
6440
6449
|
try {
|
|
6441
|
-
const f = y.getState().chat.threadId,
|
|
6450
|
+
const f = y.getState().chat.threadId, N = y.getState().cartifact.orderId;
|
|
6442
6451
|
if (f)
|
|
6443
6452
|
try {
|
|
6444
6453
|
await n.current.updateCheckoutCustomerMessage(
|
|
6445
6454
|
s.entityId,
|
|
6446
6455
|
{
|
|
6447
|
-
purchaseOrderNumber:
|
|
6456
|
+
purchaseOrderNumber: N,
|
|
6448
6457
|
threadId: f
|
|
6449
6458
|
}
|
|
6450
6459
|
);
|
|
@@ -6458,7 +6467,7 @@ function ka(t) {
|
|
|
6458
6467
|
}
|
|
6459
6468
|
}, [s, I]), me = B(
|
|
6460
6469
|
async (f) => {
|
|
6461
|
-
if (f ===
|
|
6470
|
+
if (f === le) {
|
|
6462
6471
|
v(f);
|
|
6463
6472
|
return;
|
|
6464
6473
|
}
|
|
@@ -6470,14 +6479,14 @@ function ka(t) {
|
|
|
6470
6479
|
console.error("setShippingAddressOnCheckout: No cart entity ID");
|
|
6471
6480
|
return;
|
|
6472
6481
|
}
|
|
6473
|
-
let
|
|
6482
|
+
let N = null;
|
|
6474
6483
|
if (f === be)
|
|
6475
|
-
|
|
6484
|
+
k && (N = he(k));
|
|
6476
6485
|
else {
|
|
6477
6486
|
const P = l.find((M) => M.id === f);
|
|
6478
|
-
P && (
|
|
6487
|
+
P && (N = he(P));
|
|
6479
6488
|
}
|
|
6480
|
-
if (!
|
|
6489
|
+
if (!N) {
|
|
6481
6490
|
console.error(
|
|
6482
6491
|
"setShippingAddressOnCheckout: Address not found",
|
|
6483
6492
|
f
|
|
@@ -6492,21 +6501,21 @@ function ka(t) {
|
|
|
6492
6501
|
console.error("setShippingAddressOnCheckout: No line items in cart");
|
|
6493
6502
|
return;
|
|
6494
6503
|
}
|
|
6495
|
-
Y.current = !0, I(!0),
|
|
6504
|
+
Y.current = !0, I(!0), E("updating");
|
|
6496
6505
|
try {
|
|
6497
6506
|
const P = await n.current.setCheckoutShippingAddress(
|
|
6498
6507
|
s.entityId,
|
|
6499
|
-
|
|
6508
|
+
N,
|
|
6500
6509
|
T
|
|
6501
6510
|
);
|
|
6502
|
-
P && x(P), v(f),
|
|
6503
|
-
|
|
6511
|
+
P && x(P), v(f), E("success"), W.current !== void 0 && clearTimeout(W.current), W.current = window.setTimeout(() => {
|
|
6512
|
+
E("idle"), W.current = void 0;
|
|
6504
6513
|
}, 1500);
|
|
6505
6514
|
} catch (P) {
|
|
6506
|
-
console.error("setShippingAddressOnCheckout: API error", P),
|
|
6515
|
+
console.error("setShippingAddressOnCheckout: API error", P), E("error"), i.current?.(
|
|
6507
6516
|
P instanceof Error ? P : new Error("Failed to set shipping address")
|
|
6508
6517
|
), W.current !== void 0 && clearTimeout(W.current), W.current = window.setTimeout(() => {
|
|
6509
|
-
|
|
6518
|
+
E("idle"), W.current = void 0;
|
|
6510
6519
|
}, 3e3);
|
|
6511
6520
|
} finally {
|
|
6512
6521
|
I(!1);
|
|
@@ -6515,33 +6524,33 @@ function ka(t) {
|
|
|
6515
6524
|
[
|
|
6516
6525
|
s,
|
|
6517
6526
|
l,
|
|
6518
|
-
|
|
6527
|
+
k,
|
|
6519
6528
|
I,
|
|
6520
|
-
|
|
6529
|
+
E,
|
|
6521
6530
|
x,
|
|
6522
6531
|
v
|
|
6523
6532
|
]
|
|
6524
|
-
),
|
|
6533
|
+
), de = B(
|
|
6525
6534
|
async (f) => {
|
|
6526
|
-
if (f ===
|
|
6535
|
+
if (f === le) {
|
|
6527
6536
|
O(f);
|
|
6528
6537
|
return;
|
|
6529
6538
|
}
|
|
6530
6539
|
if (!n.current || !s?.entityId)
|
|
6531
6540
|
return;
|
|
6532
|
-
let
|
|
6541
|
+
let N = null;
|
|
6533
6542
|
if (f === Se)
|
|
6534
|
-
g && (
|
|
6543
|
+
g && (N = he(g));
|
|
6535
6544
|
else {
|
|
6536
6545
|
const T = l.find((P) => P.id === f);
|
|
6537
|
-
T && (
|
|
6546
|
+
T && (N = he(T));
|
|
6538
6547
|
}
|
|
6539
|
-
if (
|
|
6548
|
+
if (N) {
|
|
6540
6549
|
te.current = !0, I(!0), Q("updating");
|
|
6541
6550
|
try {
|
|
6542
6551
|
const T = await n.current.setCheckoutBillingAddress(
|
|
6543
6552
|
s.entityId,
|
|
6544
|
-
|
|
6553
|
+
N
|
|
6545
6554
|
);
|
|
6546
6555
|
T && x(T), O(f), Q("success"), V.current !== void 0 && clearTimeout(V.current), V.current = window.setTimeout(() => {
|
|
6547
6556
|
Q("idle"), V.current = void 0;
|
|
@@ -6593,7 +6602,7 @@ function ka(t) {
|
|
|
6593
6602
|
removeLineItem: Pe,
|
|
6594
6603
|
initiateCheckout: fe,
|
|
6595
6604
|
setShippingAddressOnCheckout: me,
|
|
6596
|
-
setBillingAddressOnCheckout:
|
|
6605
|
+
setBillingAddressOnCheckout: de,
|
|
6597
6606
|
clearCart: ge,
|
|
6598
6607
|
setSelectedAddressId: v,
|
|
6599
6608
|
setSelectedBillingAddressId: O
|
|
@@ -6647,8 +6656,8 @@ function Pa({
|
|
|
6647
6656
|
quantity: v
|
|
6648
6657
|
}
|
|
6649
6658
|
]), !0;
|
|
6650
|
-
} catch (
|
|
6651
|
-
return console.error("Failed to add to cart:",
|
|
6659
|
+
} catch (E) {
|
|
6660
|
+
return console.error("Failed to add to cart:", E), !1;
|
|
6652
6661
|
}
|
|
6653
6662
|
},
|
|
6654
6663
|
[t]
|
|
@@ -6698,12 +6707,12 @@ async function $a(t, e, r, n, i, s) {
|
|
|
6698
6707
|
let m = 0;
|
|
6699
6708
|
for (; m < u; ) {
|
|
6700
6709
|
m++;
|
|
6701
|
-
const
|
|
6710
|
+
const k = await _s(
|
|
6702
6711
|
t,
|
|
6703
6712
|
e,
|
|
6704
6713
|
r,
|
|
6705
6714
|
h
|
|
6706
|
-
), g = await Ls(
|
|
6715
|
+
), g = await Ls(k, {
|
|
6707
6716
|
onToolCall: s?.onToolCall
|
|
6708
6717
|
});
|
|
6709
6718
|
if (c.push(...g.textParts), o.push(...g.toolCalls), g.finalMessage && l.push(g.finalMessage), g.errorMessage?.includes(Ta)) {
|
|
@@ -6774,19 +6783,19 @@ async function $a(t, e, r, n, i, s) {
|
|
|
6774
6783
|
);
|
|
6775
6784
|
const S = l.length > 0 ? l.join(`
|
|
6776
6785
|
|
|
6777
|
-
`) : c.join(""), b = Aa(o), x = S + b,
|
|
6778
|
-
(
|
|
6779
|
-
).reduce((
|
|
6786
|
+
`) : c.join(""), b = Aa(o), x = S + b, E = d.filter(
|
|
6787
|
+
(k) => k.toolName === Fe
|
|
6788
|
+
).reduce((k, g) => {
|
|
6780
6789
|
const A = g.input?.value;
|
|
6781
|
-
return
|
|
6790
|
+
return k + (A?.length ?? 0);
|
|
6782
6791
|
}, 0), w = d.filter(
|
|
6783
|
-
(
|
|
6784
|
-
).reduce((
|
|
6792
|
+
(k) => k.toolName === pt
|
|
6793
|
+
).reduce((k, g) => {
|
|
6785
6794
|
const A = g.input?.processingFailures;
|
|
6786
|
-
return
|
|
6795
|
+
return k + (A?.length ?? 0);
|
|
6787
6796
|
}, 0);
|
|
6788
6797
|
return s?.logger?.debug(
|
|
6789
|
-
`Batch ${i}: ${m} iteration(s), ${d.length} client tool call(s), ${
|
|
6798
|
+
`Batch ${i}: ${m} iteration(s), ${d.length} client tool call(s), ${E} addToCart item(s), ${w} failure(s)`
|
|
6790
6799
|
), x && s?.logger?.debug(`Batch ${i} output: ${x}`), {
|
|
6791
6800
|
batchIndex: i,
|
|
6792
6801
|
threadId: r,
|
|
@@ -7219,11 +7228,11 @@ function Mr(t) {
|
|
|
7219
7228
|
);
|
|
7220
7229
|
return;
|
|
7221
7230
|
}
|
|
7222
|
-
const
|
|
7231
|
+
const E = 500 * 2 ** b;
|
|
7223
7232
|
console.warn(
|
|
7224
|
-
`Thread creation failed (attempt ${b + 1}/${S + 1}), retrying in ${
|
|
7233
|
+
`Thread creation failed (attempt ${b + 1}/${S + 1}), retrying in ${E}ms...`,
|
|
7225
7234
|
x
|
|
7226
|
-
), await new Promise((I) => setTimeout(I,
|
|
7235
|
+
), await new Promise((I) => setTimeout(I, E)), b++;
|
|
7227
7236
|
}
|
|
7228
7237
|
}, [e, c, s, l, i, o]);
|
|
7229
7238
|
return F(() => {
|
|
@@ -7291,7 +7300,7 @@ function ei() {
|
|
|
7291
7300
|
setIsUploadingFile: b,
|
|
7292
7301
|
parserError: x,
|
|
7293
7302
|
setParserError: v,
|
|
7294
|
-
handleFileUpload:
|
|
7303
|
+
handleFileUpload: E
|
|
7295
7304
|
} = Za({
|
|
7296
7305
|
createParserThread: s,
|
|
7297
7306
|
sendParserMessage: h
|
|
@@ -7304,8 +7313,8 @@ function ei() {
|
|
|
7304
7313
|
"file.type": g.type,
|
|
7305
7314
|
"file.size": g.size
|
|
7306
7315
|
}
|
|
7307
|
-
}),
|
|
7308
|
-
[
|
|
7316
|
+
}), E(g)),
|
|
7317
|
+
[E]
|
|
7309
7318
|
);
|
|
7310
7319
|
F(() => {
|
|
7311
7320
|
if (d.length > 0) {
|
|
@@ -7322,7 +7331,7 @@ function ei() {
|
|
|
7322
7331
|
}, [u, o]);
|
|
7323
7332
|
const w = B(() => {
|
|
7324
7333
|
l.current?.setStatus({ code: 2, message: "cancelled" }), l.current?.end(), l.current = null, v(null), m([]), y.getState().setParsedContent(null);
|
|
7325
|
-
}, [v, m]),
|
|
7334
|
+
}, [v, m]), k = B(() => {
|
|
7326
7335
|
l.current?.setStatus({ code: 2, message: "cancelled" }), l.current?.end(), l.current = null, m([]), y.getState().clearParser(), b(!1), v(null);
|
|
7327
7336
|
}, [m, b, v]);
|
|
7328
7337
|
return {
|
|
@@ -7334,7 +7343,7 @@ function ei() {
|
|
|
7334
7343
|
parserMessages: d,
|
|
7335
7344
|
handleFileUpload: I,
|
|
7336
7345
|
handleClearError: w,
|
|
7337
|
-
reset:
|
|
7346
|
+
reset: k
|
|
7338
7347
|
};
|
|
7339
7348
|
}
|
|
7340
7349
|
class ti {
|
|
@@ -7977,11 +7986,11 @@ function ki({
|
|
|
7977
7986
|
createOnMount: !l,
|
|
7978
7987
|
// Only create if no existing thread
|
|
7979
7988
|
existingThreadId: l
|
|
7980
|
-
}), b = y((C) => C.appState), x = y((C) => C.setAppState), v = D(null),
|
|
7989
|
+
}), b = y((C) => C.appState), x = y((C) => C.setAppState), v = D(null), E = D(
|
|
7981
7990
|
null
|
|
7982
7991
|
), I = D(
|
|
7983
7992
|
null
|
|
7984
|
-
), w = Le((C) => C.isExpanded),
|
|
7993
|
+
), w = Le((C) => C.isExpanded), k = Le((C) => C.setExpanded), g = Le((C) => C.reset), A = ei(), $ = ka({
|
|
7985
7994
|
client: n.client,
|
|
7986
7995
|
onError: (C) => console.error("BigCommerce error:", C)
|
|
7987
7996
|
}), O = y((C) => C.cartifact.orderId), Q = y((C) => C.cartifact.buyerInfo), H = y(
|
|
@@ -8011,15 +8020,15 @@ function ki({
|
|
|
8011
8020
|
throw new Error("No messages to send");
|
|
8012
8021
|
let we = [re];
|
|
8013
8022
|
if (re.role === "user" && C.messages.length >= 2) {
|
|
8014
|
-
const
|
|
8015
|
-
if (
|
|
8023
|
+
const pe = C.messages[C.messages.length - 2], Xe = _.current;
|
|
8024
|
+
if (pe?.role === "assistant" && Xe.size > 0) {
|
|
8016
8025
|
const gt = Ii(
|
|
8017
|
-
|
|
8026
|
+
pe.parts
|
|
8018
8027
|
).filter(
|
|
8019
8028
|
(yt) => Xe.has(yt.toolCallId)
|
|
8020
8029
|
);
|
|
8021
8030
|
Xe.clear(), gt.length > 0 && (we = [{
|
|
8022
|
-
...
|
|
8031
|
+
...pe,
|
|
8023
8032
|
parts: gt.map((Te) => ({
|
|
8024
8033
|
type: Te.type,
|
|
8025
8034
|
toolName: wi(Te),
|
|
@@ -8050,14 +8059,14 @@ function ki({
|
|
|
8050
8059
|
messages: h,
|
|
8051
8060
|
onToolCall: Ie,
|
|
8052
8061
|
onError: (C) => {
|
|
8053
|
-
console.error("[useChat onError]", C),
|
|
8062
|
+
console.error("[useChat onError]", C), E.current?.setStatus({
|
|
8054
8063
|
code: 2,
|
|
8055
8064
|
message: "internal_error"
|
|
8056
|
-
}),
|
|
8065
|
+
}), E.current?.end(), E.current = null;
|
|
8057
8066
|
}
|
|
8058
|
-
}),
|
|
8067
|
+
}), de = B(
|
|
8059
8068
|
(C) => {
|
|
8060
|
-
|
|
8069
|
+
E.current?.end(), E.current = nt({
|
|
8061
8070
|
name: "po-agent-turn",
|
|
8062
8071
|
op: "ai.agent",
|
|
8063
8072
|
attributes: {
|
|
@@ -8068,33 +8077,33 @@ function ki({
|
|
|
8068
8077
|
[K, r]
|
|
8069
8078
|
);
|
|
8070
8079
|
F(() => {
|
|
8071
|
-
J === "ready" &&
|
|
8080
|
+
J === "ready" && E.current && (E.current.setStatus({ code: 1, message: "ok" }), E.current.end(), E.current = null);
|
|
8072
8081
|
}, [J]), F(() => () => {
|
|
8073
|
-
|
|
8082
|
+
E.current?.end(), I.current?.end();
|
|
8074
8083
|
}, []), F(() => {
|
|
8075
8084
|
if (J === "ready" && ie.current.length > 0) {
|
|
8076
8085
|
const C = [...ie.current];
|
|
8077
8086
|
ie.current = [], mi(C, j, $).then(async (re) => {
|
|
8078
8087
|
for (const we of re.outputs)
|
|
8079
8088
|
_.current.add(we.toolCallId), await me(we);
|
|
8080
|
-
re.outputs.length > 0 &&
|
|
8089
|
+
re.outputs.length > 0 && de({ text: ot });
|
|
8081
8090
|
}).catch((re) => {
|
|
8082
8091
|
console.error("[executeDeferredToolCalls] Error:", re);
|
|
8083
8092
|
});
|
|
8084
8093
|
}
|
|
8085
|
-
}, [J, j, $, me,
|
|
8094
|
+
}, [J, j, $, me, de]), F(() => {
|
|
8086
8095
|
y.getState().setMessages(j);
|
|
8087
8096
|
}, [j]);
|
|
8088
8097
|
const ge = y(
|
|
8089
8098
|
(C) => C.ai.pendingMessage
|
|
8090
|
-
), f = y((C) => C.ai.shouldScroll),
|
|
8099
|
+
), f = y((C) => C.ai.shouldScroll), N = y((C) => C.consumeMessage);
|
|
8091
8100
|
F(() => {
|
|
8092
|
-
ge && (
|
|
8101
|
+
ge && (de({ text: ge }), N(), f && requestAnimationFrame(() => {
|
|
8093
8102
|
v.current?.scrollToBottom();
|
|
8094
8103
|
}));
|
|
8095
|
-
}, [ge, f,
|
|
8096
|
-
i && b === "chatting" &&
|
|
8097
|
-
}, [i, b,
|
|
8104
|
+
}, [ge, f, de, N]), F(() => {
|
|
8105
|
+
i && b === "chatting" && k(!0);
|
|
8106
|
+
}, [i, b, k]);
|
|
8098
8107
|
const T = m || J === "submitted" || J === "streaming", P = oe(() => ma(j, J), [j, J]), M = _a({
|
|
8099
8108
|
appState: b,
|
|
8100
8109
|
setAppState: x,
|
|
@@ -8132,11 +8141,11 @@ function ki({
|
|
|
8132
8141
|
},
|
|
8133
8142
|
[n.onViewProduct]
|
|
8134
8143
|
), ce = B(() => {
|
|
8135
|
-
const C = [...j].reverse().find((
|
|
8144
|
+
const C = [...j].reverse().find((pe) => pe.role === "user");
|
|
8136
8145
|
if (!C) return;
|
|
8137
8146
|
const re = C.parts?.filter(
|
|
8138
|
-
(
|
|
8139
|
-
).map((
|
|
8147
|
+
(pe) => pe.type === "text"
|
|
8148
|
+
).map((pe) => pe.text).join(`
|
|
8140
8149
|
`);
|
|
8141
8150
|
if (!re) return;
|
|
8142
8151
|
const we = j.lastIndexOf(C);
|
|
@@ -8173,7 +8182,7 @@ function ki({
|
|
|
8173
8182
|
parserError: A.parserError
|
|
8174
8183
|
}
|
|
8175
8184
|
) });
|
|
8176
|
-
const
|
|
8185
|
+
const ue = {
|
|
8177
8186
|
className: t,
|
|
8178
8187
|
messages: j,
|
|
8179
8188
|
input: d,
|
|
@@ -8212,11 +8221,11 @@ function ki({
|
|
|
8212
8221
|
poMetadataSet: ae,
|
|
8213
8222
|
onNewOrder: ye
|
|
8214
8223
|
};
|
|
8215
|
-
return i && w ? /* @__PURE__ */ a(An, { children: /* @__PURE__ */ a(Dt, { ...
|
|
8224
|
+
return i && w ? /* @__PURE__ */ a(An, { children: /* @__PURE__ */ a(Dt, { ...ue, onMinimize: () => k(!1) }) }) : /* @__PURE__ */ a("div", { className: "h-full max-w-[1440px] mx-auto", children: /* @__PURE__ */ a(
|
|
8216
8225
|
Dt,
|
|
8217
8226
|
{
|
|
8218
|
-
...
|
|
8219
|
-
onExpand: i ? () =>
|
|
8227
|
+
...ue,
|
|
8228
|
+
onExpand: i ? () => k(!0) : void 0
|
|
8220
8229
|
}
|
|
8221
8230
|
) });
|
|
8222
8231
|
}
|
|
@@ -8271,4 +8280,4 @@ export {
|
|
|
8271
8280
|
Vi as r,
|
|
8272
8281
|
Gi as s
|
|
8273
8282
|
};
|
|
8274
|
-
//# sourceMappingURL=purchase-order-chat-wrapper-
|
|
8283
|
+
//# sourceMappingURL=purchase-order-chat-wrapper-CtCPGHtH.js.map
|