@takeshape/purchase-order-chat 1.60.2 → 1.61.0
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-fadhXbv8.js} +435 -426
- package/dist/purchase-order-chat-wrapper-fadhXbv8.js.map +1 -0
- 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.map +0 -1
package/dist/{purchase-order-chat-wrapper-D6twvEIU.js → purchase-order-chat-wrapper-fadhXbv8.js}
RENAMED
|
@@ -16,13 +16,13 @@ import Jr from "p-map";
|
|
|
16
16
|
function ke(...t) {
|
|
17
17
|
return Gr(Hr(t));
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function zi(t, e) {
|
|
20
20
|
return t.replace(/:(\w+)/g, (r, n) => {
|
|
21
21
|
const i = e[n];
|
|
22
22
|
return i != null ? String(i) : "";
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
const Yr = "
|
|
25
|
+
const Yr = "__vite_c_css_pos_initial_02ff19dc5b2e4ea6b665b8372abc1362", vt = "__vite_c_css_pos_update_02ff19dc5b2e4ea6b665b8372abc1362", Ct = () => typeof window < "u" ? window[Yr] : void 0, Qi = (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 {
|
|
@@ -1532,7 +1532,7 @@ class Pn {
|
|
|
1532
1532
|
return n;
|
|
1533
1533
|
}
|
|
1534
1534
|
}
|
|
1535
|
-
function
|
|
1535
|
+
function Hi(t) {
|
|
1536
1536
|
return `https://store-${t}.mybigcommerce.com/graphql`;
|
|
1537
1537
|
}
|
|
1538
1538
|
function Tn(t) {
|
|
@@ -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
|
)
|
|
@@ -3515,18 +3515,18 @@ function vs({
|
|
|
3515
3515
|
}
|
|
3516
3516
|
) });
|
|
3517
3517
|
}
|
|
3518
|
-
const mr = "showProducts", Cs = "searchProducts", Is = "searchProductsBySku", Fe = "addToCart", gr = "updateCart", yr = "removeFromCart", xr = "clearCart", br = "getCart", ut = "getPurchaseOrderData", Ye = "setPoMetadata", vr = "setItemWarnings", Cr = "removeItemWarnings", pt = "addProcessingFailures",
|
|
3519
|
-
function Ss(t) {
|
|
3520
|
-
return t.type === "tool" && !ws.has(t.toolName);
|
|
3521
|
-
}
|
|
3518
|
+
const mr = "showProducts", Cs = "searchProducts", Is = "searchProductsFromChat", ws = "searchProductsBySku", Fe = "addToCart", gr = "updateCart", yr = "removeFromCart", xr = "clearCart", br = "getCart", ut = "getPurchaseOrderData", Ye = "setPoMetadata", vr = "setItemWarnings", Cr = "removeItemWarnings", pt = "addProcessingFailures", Ss = /* @__PURE__ */ new Set([mr]);
|
|
3522
3519
|
function Ns(t) {
|
|
3520
|
+
return t.type === "tool" && !Ss.has(t.toolName);
|
|
3521
|
+
}
|
|
3522
|
+
function Es(t) {
|
|
3523
3523
|
const e = [];
|
|
3524
3524
|
let r = [];
|
|
3525
3525
|
function n() {
|
|
3526
3526
|
r.length >= 2 ? e.push({ type: "tool-group", tools: r }) : r.length === 1 && e.push(r[0]), r = [];
|
|
3527
3527
|
}
|
|
3528
3528
|
for (const i of t)
|
|
3529
|
-
|
|
3529
|
+
Ns(i) ? r.push(i) : (n(), e.push(i));
|
|
3530
3530
|
return n(), e;
|
|
3531
3531
|
}
|
|
3532
3532
|
const $t = () => /* @__PURE__ */ p(
|
|
@@ -3586,7 +3586,7 @@ function ht(t) {
|
|
|
3586
3586
|
return;
|
|
3587
3587
|
}
|
|
3588
3588
|
}
|
|
3589
|
-
function
|
|
3589
|
+
function ks({
|
|
3590
3590
|
toolCallId: t,
|
|
3591
3591
|
toolInput: e,
|
|
3592
3592
|
toolOutput: r,
|
|
@@ -3612,7 +3612,7 @@ function Es({
|
|
|
3612
3612
|
}
|
|
3613
3613
|
);
|
|
3614
3614
|
}
|
|
3615
|
-
function
|
|
3615
|
+
function Ps({
|
|
3616
3616
|
toolCallId: t,
|
|
3617
3617
|
toolInput: e,
|
|
3618
3618
|
toolOutput: r,
|
|
@@ -3628,12 +3628,12 @@ function ks({
|
|
|
3628
3628
|
successMessage: ""
|
|
3629
3629
|
}
|
|
3630
3630
|
);
|
|
3631
|
-
const c = ht(r)?.data?.searchProducts?.total ?? 0;
|
|
3631
|
+
const c = ht(r)?.data, l = c?.searchProducts?.total ?? c?.searchProductsFromChat?.total ?? 0;
|
|
3632
3632
|
return /* @__PURE__ */ a(
|
|
3633
3633
|
ne,
|
|
3634
3634
|
{
|
|
3635
3635
|
toolCallId: t,
|
|
3636
|
-
successMessage: `Found ${
|
|
3636
|
+
successMessage: `Found ${l} product${l !== 1 ? "s" : ""} for '${i}'`,
|
|
3637
3637
|
toolOutput: r
|
|
3638
3638
|
}
|
|
3639
3639
|
);
|
|
@@ -3641,7 +3641,7 @@ function ks({
|
|
|
3641
3641
|
const wr = Rr(
|
|
3642
3642
|
null
|
|
3643
3643
|
);
|
|
3644
|
-
function
|
|
3644
|
+
function Ts({
|
|
3645
3645
|
client: t,
|
|
3646
3646
|
children: e
|
|
3647
3647
|
}) {
|
|
@@ -3650,7 +3650,7 @@ function Ps({
|
|
|
3650
3650
|
function ft() {
|
|
3651
3651
|
return Dr(wr);
|
|
3652
3652
|
}
|
|
3653
|
-
function
|
|
3653
|
+
function As(t, e) {
|
|
3654
3654
|
return qr({
|
|
3655
3655
|
queryKey: [
|
|
3656
3656
|
"productVariants",
|
|
@@ -3694,7 +3694,7 @@ function Bt(t) {
|
|
|
3694
3694
|
}
|
|
3695
3695
|
return e;
|
|
3696
3696
|
}
|
|
3697
|
-
const
|
|
3697
|
+
const $s = () => /* @__PURE__ */ a("div", { className: "w-full h-full bg-surface-tertiary flex items-center justify-center text-text-quaternary", children: /* @__PURE__ */ p(
|
|
3698
3698
|
"svg",
|
|
3699
3699
|
{
|
|
3700
3700
|
width: "40",
|
|
@@ -3711,7 +3711,7 @@ const As = () => /* @__PURE__ */ a("div", { className: "w-full h-full bg-surface
|
|
|
3711
3711
|
]
|
|
3712
3712
|
}
|
|
3713
3713
|
) });
|
|
3714
|
-
function
|
|
3714
|
+
function Bs({
|
|
3715
3715
|
variantDetails: t,
|
|
3716
3716
|
selections: e,
|
|
3717
3717
|
onSelectionChange: r
|
|
@@ -3744,8 +3744,8 @@ function $s({
|
|
|
3744
3744
|
i && /* @__PURE__ */ a("p", { className: "text-xs text-error m-0", role: "alert", "aria-live": "polite", children: "This combination is not available" })
|
|
3745
3745
|
] });
|
|
3746
3746
|
}
|
|
3747
|
-
const
|
|
3748
|
-
function
|
|
3747
|
+
const Ms = 10;
|
|
3748
|
+
function Fs(t, e, r) {
|
|
3749
3749
|
return t ? "bg-surface-tertiary text-text cursor-not-allowed" : e ? "bg-success/20 text-success-text cursor-not-allowed" : r ? "bg-surface-disabled text-text-quaternary cursor-not-allowed" : "bg-surface-invert text-text-invert hover:bg-surface-invert-hover cursor-pointer";
|
|
3750
3750
|
}
|
|
3751
3751
|
function Mt({
|
|
@@ -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 && $ < Ms, 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
|
) : (
|
|
@@ -3814,7 +3814,7 @@ function Mt({
|
|
|
3814
3814
|
alt: t.name,
|
|
3815
3815
|
className: "w-full h-full object-cover"
|
|
3816
3816
|
}
|
|
3817
|
-
) : /* @__PURE__ */ a(
|
|
3817
|
+
) : /* @__PURE__ */ a($s, {}),
|
|
3818
3818
|
!x && H && /* @__PURE__ */ a("div", { className: "absolute top-2 right-2 bg-error text-text-invert text-xs font-semibold px-2 py-0.5 rounded", children: "Out of stock" })
|
|
3819
3819
|
]
|
|
3820
3820
|
}
|
|
@@ -3852,7 +3852,7 @@ function Mt({
|
|
|
3852
3852
|
x && te
|
|
3853
3853
|
] }),
|
|
3854
3854
|
o && c && l && /* @__PURE__ */ a("div", { className: x ? "mt-2" : "shrink-0 px-3 pt-2", children: /* @__PURE__ */ a(
|
|
3855
|
-
|
|
3855
|
+
Bs,
|
|
3856
3856
|
{
|
|
3857
3857
|
variantDetails: o,
|
|
3858
3858
|
selections: c,
|
|
@@ -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(
|
|
@@ -3891,7 +3891,7 @@ function Mt({
|
|
|
3891
3891
|
type: "button",
|
|
3892
3892
|
onClick: ae,
|
|
3893
3893
|
disabled: u || S || !!z || H,
|
|
3894
|
-
className: `py-1.5 px-3 text-xs font-medium rounded border-none ${x ? "" : "w-full"} ${
|
|
3894
|
+
className: `py-1.5 px-3 text-xs font-medium rounded border-none ${x ? "" : "w-full"} ${Fs(u, S, !!z || H)}`,
|
|
3895
3895
|
children: u ? "Adding..." : S ? "✓ Added" : "Add to cart"
|
|
3896
3896
|
}
|
|
3897
3897
|
)
|
|
@@ -3908,7 +3908,7 @@ function Mt({
|
|
|
3908
3908
|
}
|
|
3909
3909
|
);
|
|
3910
3910
|
}
|
|
3911
|
-
function
|
|
3911
|
+
function Os({
|
|
3912
3912
|
products: t,
|
|
3913
3913
|
onAddToCart: e,
|
|
3914
3914
|
onViewProduct: r,
|
|
@@ -3920,42 +3920,42 @@ function Fs({
|
|
|
3920
3920
|
const c = ft(), l = oe(
|
|
3921
3921
|
() => t.filter((v) => v.productEntityId !== void 0).map((v) => v.productEntityId),
|
|
3922
3922
|
[t]
|
|
3923
|
-
), { data: d } =
|
|
3923
|
+
), { data: d } = As(
|
|
3924
3924
|
c,
|
|
3925
3925
|
c ? l : []
|
|
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,15 +3992,15 @@ 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
|
);
|
|
4001
4001
|
}) });
|
|
4002
4002
|
}
|
|
4003
|
-
function
|
|
4003
|
+
function Rs({
|
|
4004
4004
|
toolInput: t,
|
|
4005
4005
|
toolState: e,
|
|
4006
4006
|
cart: r,
|
|
@@ -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}`,
|
|
@@ -4055,7 +4055,7 @@ function Os({
|
|
|
4055
4055
|
}
|
|
4056
4056
|
S();
|
|
4057
4057
|
}, [s, t]), h ? /* @__PURE__ */ a("div", { className: "py-2 text-sm text-error-text", children: h }) : /* @__PURE__ */ a(
|
|
4058
|
-
|
|
4058
|
+
Os,
|
|
4059
4059
|
{
|
|
4060
4060
|
products: o,
|
|
4061
4061
|
onAddToCart: n,
|
|
@@ -4077,7 +4077,7 @@ function Nr({
|
|
|
4077
4077
|
onViewProduct: c
|
|
4078
4078
|
}) {
|
|
4079
4079
|
return e === mr ? /* @__PURE__ */ a("div", { className: "mt-3", children: /* @__PURE__ */ a(
|
|
4080
|
-
|
|
4080
|
+
Rs,
|
|
4081
4081
|
{
|
|
4082
4082
|
toolInput: r,
|
|
4083
4083
|
toolOutput: n,
|
|
@@ -4086,16 +4086,16 @@ function Nr({
|
|
|
4086
4086
|
onAddToCart: o,
|
|
4087
4087
|
onViewProduct: c
|
|
4088
4088
|
}
|
|
4089
|
-
) }) : e === Cs ? /* @__PURE__ */ a(
|
|
4090
|
-
|
|
4089
|
+
) }) : e === Cs || e === Is ? /* @__PURE__ */ a(
|
|
4090
|
+
Ps,
|
|
4091
4091
|
{
|
|
4092
4092
|
toolCallId: t,
|
|
4093
4093
|
toolInput: r,
|
|
4094
4094
|
toolOutput: n,
|
|
4095
4095
|
toolState: i ?? ""
|
|
4096
4096
|
}
|
|
4097
|
-
) : e ===
|
|
4098
|
-
|
|
4097
|
+
) : e === ws ? /* @__PURE__ */ a(
|
|
4098
|
+
ks,
|
|
4099
4099
|
{
|
|
4100
4100
|
toolCallId: t,
|
|
4101
4101
|
toolInput: r,
|
|
@@ -4180,7 +4180,7 @@ function Nr({
|
|
|
4180
4180
|
}
|
|
4181
4181
|
) : null;
|
|
4182
4182
|
}
|
|
4183
|
-
function
|
|
4183
|
+
function Ds({
|
|
4184
4184
|
tools: t,
|
|
4185
4185
|
messageId: e,
|
|
4186
4186
|
cart: r,
|
|
@@ -4238,10 +4238,10 @@ function Rs({
|
|
|
4238
4238
|
)
|
|
4239
4239
|
] });
|
|
4240
4240
|
}
|
|
4241
|
-
const
|
|
4241
|
+
const Ls = bt.object({
|
|
4242
4242
|
id: bt.string()
|
|
4243
4243
|
});
|
|
4244
|
-
async function
|
|
4244
|
+
async function _s(t, e) {
|
|
4245
4245
|
if (!t.body)
|
|
4246
4246
|
throw new Error("No response body");
|
|
4247
4247
|
const r = [], n = /* @__PURE__ */ new Set(), i = [];
|
|
@@ -4319,9 +4319,9 @@ async function Er(t, e) {
|
|
|
4319
4319
|
);
|
|
4320
4320
|
}
|
|
4321
4321
|
const o = await s.json();
|
|
4322
|
-
return
|
|
4322
|
+
return Ls.parse(o).id;
|
|
4323
4323
|
}
|
|
4324
|
-
async function
|
|
4324
|
+
async function Us(t, e, r, n) {
|
|
4325
4325
|
const { sseOrigin: i, projectId: s, apiKey: o } = t, c = await Ee(
|
|
4326
4326
|
`${i}/project/${s}/agents/messages`,
|
|
4327
4327
|
{
|
|
@@ -4358,7 +4358,7 @@ async function _s(t, e, r, n) {
|
|
|
4358
4358
|
}
|
|
4359
4359
|
return c;
|
|
4360
4360
|
}
|
|
4361
|
-
const
|
|
4361
|
+
const qs = `
|
|
4362
4362
|
mutation SendFeedback(
|
|
4363
4363
|
$messageId: String!
|
|
4364
4364
|
$name: String!
|
|
@@ -4375,7 +4375,7 @@ const Us = `
|
|
|
4375
4375
|
)
|
|
4376
4376
|
}
|
|
4377
4377
|
`;
|
|
4378
|
-
async function
|
|
4378
|
+
async function js(t, e) {
|
|
4379
4379
|
const { origin: r, projectId: n, apiKey: i } = t, s = await Ee(`${r}/project/${n}/graphql`, {
|
|
4380
4380
|
method: "POST",
|
|
4381
4381
|
headers: {
|
|
@@ -4383,7 +4383,7 @@ async function qs(t, e) {
|
|
|
4383
4383
|
Authorization: `Bearer ${i}`
|
|
4384
4384
|
},
|
|
4385
4385
|
body: JSON.stringify({
|
|
4386
|
-
query:
|
|
4386
|
+
query: qs,
|
|
4387
4387
|
variables: {
|
|
4388
4388
|
messageId: e.messageId,
|
|
4389
4389
|
name: e.name,
|
|
@@ -4406,7 +4406,7 @@ async function qs(t, e) {
|
|
|
4406
4406
|
);
|
|
4407
4407
|
return !0;
|
|
4408
4408
|
}
|
|
4409
|
-
const
|
|
4409
|
+
const Ws = {
|
|
4410
4410
|
end: () => {
|
|
4411
4411
|
},
|
|
4412
4412
|
setStatus: () => {
|
|
@@ -4415,13 +4415,13 @@ const js = {
|
|
|
4415
4415
|
}
|
|
4416
4416
|
};
|
|
4417
4417
|
let Ue = null;
|
|
4418
|
-
function
|
|
4418
|
+
function Gi(t) {
|
|
4419
4419
|
Ue = t;
|
|
4420
4420
|
}
|
|
4421
4421
|
function nt(t) {
|
|
4422
|
-
return Ue ? Ue.startInactiveSpan(t) :
|
|
4422
|
+
return Ue ? Ue.startInactiveSpan(t) : Ws;
|
|
4423
4423
|
}
|
|
4424
|
-
function
|
|
4424
|
+
function Vs(t, e) {
|
|
4425
4425
|
Ue && Ue.captureFeedback(
|
|
4426
4426
|
t,
|
|
4427
4427
|
e?.tags ? {
|
|
@@ -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]);
|
|
@@ -4456,7 +4456,7 @@ function Ft({
|
|
|
4456
4456
|
if (w.preventDefault(), !(!n.trim() || !c.trim())) {
|
|
4457
4457
|
h("submitting"), m("");
|
|
4458
4458
|
try {
|
|
4459
|
-
|
|
4459
|
+
Vs(
|
|
4460
4460
|
{
|
|
4461
4461
|
name: n.trim(),
|
|
4462
4462
|
email: s.trim() || void 0,
|
|
@@ -4468,20 +4468,20 @@ 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
|
}
|
|
4476
|
-
), await
|
|
4476
|
+
), await js(b, {
|
|
4477
4477
|
messageId: t,
|
|
4478
4478
|
name: n.trim(),
|
|
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
|
}
|
|
@@ -4639,7 +4639,7 @@ const Ot = ({ size: t = 12 }) => /* @__PURE__ */ p(
|
|
|
4639
4639
|
]
|
|
4640
4640
|
}
|
|
4641
4641
|
);
|
|
4642
|
-
function
|
|
4642
|
+
function zs({
|
|
4643
4643
|
messagePartId: t,
|
|
4644
4644
|
messageId: e,
|
|
4645
4645
|
isLatestAssistantMessage: r,
|
|
@@ -4734,7 +4734,7 @@ function Vs({
|
|
|
4734
4734
|
)
|
|
4735
4735
|
] });
|
|
4736
4736
|
}
|
|
4737
|
-
function
|
|
4737
|
+
function Qs(t) {
|
|
4738
4738
|
if (!t.parts)
|
|
4739
4739
|
return [];
|
|
4740
4740
|
const e = [];
|
|
@@ -4757,11 +4757,11 @@ function zs(t) {
|
|
|
4757
4757
|
}
|
|
4758
4758
|
return e;
|
|
4759
4759
|
}
|
|
4760
|
-
function
|
|
4760
|
+
function Hs(t) {
|
|
4761
4761
|
const e = t?.find((r) => r.type === "file");
|
|
4762
4762
|
return e && "filename" in e && typeof e.filename == "string" ? e.filename : "Attachment";
|
|
4763
4763
|
}
|
|
4764
|
-
function
|
|
4764
|
+
function Gs({
|
|
4765
4765
|
message: t,
|
|
4766
4766
|
isFirstUserMessage: e,
|
|
4767
4767
|
isLatestAssistantMessage: r,
|
|
@@ -4772,7 +4772,7 @@ function Hs({
|
|
|
4772
4772
|
onAddToCart: c,
|
|
4773
4773
|
onViewProduct: l
|
|
4774
4774
|
}) {
|
|
4775
|
-
const d = t.role === "assistant", h =
|
|
4775
|
+
const d = t.role === "assistant", h = Qs(t);
|
|
4776
4776
|
return h.length === 0 ? null : /* @__PURE__ */ a(
|
|
4777
4777
|
"div",
|
|
4778
4778
|
{
|
|
@@ -4816,8 +4816,8 @@ function Hs({
|
|
|
4816
4816
|
`text-${t.id}-${m}`
|
|
4817
4817
|
) : null) })
|
|
4818
4818
|
] }) : /* @__PURE__ */ p(ve, { children: [
|
|
4819
|
-
|
|
4820
|
-
|
|
4819
|
+
Es(h).map((u, m) => u.type === "tool-group" ? /* @__PURE__ */ a(
|
|
4820
|
+
Ds,
|
|
4821
4821
|
{
|
|
4822
4822
|
tools: u.tools,
|
|
4823
4823
|
messageId: `${t.id}-${m}`,
|
|
@@ -4827,7 +4827,7 @@ function Hs({
|
|
|
4827
4827
|
},
|
|
4828
4828
|
`group-${t.id}-${m}`
|
|
4829
4829
|
) : u.type === "text" ? d ? /* @__PURE__ */ a(
|
|
4830
|
-
|
|
4830
|
+
zs,
|
|
4831
4831
|
{
|
|
4832
4832
|
messagePartId: `${t.id}-${m}`,
|
|
4833
4833
|
messageId: t.id,
|
|
@@ -4864,7 +4864,7 @@ function Hs({
|
|
|
4864
4864
|
) }, u.toolCallId) : null),
|
|
4865
4865
|
!d && t.parts?.some((u) => u.type === "file") && /* @__PURE__ */ p("div", { className: "flex items-center gap-1.5 mt-2 text-xs text-text-tertiary", children: [
|
|
4866
4866
|
/* @__PURE__ */ a($t, {}),
|
|
4867
|
-
/* @__PURE__ */ a("span", { children:
|
|
4867
|
+
/* @__PURE__ */ a("span", { children: Hs(t.parts) })
|
|
4868
4868
|
] })
|
|
4869
4869
|
] }) })
|
|
4870
4870
|
}
|
|
@@ -4902,7 +4902,7 @@ const Pr = () => /* @__PURE__ */ p(
|
|
|
4902
4902
|
/* @__PURE__ */ a("polyline", { points: "9 15 12 12 15 15" })
|
|
4903
4903
|
]
|
|
4904
4904
|
}
|
|
4905
|
-
),
|
|
4905
|
+
), Ks = () => /* @__PURE__ */ p(
|
|
4906
4906
|
"svg",
|
|
4907
4907
|
{
|
|
4908
4908
|
width: "16",
|
|
@@ -4928,13 +4928,13 @@ function Tr({ onClick: t }) {
|
|
|
4928
4928
|
className: "flex items-center gap-2 min-h-11 py-2.5 px-5 bg-surface border border-border-strong rounded-full text-sm font-medium text-text cursor-pointer transition-colors hover:bg-surface-secondary focus-visible:outline-2 focus-visible:outline-border-focus focus-visible:outline-offset-2",
|
|
4929
4929
|
onClick: t,
|
|
4930
4930
|
children: [
|
|
4931
|
-
/* @__PURE__ */ a(
|
|
4931
|
+
/* @__PURE__ */ a(Ks, {}),
|
|
4932
4932
|
"Take a photo"
|
|
4933
4933
|
]
|
|
4934
4934
|
}
|
|
4935
4935
|
);
|
|
4936
4936
|
}
|
|
4937
|
-
function
|
|
4937
|
+
function Js({
|
|
4938
4938
|
isDragging: t = !1,
|
|
4939
4939
|
fileInputRef: e,
|
|
4940
4940
|
cameraInputRef: r,
|
|
@@ -5000,7 +5000,7 @@ function Ks({
|
|
|
5000
5000
|
n && /* @__PURE__ */ a("div", { className: "flex items-center gap-2 py-3 px-4 bg-error-bg border border-error/30 rounded-lg text-error-text text-sm max-w-[400px] text-center", children: n })
|
|
5001
5001
|
] }) });
|
|
5002
5002
|
}
|
|
5003
|
-
function
|
|
5003
|
+
function Ys() {
|
|
5004
5004
|
return /* @__PURE__ */ a("div", { className: "flex justify-start px-5 py-2", children: /* @__PURE__ */ p("div", { className: "flex flex-col gap-2 w-3/4", children: [
|
|
5005
5005
|
/* @__PURE__ */ a("div", { className: "h-3 rounded-full animate-shimmer" }),
|
|
5006
5006
|
/* @__PURE__ */ a(
|
|
@@ -5012,7 +5012,7 @@ function Js() {
|
|
|
5012
5012
|
)
|
|
5013
5013
|
] }) });
|
|
5014
5014
|
}
|
|
5015
|
-
const
|
|
5015
|
+
const Xs = Lr(
|
|
5016
5016
|
function({
|
|
5017
5017
|
messages: e,
|
|
5018
5018
|
input: r,
|
|
@@ -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,
|
|
@@ -5069,7 +5069,7 @@ const Ys = Lr(
|
|
|
5069
5069
|
className: "flex-1 min-h-0 overflow-y-auto py-3 flex flex-col",
|
|
5070
5070
|
children: [
|
|
5071
5071
|
e.length === 0 && !s && b && /* @__PURE__ */ a(
|
|
5072
|
-
|
|
5072
|
+
Js,
|
|
5073
5073
|
{
|
|
5074
5074
|
isDragging: b.isDragging,
|
|
5075
5075
|
fileInputRef: b.fileInputRef,
|
|
@@ -5081,9 +5081,9 @@ 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
|
+
Gs,
|
|
5087
5087
|
{
|
|
5088
5088
|
message: g,
|
|
5089
5089
|
isFirstUserMessage: $,
|
|
@@ -5098,7 +5098,7 @@ const Ys = Lr(
|
|
|
5098
5098
|
g.id
|
|
5099
5099
|
);
|
|
5100
5100
|
}),
|
|
5101
|
-
s && /* @__PURE__ */ a(
|
|
5101
|
+
s && /* @__PURE__ */ a(Ys, {}),
|
|
5102
5102
|
/* @__PURE__ */ a(xs, { error: h, onRetry: u })
|
|
5103
5103
|
]
|
|
5104
5104
|
}
|
|
@@ -5114,18 +5114,18 @@ const Ys = Lr(
|
|
|
5114
5114
|
)
|
|
5115
5115
|
] });
|
|
5116
5116
|
}
|
|
5117
|
-
),
|
|
5117
|
+
), Zs = "purchase-order-chat-user-settings", ea = 25, Rt = it()(
|
|
5118
5118
|
Ht(
|
|
5119
5119
|
(t) => ({
|
|
5120
|
-
panelWidth:
|
|
5120
|
+
panelWidth: ea,
|
|
5121
5121
|
setPanelWidth: (e) => t({ panelWidth: e })
|
|
5122
5122
|
}),
|
|
5123
5123
|
{
|
|
5124
|
-
name:
|
|
5124
|
+
name: Zs
|
|
5125
5125
|
}
|
|
5126
5126
|
)
|
|
5127
5127
|
);
|
|
5128
|
-
function
|
|
5128
|
+
function ta() {
|
|
5129
5129
|
const t = Rt((m) => m.panelWidth), e = Rt((m) => m.setPanelWidth), [r, n] = R(
|
|
5130
5130
|
typeof window < "u" && window.innerWidth >= 1024
|
|
5131
5131
|
), i = D(null), s = D(!1), o = D(t);
|
|
@@ -5179,7 +5179,7 @@ function ea() {
|
|
|
5179
5179
|
handleBlur: u
|
|
5180
5180
|
};
|
|
5181
5181
|
}
|
|
5182
|
-
function
|
|
5182
|
+
function ra({ activeTab: t, onTabChange: e, hasUnread: r }) {
|
|
5183
5183
|
const n = r && t !== "chat";
|
|
5184
5184
|
return /* @__PURE__ */ p("div", { className: "flex border-b border-border-strong shrink-0", role: "tablist", children: [
|
|
5185
5185
|
/* @__PURE__ */ a(
|
|
@@ -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: $,
|
|
@@ -5263,23 +5263,23 @@ function Dt({
|
|
|
5263
5263
|
onMinimize: _,
|
|
5264
5264
|
className: j = ""
|
|
5265
5265
|
}) {
|
|
5266
|
-
const K =
|
|
5266
|
+
const K = ta(), [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]);
|
|
5279
5279
|
const T = B((U) => {
|
|
5280
5280
|
Pe(U), U === "chat" && me(!1);
|
|
5281
5281
|
}, []), P = /* @__PURE__ */ a(
|
|
5282
|
-
|
|
5282
|
+
Xs,
|
|
5283
5283
|
{
|
|
5284
5284
|
ref: d,
|
|
5285
5285
|
messages: t,
|
|
@@ -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(
|
|
@@ -5384,7 +5384,7 @@ function Dt({
|
|
|
5384
5384
|
...L,
|
|
5385
5385
|
children: [
|
|
5386
5386
|
/* @__PURE__ */ a(
|
|
5387
|
-
|
|
5387
|
+
ra,
|
|
5388
5388
|
{
|
|
5389
5389
|
activeTab: J,
|
|
5390
5390
|
onTabChange: T,
|
|
@@ -5406,7 +5406,7 @@ function Dt({
|
|
|
5406
5406
|
)
|
|
5407
5407
|
);
|
|
5408
5408
|
}
|
|
5409
|
-
function
|
|
5409
|
+
function na() {
|
|
5410
5410
|
const t = ft(), e = y((c) => c.ui.existingCart), r = y(
|
|
5411
5411
|
(c) => c.confirmClearExistingCart
|
|
5412
5412
|
), [n, i] = R(!1), s = oe(
|
|
@@ -5442,7 +5442,7 @@ function ra() {
|
|
|
5442
5442
|
)
|
|
5443
5443
|
] }) });
|
|
5444
5444
|
}
|
|
5445
|
-
function
|
|
5445
|
+
function sa({ message: t }) {
|
|
5446
5446
|
return /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full w-full bg-surface-secondary", children: /* @__PURE__ */ p("div", { className: "text-center max-w-md px-4", children: [
|
|
5447
5447
|
/* @__PURE__ */ a("p", { className: "text-lg text-text-secondary mb-2", children: "Something went wrong" }),
|
|
5448
5448
|
/* @__PURE__ */ a("p", { className: "text-sm text-text-tertiary mb-6", children: t || "An unexpected error occurred. Please refresh the page to try again." }),
|
|
@@ -5467,19 +5467,19 @@ function Ar() {
|
|
|
5467
5467
|
);
|
|
5468
5468
|
return oe(() => t !== "processing" ? null : e ? r === "idle" || r === "processing" ? "matching" : "building" : "reading", [t, e, r]);
|
|
5469
5469
|
}
|
|
5470
|
-
const
|
|
5470
|
+
const aa = [
|
|
5471
5471
|
{ label: "Upload", number: 1 },
|
|
5472
5472
|
{ label: "Match", number: 2 },
|
|
5473
5473
|
{ label: "Checkout", number: 3 }
|
|
5474
5474
|
];
|
|
5475
|
-
function
|
|
5476
|
-
return /* @__PURE__ */ a("div", { className: "flex items-center justify-center gap-0 p-4 md:py-1 md:px-0", children:
|
|
5475
|
+
function ia(t = {}) {
|
|
5476
|
+
return /* @__PURE__ */ a("div", { className: "flex items-center justify-center gap-0 p-4 md:py-1 md:px-0", children: aa.map((e, r) => /* @__PURE__ */ p("div", { className: "flex items-center gap-2", children: [
|
|
5477
5477
|
r > 0 && /* @__PURE__ */ a("div", { className: "w-6 md:w-10 h-px mx-2 md:mx-3 rounded-[1px] bg-border" }),
|
|
5478
5478
|
/* @__PURE__ */ a("div", { className: "flex items-center justify-center w-5 h-5 rounded-full shrink-0 bg-transparent border-[1.5px] border-border-strong text-text-quaternary", children: /* @__PURE__ */ a("span", { className: "text-xs font-medium", children: e.number }) }),
|
|
5479
5479
|
/* @__PURE__ */ a("span", { className: "text-s font-normal whitespace-nowrap text-text-quaternary", children: e.label })
|
|
5480
5480
|
] }, e.label)) });
|
|
5481
5481
|
}
|
|
5482
|
-
function
|
|
5482
|
+
function oa({
|
|
5483
5483
|
isDragging: t,
|
|
5484
5484
|
fileInputRef: e,
|
|
5485
5485
|
cameraInputRef: r,
|
|
@@ -5539,7 +5539,7 @@ function ia({
|
|
|
5539
5539
|
}
|
|
5540
5540
|
);
|
|
5541
5541
|
}
|
|
5542
|
-
function
|
|
5542
|
+
function ca({
|
|
5543
5543
|
isDragging: t,
|
|
5544
5544
|
fileInputRef: e,
|
|
5545
5545
|
acceptedExtensions: r,
|
|
@@ -5559,9 +5559,9 @@ function oa({
|
|
|
5559
5559
|
t && "ring-2 ring-border-focus border-border-focus bg-surface-tertiary shadow-upload-active"
|
|
5560
5560
|
),
|
|
5561
5561
|
children: [
|
|
5562
|
-
/* @__PURE__ */ a("div", { className: "upload-zone-steps mb-3 py-4 px-8 border-b border-solid border-border-strong", children: /* @__PURE__ */ a(
|
|
5562
|
+
/* @__PURE__ */ a("div", { className: "upload-zone-steps mb-3 py-4 px-8 border-b border-solid border-border-strong", children: /* @__PURE__ */ a(ia, {}) }),
|
|
5563
5563
|
/* @__PURE__ */ a(
|
|
5564
|
-
|
|
5564
|
+
oa,
|
|
5565
5565
|
{
|
|
5566
5566
|
isDragging: t,
|
|
5567
5567
|
fileInputRef: e,
|
|
@@ -5587,7 +5587,7 @@ function oa({
|
|
|
5587
5587
|
}
|
|
5588
5588
|
);
|
|
5589
5589
|
}
|
|
5590
|
-
function
|
|
5590
|
+
function la({
|
|
5591
5591
|
items: t,
|
|
5592
5592
|
orderId: e,
|
|
5593
5593
|
parsedContent: r,
|
|
@@ -5679,11 +5679,11 @@ function ca({
|
|
|
5679
5679
|
] })
|
|
5680
5680
|
] });
|
|
5681
5681
|
}
|
|
5682
|
-
const
|
|
5683
|
-
function
|
|
5684
|
-
return t <= 0 ? Lt : Math.max(Lt, Math.round(
|
|
5682
|
+
const da = 3e3, Lt = 200;
|
|
5683
|
+
function ua(t) {
|
|
5684
|
+
return t <= 0 ? Lt : Math.max(Lt, Math.round(da / t));
|
|
5685
5685
|
}
|
|
5686
|
-
function
|
|
5686
|
+
function pa() {
|
|
5687
5687
|
const t = y(
|
|
5688
5688
|
(o) => o.batchProcessing.toolCalls
|
|
5689
5689
|
), r = y(
|
|
@@ -5695,7 +5695,7 @@ function ua() {
|
|
|
5695
5695
|
}, 0), [i, s] = R(0);
|
|
5696
5696
|
return F(() => {
|
|
5697
5697
|
if (!r || n === 0 || i >= n) return;
|
|
5698
|
-
const o =
|
|
5698
|
+
const o = ua(n), c = setTimeout(() => {
|
|
5699
5699
|
s((l) => Math.min(l + 1, n));
|
|
5700
5700
|
}, o);
|
|
5701
5701
|
return () => clearTimeout(c);
|
|
@@ -5705,8 +5705,8 @@ function ua() {
|
|
|
5705
5705
|
isRevealing: n > 0 && i < n
|
|
5706
5706
|
};
|
|
5707
5707
|
}
|
|
5708
|
-
const
|
|
5709
|
-
function
|
|
5708
|
+
const ha = 1e3;
|
|
5709
|
+
function fa() {
|
|
5710
5710
|
const t = y(
|
|
5711
5711
|
(s) => s.batchProcessing.toolCalls
|
|
5712
5712
|
), e = y(
|
|
@@ -5717,7 +5717,7 @@ function ha() {
|
|
|
5717
5717
|
F(() => {
|
|
5718
5718
|
if (e >= t.length)
|
|
5719
5719
|
return;
|
|
5720
|
-
const s = setTimeout(r,
|
|
5720
|
+
const s = setTimeout(r, ha);
|
|
5721
5721
|
return () => clearTimeout(s);
|
|
5722
5722
|
}, [t.length, e, r]);
|
|
5723
5723
|
const n = t.slice(0, e);
|
|
@@ -5728,22 +5728,22 @@ function ha() {
|
|
|
5728
5728
|
};
|
|
5729
5729
|
}
|
|
5730
5730
|
const _t = ["reading", "matching", "building"];
|
|
5731
|
-
function
|
|
5731
|
+
function ma(t, e) {
|
|
5732
5732
|
if (!e) return "pending";
|
|
5733
5733
|
const r = _t.indexOf(e), n = _t.indexOf(t);
|
|
5734
5734
|
return n < r ? "complete" : n === r ? "active" : "pending";
|
|
5735
5735
|
}
|
|
5736
|
-
function
|
|
5736
|
+
function ga(t, e) {
|
|
5737
5737
|
return t.length >= 2 && e !== "submitted" && e !== "streaming";
|
|
5738
5738
|
}
|
|
5739
|
-
function
|
|
5739
|
+
function ya(t) {
|
|
5740
5740
|
if (t === void 0) return null;
|
|
5741
5741
|
const e = ht(t);
|
|
5742
5742
|
if (e === void 0) return null;
|
|
5743
5743
|
const r = Ze(e, "data.searchProductsBySku") ?? Ze(e, "data.searchProducts");
|
|
5744
5744
|
return Ze(r, "total", 0);
|
|
5745
5745
|
}
|
|
5746
|
-
const
|
|
5746
|
+
const xa = {
|
|
5747
5747
|
searchProductsBySku: (t, { resultCount: e }) => {
|
|
5748
5748
|
const r = t.sku ?? "";
|
|
5749
5749
|
return e === null ? `Looking up SKU ${r}` : /* @__PURE__ */ p(ve, { children: [
|
|
@@ -5772,14 +5772,14 @@ const ya = {
|
|
|
5772
5772
|
] });
|
|
5773
5773
|
}
|
|
5774
5774
|
};
|
|
5775
|
-
function
|
|
5776
|
-
const r =
|
|
5775
|
+
function ba(t, e) {
|
|
5776
|
+
const r = xa[t.toolName];
|
|
5777
5777
|
return r ? r(t.input, {
|
|
5778
5778
|
visibleToolCalls: e,
|
|
5779
|
-
resultCount:
|
|
5779
|
+
resultCount: ya(t.output)
|
|
5780
5780
|
}) : null;
|
|
5781
5781
|
}
|
|
5782
|
-
const
|
|
5782
|
+
const va = [
|
|
5783
5783
|
{ id: "reading", label: "Reading document..." },
|
|
5784
5784
|
{ id: "matching", label: "Matching products..." },
|
|
5785
5785
|
{ id: "building", label: "Building cart..." }
|
|
@@ -5797,14 +5797,14 @@ const ba = [
|
|
|
5797
5797
|
icon: "bg-surface border-2 border-success text-success"
|
|
5798
5798
|
}
|
|
5799
5799
|
};
|
|
5800
|
-
function
|
|
5800
|
+
function Ca({
|
|
5801
5801
|
currentStep: t
|
|
5802
5802
|
}) {
|
|
5803
|
-
const { currentToolCall: e, visibleToolCalls: r } =
|
|
5803
|
+
const { currentToolCall: e, visibleToolCalls: r } = fa(), { revealedCount: n, totalItems: i } = pa(), s = y(
|
|
5804
5804
|
(o) => o.parser.uploadedFileName
|
|
5805
5805
|
);
|
|
5806
|
-
return /* @__PURE__ */ a("div", { className: "flex flex-col gap-6 w-64", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-6", children:
|
|
5807
|
-
const c =
|
|
5806
|
+
return /* @__PURE__ */ a("div", { className: "flex flex-col gap-6 w-64", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-6", children: va.map((o) => {
|
|
5807
|
+
const c = ma(o.id, t), l = o.id === "reading" && (c === "active" || c === "complete") && s ? s : null, d = o.id === "matching" && c === "active" && e ? ba(e, r) : null, h = o.id === "building" && c === "active" && i > 0 ? n >= i ? `Added ${i} item${i !== 1 ? "s" : ""}` : `Adding item ${n + 1} of ${i}...` : null;
|
|
5808
5808
|
return /* @__PURE__ */ p(
|
|
5809
5809
|
"div",
|
|
5810
5810
|
{
|
|
@@ -5855,7 +5855,7 @@ function va({
|
|
|
5855
5855
|
);
|
|
5856
5856
|
}) }) });
|
|
5857
5857
|
}
|
|
5858
|
-
function
|
|
5858
|
+
function Ia({
|
|
5859
5859
|
cartItems: t,
|
|
5860
5860
|
isUploading: e = !1
|
|
5861
5861
|
}) {
|
|
@@ -5863,9 +5863,9 @@ function Ca({
|
|
|
5863
5863
|
(s) => s.parser.parsedContent
|
|
5864
5864
|
);
|
|
5865
5865
|
return /* @__PURE__ */ a("div", { className: "animate-fade-in-scale flex flex-col w-full max-w-[900px] gap-10 bg-surface rounded-2xl p-10 max-md:p-6 border border-border-strong border-solid", children: /* @__PURE__ */ p("div", { className: "flex w-full justify-center gap-32 max-md:flex-col max-md:gap-8", children: [
|
|
5866
|
-
/* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center", children: /* @__PURE__ */ a(
|
|
5866
|
+
/* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center", children: /* @__PURE__ */ a(Ca, { currentStep: r }) }),
|
|
5867
5867
|
/* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center min-w-80", children: /* @__PURE__ */ a(
|
|
5868
|
-
|
|
5868
|
+
la,
|
|
5869
5869
|
{
|
|
5870
5870
|
items: t,
|
|
5871
5871
|
orderId: n,
|
|
@@ -5876,7 +5876,7 @@ function Ca({
|
|
|
5876
5876
|
) })
|
|
5877
5877
|
] }) });
|
|
5878
5878
|
}
|
|
5879
|
-
function
|
|
5879
|
+
function wa({
|
|
5880
5880
|
onFileUpload: t,
|
|
5881
5881
|
onSkip: e,
|
|
5882
5882
|
onClearError: r,
|
|
@@ -5895,8 +5895,8 @@ function Ia({
|
|
|
5895
5895
|
{
|
|
5896
5896
|
className: `upload-step flex flex-col w-full flex-1 min-h-0 ${l.isDragging ? "upload-step-dragging" : ""} ${c ? "upload-step-processing" : ""}`,
|
|
5897
5897
|
...l.dragProps,
|
|
5898
|
-
children: /* @__PURE__ */ a("div", { className: "upload-step-content animate-fade-in-up flex-1 flex items-center justify-center min-h-0 relative", children: c ? /* @__PURE__ */ a(
|
|
5899
|
-
|
|
5898
|
+
children: /* @__PURE__ */ a("div", { className: "upload-step-content animate-fade-in-up flex-1 flex items-center justify-center min-h-0 relative", children: c ? /* @__PURE__ */ a(Ia, { cartItems: n, isUploading: i }) : /* @__PURE__ */ a(
|
|
5899
|
+
ca,
|
|
5900
5900
|
{
|
|
5901
5901
|
isDragging: l.isDragging,
|
|
5902
5902
|
fileInputRef: l.fileInputRef,
|
|
@@ -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,
|
|
@@ -5932,7 +5932,7 @@ function qt(t, e) {
|
|
|
5932
5932
|
function $r(t, e) {
|
|
5933
5933
|
return t !== void 0 && Math.abs(t - e) > 0.01;
|
|
5934
5934
|
}
|
|
5935
|
-
function
|
|
5935
|
+
function Sa(t, e) {
|
|
5936
5936
|
const r = [...t];
|
|
5937
5937
|
for (const n of e) {
|
|
5938
5938
|
const i = r.findIndex(
|
|
@@ -5942,7 +5942,7 @@ function wa(t, e) {
|
|
|
5942
5942
|
}
|
|
5943
5943
|
return r;
|
|
5944
5944
|
}
|
|
5945
|
-
function
|
|
5945
|
+
function Na(t, e) {
|
|
5946
5946
|
const r = [], n = [];
|
|
5947
5947
|
for (const i of e) {
|
|
5948
5948
|
const s = t.find(
|
|
@@ -5957,7 +5957,7 @@ function Sa(t, e) {
|
|
|
5957
5957
|
}
|
|
5958
5958
|
return { toAdd: r, toUpdate: n };
|
|
5959
5959
|
}
|
|
5960
|
-
function
|
|
5960
|
+
function Ea(t, e) {
|
|
5961
5961
|
const r = [];
|
|
5962
5962
|
for (const n of t.lineItems.physicalItems) {
|
|
5963
5963
|
const i = e.find(
|
|
@@ -5986,14 +5986,14 @@ function Ke(t) {
|
|
|
5986
5986
|
function Je(t) {
|
|
5987
5987
|
return t.toLowerCase();
|
|
5988
5988
|
}
|
|
5989
|
-
function
|
|
5989
|
+
function ka(t, e) {
|
|
5990
5990
|
return t.filter(
|
|
5991
5991
|
(r) => !e.some(
|
|
5992
5992
|
(n) => r.productSku && n.sku && Ke(r.productSku) === Ke(n.sku) || r.productName && n.name && Je(r.productName) === Je(n.name)
|
|
5993
5993
|
)
|
|
5994
5994
|
);
|
|
5995
5995
|
}
|
|
5996
|
-
function
|
|
5996
|
+
function Pa(t) {
|
|
5997
5997
|
const { client: e, onError: r } = t, n = D(e), i = D(r);
|
|
5998
5998
|
i.current = r;
|
|
5999
5999
|
const s = y((f) => f.bcSession.bcCart), o = y((f) => f.bcSession.checkout), c = y(
|
|
@@ -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,19 +6240,19 @@ function ka(t) {
|
|
|
6231
6240
|
return { cart: s, cartItems: [], errors: [] };
|
|
6232
6241
|
I(!0);
|
|
6233
6242
|
try {
|
|
6234
|
-
const
|
|
6243
|
+
const N = Sa(z, f), T = await n.current.getCart();
|
|
6235
6244
|
let P = null;
|
|
6236
6245
|
const M = [];
|
|
6237
6246
|
if (T) {
|
|
6238
|
-
const { toAdd: G, toUpdate: ce } =
|
|
6247
|
+
const { toAdd: G, toUpdate: ce } = Na(
|
|
6239
6248
|
T.lineItems.physicalItems,
|
|
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,15 +6312,15 @@ 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
|
-
const { cartItems: U } =
|
|
6320
|
+
const { cartItems: U } = Ea(
|
|
6312
6321
|
P,
|
|
6313
|
-
|
|
6314
|
-
), je = y.getState().cartifact.itemWarnings, Oe =
|
|
6322
|
+
N
|
|
6323
|
+
), je = y.getState().cartifact.itemWarnings, Oe = ka(
|
|
6315
6324
|
je,
|
|
6316
6325
|
U
|
|
6317
6326
|
);
|
|
@@ -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,13 +6602,13 @@ 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
|
|
6600
6609
|
};
|
|
6601
6610
|
}
|
|
6602
|
-
function
|
|
6611
|
+
function Ta({
|
|
6603
6612
|
bcCart: t,
|
|
6604
6613
|
cartItems: e,
|
|
6605
6614
|
onCheckoutInitiated: r,
|
|
@@ -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]
|
|
@@ -6679,14 +6688,14 @@ const st = /* @__PURE__ */ new Set([
|
|
|
6679
6688
|
ut,
|
|
6680
6689
|
Ye,
|
|
6681
6690
|
pt
|
|
6682
|
-
]),
|
|
6683
|
-
function
|
|
6691
|
+
]), Aa = "did not produce any output";
|
|
6692
|
+
function $a(t) {
|
|
6684
6693
|
const e = t.filter((n) => st.has(n.toolName)).map((n) => n.toolName);
|
|
6685
6694
|
return e.length === 0 ? "" : `
|
|
6686
6695
|
|
|
6687
6696
|
Tools called: ${[...new Set(e)].join(", ")}`;
|
|
6688
6697
|
}
|
|
6689
|
-
async function
|
|
6698
|
+
async function Ba(t, e, r, n, i, s) {
|
|
6690
6699
|
const o = [], c = [], l = [], d = [];
|
|
6691
6700
|
let h = [
|
|
6692
6701
|
{
|
|
@@ -6698,15 +6707,15 @@ 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 Us(
|
|
6702
6711
|
t,
|
|
6703
6712
|
e,
|
|
6704
6713
|
r,
|
|
6705
6714
|
h
|
|
6706
|
-
), g = await
|
|
6715
|
+
), g = await _s(k, {
|
|
6707
6716
|
onToolCall: s?.onToolCall
|
|
6708
6717
|
});
|
|
6709
|
-
if (c.push(...g.textParts), o.push(...g.toolCalls), g.finalMessage && l.push(g.finalMessage), g.errorMessage?.includes(
|
|
6718
|
+
if (c.push(...g.textParts), o.push(...g.toolCalls), g.finalMessage && l.push(g.finalMessage), g.errorMessage?.includes(Aa)) {
|
|
6710
6719
|
s?.logger?.debug(
|
|
6711
6720
|
`Batch ${i}: Exiting loop - no output error`
|
|
6712
6721
|
);
|
|
@@ -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 =
|
|
6778
|
-
(
|
|
6779
|
-
).reduce((
|
|
6786
|
+
`) : c.join(""), b = $a(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,
|
|
@@ -6795,7 +6804,7 @@ async function $a(t, e, r, n, i, s) {
|
|
|
6795
6804
|
pendingClientToolCalls: d
|
|
6796
6805
|
};
|
|
6797
6806
|
}
|
|
6798
|
-
async function
|
|
6807
|
+
async function Ma(t, e, r, n) {
|
|
6799
6808
|
if (r.length === 0)
|
|
6800
6809
|
return { results: [], hasErrors: !1 };
|
|
6801
6810
|
const s = (await Promise.allSettled(
|
|
@@ -6822,7 +6831,7 @@ async function Ba(t, e, r, n) {
|
|
|
6822
6831
|
error: "Failed to create thread"
|
|
6823
6832
|
};
|
|
6824
6833
|
try {
|
|
6825
|
-
const u = await
|
|
6834
|
+
const u = await Ba(
|
|
6826
6835
|
t,
|
|
6827
6836
|
e,
|
|
6828
6837
|
h,
|
|
@@ -6847,7 +6856,7 @@ async function Ba(t, e, r, n) {
|
|
|
6847
6856
|
), c = o.some((l) => l.error !== void 0);
|
|
6848
6857
|
return { results: o, hasErrors: c };
|
|
6849
6858
|
}
|
|
6850
|
-
function
|
|
6859
|
+
function Fa(t) {
|
|
6851
6860
|
const e = [];
|
|
6852
6861
|
let r = null;
|
|
6853
6862
|
const n = [];
|
|
@@ -6868,7 +6877,7 @@ function Ma(t) {
|
|
|
6868
6877
|
}
|
|
6869
6878
|
return { addToCartItems: e, setPoMetadataArgs: r, processingFailures: n };
|
|
6870
6879
|
}
|
|
6871
|
-
function
|
|
6880
|
+
function Oa(t) {
|
|
6872
6881
|
if (t.length === 0)
|
|
6873
6882
|
return "";
|
|
6874
6883
|
const e = [
|
|
@@ -6884,7 +6893,7 @@ function Fa(t) {
|
|
|
6884
6893
|
return e.join(`
|
|
6885
6894
|
`);
|
|
6886
6895
|
}
|
|
6887
|
-
function
|
|
6896
|
+
function Ra(t) {
|
|
6888
6897
|
if (t.length === 0) return "";
|
|
6889
6898
|
const e = ["---", "## Failed Tool Calls", ""];
|
|
6890
6899
|
for (const r of t) {
|
|
@@ -6900,8 +6909,8 @@ function Oa(t) {
|
|
|
6900
6909
|
return e.join(`
|
|
6901
6910
|
`);
|
|
6902
6911
|
}
|
|
6903
|
-
async function
|
|
6904
|
-
const r =
|
|
6912
|
+
async function Da(t, e) {
|
|
6913
|
+
const r = Fa(t);
|
|
6905
6914
|
if (r.setPoMetadataArgs) {
|
|
6906
6915
|
const s = r.setPoMetadataArgs;
|
|
6907
6916
|
y.getState().applyPoMetadata(s.poMetadata);
|
|
@@ -6911,20 +6920,20 @@ async function Ra(t, e) {
|
|
|
6911
6920
|
const { errors: s } = await e.addToCart(r.addToCartItems);
|
|
6912
6921
|
n = s, s.length > 0 && console.error("Failed to add some items to cart:", s);
|
|
6913
6922
|
}
|
|
6914
|
-
const i =
|
|
6923
|
+
const i = Oa(
|
|
6915
6924
|
r.processingFailures
|
|
6916
6925
|
);
|
|
6917
6926
|
if (n.length > 0) {
|
|
6918
|
-
const s =
|
|
6927
|
+
const s = Ra(n);
|
|
6919
6928
|
return i ? `${i}
|
|
6920
6929
|
${s}` : s;
|
|
6921
6930
|
}
|
|
6922
6931
|
return i;
|
|
6923
6932
|
}
|
|
6924
|
-
async function
|
|
6933
|
+
async function La(t, e) {
|
|
6925
6934
|
if (e.length === 0)
|
|
6926
6935
|
return { results: [], processingFailuresString: "", hasErrors: !1 };
|
|
6927
|
-
const r = await
|
|
6936
|
+
const r = await Ma(
|
|
6928
6937
|
t.takeshapeConfig,
|
|
6929
6938
|
t.agentName,
|
|
6930
6939
|
e,
|
|
@@ -6938,7 +6947,7 @@ async function Da(t, e) {
|
|
|
6938
6947
|
}
|
|
6939
6948
|
);
|
|
6940
6949
|
let n = "";
|
|
6941
|
-
return t.bcCart && (n = await
|
|
6950
|
+
return t.bcCart && (n = await Da(
|
|
6942
6951
|
r.results,
|
|
6943
6952
|
t.bcCart
|
|
6944
6953
|
)), {
|
|
@@ -6947,7 +6956,7 @@ async function Da(t, e) {
|
|
|
6947
6956
|
hasErrors: r.hasErrors
|
|
6948
6957
|
};
|
|
6949
6958
|
}
|
|
6950
|
-
function
|
|
6959
|
+
function _a(t) {
|
|
6951
6960
|
const { bcCart: e } = t, r = y(
|
|
6952
6961
|
(d) => d.takeshapeConfig
|
|
6953
6962
|
), n = y(
|
|
@@ -6971,7 +6980,7 @@ function La(t) {
|
|
|
6971
6980
|
bcCart: e
|
|
6972
6981
|
};
|
|
6973
6982
|
try {
|
|
6974
|
-
const u = await
|
|
6983
|
+
const u = await La(h, d);
|
|
6975
6984
|
if (s(
|
|
6976
6985
|
u.results,
|
|
6977
6986
|
u.processingFailuresString
|
|
@@ -7001,7 +7010,7 @@ function La(t) {
|
|
|
7001
7010
|
reset: o
|
|
7002
7011
|
};
|
|
7003
7012
|
}
|
|
7004
|
-
function
|
|
7013
|
+
function Ua({
|
|
7005
7014
|
appState: t,
|
|
7006
7015
|
setAppState: e,
|
|
7007
7016
|
parser: r,
|
|
@@ -7013,7 +7022,7 @@ function _a({
|
|
|
7013
7022
|
(u) => u.parser.hasProcessedDocument
|
|
7014
7023
|
), l = y(
|
|
7015
7024
|
(u) => u.setHasProcessedDocument
|
|
7016
|
-
), { processBatches: d } =
|
|
7025
|
+
), { processBatches: d } = _a({ bcCart: s });
|
|
7017
7026
|
return F(() => {
|
|
7018
7027
|
t === "processing" && r.parserStatus !== "streaming" && r.parserStatus !== "submitted" && r.parsedContent && r.parserMessages.length > 0 && !o.current && (o.current = !0, l(!0), d(r.parsedContent));
|
|
7019
7028
|
}, [
|
|
@@ -7039,30 +7048,30 @@ function _a({
|
|
|
7039
7048
|
}
|
|
7040
7049
|
};
|
|
7041
7050
|
}
|
|
7042
|
-
const
|
|
7043
|
-
function qa(t) {
|
|
7044
|
-
return t.split(Ua).map((e) => e.trim()).filter(Boolean);
|
|
7045
|
-
}
|
|
7051
|
+
const qa = "<!-- BATCH -->";
|
|
7046
7052
|
function ja(t) {
|
|
7053
|
+
return t.split(qa).map((e) => e.trim()).filter(Boolean);
|
|
7054
|
+
}
|
|
7055
|
+
function Wa(t) {
|
|
7047
7056
|
return new Promise((e, r) => {
|
|
7048
7057
|
const n = new FileReader();
|
|
7049
7058
|
n.onload = () => e(n.result), n.onerror = () => r(new Error("Failed to read file")), n.readAsText(t);
|
|
7050
7059
|
});
|
|
7051
7060
|
}
|
|
7052
|
-
function
|
|
7061
|
+
function Va(t) {
|
|
7053
7062
|
return new Promise((e, r) => {
|
|
7054
7063
|
const n = new FileReader();
|
|
7055
7064
|
n.onload = () => e(n.result), n.onerror = () => r(new Error("Failed to read file")), n.readAsDataURL(t);
|
|
7056
7065
|
});
|
|
7057
7066
|
}
|
|
7058
|
-
const
|
|
7067
|
+
const za = /* @__PURE__ */ new Set([
|
|
7059
7068
|
"application/vnd.ms-excel",
|
|
7060
7069
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
7061
7070
|
]);
|
|
7062
7071
|
function jt(t) {
|
|
7063
|
-
return
|
|
7072
|
+
return za.has(t);
|
|
7064
7073
|
}
|
|
7065
|
-
async function
|
|
7074
|
+
async function Qa(t) {
|
|
7066
7075
|
const e = await import("xlsx"), r = await t.arrayBuffer(), n = e.read(r, { type: "array" });
|
|
7067
7076
|
if (n.SheetNames.length === 0)
|
|
7068
7077
|
throw new Error("Workbook contains no sheets");
|
|
@@ -7074,27 +7083,27 @@ async function za(t) {
|
|
|
7074
7083
|
const s = e.utils.json_to_sheet(i);
|
|
7075
7084
|
return e.utils.sheet_to_csv(s);
|
|
7076
7085
|
}
|
|
7077
|
-
const
|
|
7078
|
-
function
|
|
7086
|
+
const Ha = "%PDF-", Ga = "%%EOF", Ka = 256;
|
|
7087
|
+
function Ja(t) {
|
|
7079
7088
|
return new Promise((e, r) => {
|
|
7080
7089
|
const n = new FileReader();
|
|
7081
7090
|
n.onload = () => e(n.result), n.onerror = () => r(n.error), n.readAsArrayBuffer(t);
|
|
7082
7091
|
});
|
|
7083
7092
|
}
|
|
7084
|
-
async function
|
|
7085
|
-
if (t.size <
|
|
7093
|
+
async function Ya(t) {
|
|
7094
|
+
if (t.size < Ka) return { valid: !1, reason: "invalid" };
|
|
7086
7095
|
let e;
|
|
7087
7096
|
try {
|
|
7088
|
-
e = new Uint8Array(await
|
|
7097
|
+
e = new Uint8Array(await Ja(t));
|
|
7089
7098
|
} catch {
|
|
7090
7099
|
return { valid: !1, reason: "invalid" };
|
|
7091
7100
|
}
|
|
7092
|
-
if (!String.fromCharCode(...e.slice(0, 5)).startsWith(
|
|
7101
|
+
if (!String.fromCharCode(...e.slice(0, 5)).startsWith(Ha))
|
|
7093
7102
|
return { valid: !1, reason: "invalid" };
|
|
7094
7103
|
const n = Math.min(1024, e.length);
|
|
7095
7104
|
if (!String.fromCharCode(
|
|
7096
7105
|
...e.slice(e.length - n)
|
|
7097
|
-
).includes(
|
|
7106
|
+
).includes(Ga))
|
|
7098
7107
|
return { valid: !1, reason: "invalid" };
|
|
7099
7108
|
const s = Math.max(0, e.length - 8192), o = new TextDecoder().decode(e.slice(s)), c = o.lastIndexOf("<<"), l = o.lastIndexOf(">>");
|
|
7100
7109
|
if (c !== -1 && l !== -1 && c < l && o.substring(c, l).includes("/Encrypt"))
|
|
@@ -7118,7 +7127,7 @@ async function Ja(t) {
|
|
|
7118
7127
|
}
|
|
7119
7128
|
return { valid: !0 };
|
|
7120
7129
|
}
|
|
7121
|
-
const
|
|
7130
|
+
const Xa = /* @__PURE__ */ new Set([
|
|
7122
7131
|
"text/csv",
|
|
7123
7132
|
"text/plain",
|
|
7124
7133
|
"application/json"
|
|
@@ -7133,7 +7142,7 @@ ${e}`
|
|
|
7133
7142
|
}
|
|
7134
7143
|
];
|
|
7135
7144
|
}
|
|
7136
|
-
function
|
|
7145
|
+
function Za(t, e, r) {
|
|
7137
7146
|
return [
|
|
7138
7147
|
{ type: "text", text: Br },
|
|
7139
7148
|
{
|
|
@@ -7144,7 +7153,7 @@ function Xa(t, e, r) {
|
|
|
7144
7153
|
}
|
|
7145
7154
|
];
|
|
7146
7155
|
}
|
|
7147
|
-
function
|
|
7156
|
+
function ei({
|
|
7148
7157
|
createParserThread: t,
|
|
7149
7158
|
sendParserMessage: e
|
|
7150
7159
|
}) {
|
|
@@ -7152,7 +7161,7 @@ function Za({
|
|
|
7152
7161
|
async (c) => {
|
|
7153
7162
|
const l = y.getState();
|
|
7154
7163
|
if (l.setParsedContent(null), n(!0), l.setUploadedFileName(c.name), s(null), c.type === "application/pdf") {
|
|
7155
|
-
const d = await
|
|
7164
|
+
const d = await Ya(c);
|
|
7156
7165
|
if (!d.valid)
|
|
7157
7166
|
return s(
|
|
7158
7167
|
d.reason === "password-protected" ? "The PDF appears to be password protected." : "The file does not appear to be a valid PDF."
|
|
@@ -7161,15 +7170,15 @@ function Za({
|
|
|
7161
7170
|
await t();
|
|
7162
7171
|
try {
|
|
7163
7172
|
if (jt(c.type)) {
|
|
7164
|
-
const d = await
|
|
7173
|
+
const d = await Qa(c);
|
|
7165
7174
|
e({ parts: Wt(c.name, d) });
|
|
7166
|
-
} else if (
|
|
7167
|
-
const d = await
|
|
7175
|
+
} else if (Xa.has(c.type)) {
|
|
7176
|
+
const d = await Wa(c);
|
|
7168
7177
|
e({ parts: Wt(c.name, d) });
|
|
7169
7178
|
} else {
|
|
7170
|
-
const d = await
|
|
7179
|
+
const d = await Va(c);
|
|
7171
7180
|
e({
|
|
7172
|
-
parts:
|
|
7181
|
+
parts: Za(d, c.type, c.name)
|
|
7173
7182
|
});
|
|
7174
7183
|
}
|
|
7175
7184
|
} catch (d) {
|
|
@@ -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(() => {
|
|
@@ -7234,7 +7243,7 @@ function Mr(t) {
|
|
|
7234
7243
|
createThread: m
|
|
7235
7244
|
};
|
|
7236
7245
|
}
|
|
7237
|
-
function
|
|
7246
|
+
function ti() {
|
|
7238
7247
|
const { sseOrigin: t, projectId: e, apiKey: r } = y(
|
|
7239
7248
|
(g) => g.takeshapeConfig
|
|
7240
7249
|
), n = y(
|
|
@@ -7291,8 +7300,8 @@ function ei() {
|
|
|
7291
7300
|
setIsUploadingFile: b,
|
|
7292
7301
|
parserError: x,
|
|
7293
7302
|
setParserError: v,
|
|
7294
|
-
handleFileUpload:
|
|
7295
|
-
} =
|
|
7303
|
+
handleFileUpload: E
|
|
7304
|
+
} = ei({
|
|
7296
7305
|
createParserThread: s,
|
|
7297
7306
|
sendParserMessage: h
|
|
7298
7307
|
}), I = B(
|
|
@@ -7304,14 +7313,14 @@ 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) {
|
|
7312
7321
|
const g = d[d.length - 1];
|
|
7313
7322
|
if (g?.role === "assistant" && Array.isArray(g.parts)) {
|
|
7314
|
-
const A = g.parts.filter((O) => O.type === "text").map((O) => O.text).filter(Boolean), $ =
|
|
7323
|
+
const A = g.parts.filter((O) => O.type === "text").map((O) => O.text).filter(Boolean), $ = ja(A.join(""));
|
|
7315
7324
|
y.getState().setParsedContent($), $ && b(!1);
|
|
7316
7325
|
}
|
|
7317
7326
|
}
|
|
@@ -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,10 +7343,10 @@ function ei() {
|
|
|
7334
7343
|
parserMessages: d,
|
|
7335
7344
|
handleFileUpload: I,
|
|
7336
7345
|
handleClearError: w,
|
|
7337
|
-
reset:
|
|
7346
|
+
reset: k
|
|
7338
7347
|
};
|
|
7339
7348
|
}
|
|
7340
|
-
class
|
|
7349
|
+
class ri {
|
|
7341
7350
|
b2bToken = null;
|
|
7342
7351
|
companyId = null;
|
|
7343
7352
|
channelId;
|
|
@@ -7483,12 +7492,12 @@ class ti {
|
|
|
7483
7492
|
}
|
|
7484
7493
|
}
|
|
7485
7494
|
}
|
|
7486
|
-
function
|
|
7495
|
+
function ni(t) {
|
|
7487
7496
|
return console.debug(
|
|
7488
7497
|
`[createB2BClient] Initializing B2B client for channelId=${t.channelId}`
|
|
7489
|
-
), new
|
|
7498
|
+
), new ri(t);
|
|
7490
7499
|
}
|
|
7491
|
-
async function
|
|
7500
|
+
async function Ki(t) {
|
|
7492
7501
|
let e = null;
|
|
7493
7502
|
try {
|
|
7494
7503
|
const r = await Ee(
|
|
@@ -7537,7 +7546,7 @@ async function Gi(t) {
|
|
|
7537
7546
|
return null;
|
|
7538
7547
|
}
|
|
7539
7548
|
}
|
|
7540
|
-
async function
|
|
7549
|
+
async function si(t, e) {
|
|
7541
7550
|
const { setToolCallError: r } = y.getState(), n = t.input;
|
|
7542
7551
|
let i = "No items provided to add to cart.";
|
|
7543
7552
|
if (n.value && n.value.length > 0) {
|
|
@@ -7554,7 +7563,7 @@ async function ni(t, e) {
|
|
|
7554
7563
|
output: i
|
|
7555
7564
|
};
|
|
7556
7565
|
}
|
|
7557
|
-
async function
|
|
7566
|
+
async function ai(t, e) {
|
|
7558
7567
|
const { setToolCallError: r } = y.getState();
|
|
7559
7568
|
let n = "Cart cleared successfully.";
|
|
7560
7569
|
try {
|
|
@@ -7569,7 +7578,7 @@ async function si(t, e) {
|
|
|
7569
7578
|
output: n
|
|
7570
7579
|
};
|
|
7571
7580
|
}
|
|
7572
|
-
function
|
|
7581
|
+
function ii(t, e) {
|
|
7573
7582
|
const r = {
|
|
7574
7583
|
items: e.cartItems.map((n) => ({
|
|
7575
7584
|
productEntityId: n.productEntityId,
|
|
@@ -7589,7 +7598,7 @@ function ai(t, e) {
|
|
|
7589
7598
|
output: JSON.stringify(r)
|
|
7590
7599
|
};
|
|
7591
7600
|
}
|
|
7592
|
-
function
|
|
7601
|
+
function oi(t) {
|
|
7593
7602
|
const { parser: e } = y.getState(), r = {
|
|
7594
7603
|
uploadedFileName: e.uploadedFileName,
|
|
7595
7604
|
parsedContent: e.parsedContent
|
|
@@ -7600,7 +7609,7 @@ function ii(t) {
|
|
|
7600
7609
|
output: JSON.stringify(r)
|
|
7601
7610
|
};
|
|
7602
7611
|
}
|
|
7603
|
-
async function
|
|
7612
|
+
async function ci(t, e) {
|
|
7604
7613
|
const { setToolCallError: r } = y.getState(), n = t.input;
|
|
7605
7614
|
let i = "Item removed from cart successfully.";
|
|
7606
7615
|
try {
|
|
@@ -7625,7 +7634,7 @@ async function oi(t, e) {
|
|
|
7625
7634
|
output: i
|
|
7626
7635
|
};
|
|
7627
7636
|
}
|
|
7628
|
-
function
|
|
7637
|
+
function li(t) {
|
|
7629
7638
|
const {
|
|
7630
7639
|
cartifact: { itemWarnings: e },
|
|
7631
7640
|
setItemWarnings: r
|
|
@@ -7638,7 +7647,7 @@ function ci(t) {
|
|
|
7638
7647
|
output: "Item warnings removed successfully."
|
|
7639
7648
|
};
|
|
7640
7649
|
}
|
|
7641
|
-
function
|
|
7650
|
+
function di(t) {
|
|
7642
7651
|
const { setItemWarnings: e } = y.getState(), r = t.input;
|
|
7643
7652
|
return r.itemWarnings && e(r.itemWarnings), {
|
|
7644
7653
|
tool: vr,
|
|
@@ -7646,7 +7655,7 @@ function li(t) {
|
|
|
7646
7655
|
output: "Item warnings set successfully."
|
|
7647
7656
|
};
|
|
7648
7657
|
}
|
|
7649
|
-
function
|
|
7658
|
+
function ui(t) {
|
|
7650
7659
|
const e = t.input;
|
|
7651
7660
|
return y.getState().applyPoMetadata(e.poMetadata), {
|
|
7652
7661
|
tool: Ye,
|
|
@@ -7654,7 +7663,7 @@ function di(t) {
|
|
|
7654
7663
|
output: "PO metadata set successfully."
|
|
7655
7664
|
};
|
|
7656
7665
|
}
|
|
7657
|
-
async function
|
|
7666
|
+
async function pi(t, e) {
|
|
7658
7667
|
const { setToolCallError: r, setPoItemPrice: n } = y.getState(), i = t.input;
|
|
7659
7668
|
let s = 0;
|
|
7660
7669
|
try {
|
|
@@ -7687,21 +7696,21 @@ async function ui(t, e) {
|
|
|
7687
7696
|
};
|
|
7688
7697
|
}
|
|
7689
7698
|
const Fr = {
|
|
7690
|
-
addToCart:
|
|
7691
|
-
updateCart:
|
|
7692
|
-
removeFromCart:
|
|
7693
|
-
clearCart:
|
|
7694
|
-
getCart:
|
|
7695
|
-
getPurchaseOrderData:
|
|
7696
|
-
setPoMetadata:
|
|
7697
|
-
setItemWarnings:
|
|
7698
|
-
removeItemWarnings:
|
|
7699
|
-
},
|
|
7700
|
-
async function
|
|
7699
|
+
addToCart: si,
|
|
7700
|
+
updateCart: pi,
|
|
7701
|
+
removeFromCart: ci,
|
|
7702
|
+
clearCart: ai,
|
|
7703
|
+
getCart: ii,
|
|
7704
|
+
getPurchaseOrderData: oi,
|
|
7705
|
+
setPoMetadata: ui,
|
|
7706
|
+
setItemWarnings: di,
|
|
7707
|
+
removeItemWarnings: li
|
|
7708
|
+
}, hi = new Set(Object.keys(Fr));
|
|
7709
|
+
async function fi(t, e) {
|
|
7701
7710
|
const r = Fr[t.toolName];
|
|
7702
7711
|
return r?.(t, e);
|
|
7703
7712
|
}
|
|
7704
|
-
function
|
|
7713
|
+
function mi(t, e) {
|
|
7705
7714
|
const n = [...t].reverse().find((i) => i.role === "assistant")?.parts?.find(
|
|
7706
7715
|
(i) => "toolCallId" in i && i.toolCallId === e && "state" in i && (i.state === "output-available" || i.state === "output-error")
|
|
7707
7716
|
);
|
|
@@ -7711,12 +7720,12 @@ function fi(t, e) {
|
|
|
7711
7720
|
errorText: "errorText" in n ? String(n.errorText) : void 0
|
|
7712
7721
|
};
|
|
7713
7722
|
}
|
|
7714
|
-
async function
|
|
7723
|
+
async function gi(t, e, r) {
|
|
7715
7724
|
const n = [], i = [];
|
|
7716
7725
|
for (const s of t) {
|
|
7717
|
-
if (!
|
|
7726
|
+
if (!hi.has(s.toolName))
|
|
7718
7727
|
continue;
|
|
7719
|
-
const o =
|
|
7728
|
+
const o = mi(
|
|
7720
7729
|
e,
|
|
7721
7730
|
s.toolCallId
|
|
7722
7731
|
);
|
|
@@ -7735,7 +7744,7 @@ async function mi(t, e, r) {
|
|
|
7735
7744
|
continue;
|
|
7736
7745
|
}
|
|
7737
7746
|
try {
|
|
7738
|
-
const c = await
|
|
7747
|
+
const c = await fi(s, r);
|
|
7739
7748
|
c && (n.push(c.toolCallId), i.push(c));
|
|
7740
7749
|
} catch (c) {
|
|
7741
7750
|
console.error("[handleToolCall] Error:", { toolCall: s, error: c });
|
|
@@ -7745,7 +7754,7 @@ async function mi(t, e, r) {
|
|
|
7745
7754
|
}
|
|
7746
7755
|
return { completedToolCallIds: n, outputs: i };
|
|
7747
7756
|
}
|
|
7748
|
-
function
|
|
7757
|
+
function yi() {
|
|
7749
7758
|
try {
|
|
7750
7759
|
const t = localStorage.getItem(ct);
|
|
7751
7760
|
if (!t)
|
|
@@ -7801,7 +7810,7 @@ function ze() {
|
|
|
7801
7810
|
console.error("Failed to clear persisted session:", t);
|
|
7802
7811
|
}
|
|
7803
7812
|
}
|
|
7804
|
-
function
|
|
7813
|
+
function xi(t, e) {
|
|
7805
7814
|
return !t && !e ? { valid: !0 } : t && !e ? {
|
|
7806
7815
|
valid: !1,
|
|
7807
7816
|
error: "Your previous session was reset because you signed out."
|
|
@@ -7813,20 +7822,20 @@ function yi(t, e) {
|
|
|
7813
7822
|
error: "Your previous session was reset because you signed in as a different user."
|
|
7814
7823
|
} : { valid: !0 };
|
|
7815
7824
|
}
|
|
7816
|
-
async function
|
|
7825
|
+
async function bi(t, e) {
|
|
7817
7826
|
return { valid: !0 };
|
|
7818
7827
|
}
|
|
7819
|
-
function
|
|
7828
|
+
function vi(t) {
|
|
7820
7829
|
return t ? { valid: !0 } : {
|
|
7821
7830
|
valid: !1,
|
|
7822
7831
|
error: "The cart from your previous session is no longer available."
|
|
7823
7832
|
};
|
|
7824
7833
|
}
|
|
7825
|
-
async function
|
|
7834
|
+
async function Ci(t) {
|
|
7826
7835
|
const e = y.getState();
|
|
7827
7836
|
if (e.ui.initStatus !== "pending")
|
|
7828
7837
|
return;
|
|
7829
|
-
const r =
|
|
7838
|
+
const r = yi();
|
|
7830
7839
|
if (e.setTakeShapeConfig(t.takeShapeConfig), !r.valid) {
|
|
7831
7840
|
ze(), e.failValidation(r.error ?? "Session validation failed");
|
|
7832
7841
|
return;
|
|
@@ -7874,12 +7883,12 @@ async function vi(t) {
|
|
|
7874
7883
|
const d = [];
|
|
7875
7884
|
d.push(
|
|
7876
7885
|
Promise.resolve(
|
|
7877
|
-
|
|
7886
|
+
xi(
|
|
7878
7887
|
c.customerEntityId ?? null,
|
|
7879
7888
|
i
|
|
7880
7889
|
)
|
|
7881
7890
|
)
|
|
7882
|
-
), s && d.push(
|
|
7891
|
+
), s && d.push(bi()), o && d.push(Promise.resolve(vi(l)));
|
|
7883
7892
|
const u = (await Promise.all(d)).find((m) => !m.valid);
|
|
7884
7893
|
if (u) {
|
|
7885
7894
|
ze(), e.failValidation(u.error ?? "Session validation failed");
|
|
@@ -7887,16 +7896,16 @@ async function vi(t) {
|
|
|
7887
7896
|
}
|
|
7888
7897
|
c && e.restoreSession(c), l && e.setBcCart(l), i && e.setCustomerInfo(i), n.length > 0 && e.setCustomerAddresses(n), e.completeValidation();
|
|
7889
7898
|
}
|
|
7890
|
-
function Ci(t) {
|
|
7891
|
-
return Qr(t) && "toolCallId" in t && typeof t.toolCallId == "string" && "output" in t && t.output !== void 0 && "state" in t && t.state === "output-available";
|
|
7892
|
-
}
|
|
7893
7899
|
function Ii(t) {
|
|
7894
|
-
return t
|
|
7900
|
+
return Qr(t) && "toolCallId" in t && typeof t.toolCallId == "string" && "output" in t && t.output !== void 0 && "state" in t && t.state === "output-available";
|
|
7895
7901
|
}
|
|
7896
7902
|
function wi(t) {
|
|
7903
|
+
return t ? t.filter(Ii) : [];
|
|
7904
|
+
}
|
|
7905
|
+
function Si(t) {
|
|
7897
7906
|
return t.type === "dynamic-tool" ? t.toolName ?? "unknown" : t.type.slice(5);
|
|
7898
7907
|
}
|
|
7899
|
-
const
|
|
7908
|
+
const Ni = new Wr({
|
|
7900
7909
|
defaultOptions: {
|
|
7901
7910
|
queries: {
|
|
7902
7911
|
staleTime: 300 * 1e3
|
|
@@ -7904,15 +7913,15 @@ const Si = new Wr({
|
|
|
7904
7913
|
}
|
|
7905
7914
|
}
|
|
7906
7915
|
});
|
|
7907
|
-
function Ni(t) {
|
|
7908
|
-
return /* @__PURE__ */ a(jr, { client: Si, children: /* @__PURE__ */ a(Ps, { client: t.bigcommerce.client, children: /* @__PURE__ */ a(Ei, { ...t }) }) });
|
|
7909
|
-
}
|
|
7910
7916
|
function Ei(t) {
|
|
7917
|
+
return /* @__PURE__ */ a(jr, { client: Ni, children: /* @__PURE__ */ a(Ts, { client: t.bigcommerce.client, children: /* @__PURE__ */ a(ki, { ...t }) }) });
|
|
7918
|
+
}
|
|
7919
|
+
function ki(t) {
|
|
7911
7920
|
const e = y((s) => s.ui.initStatus), r = y((s) => s.ui.initError), n = y((s) => s.fatalError), i = y((s) => s.clearInitError);
|
|
7912
7921
|
return F(() => {
|
|
7913
|
-
e === "pending" &&
|
|
7922
|
+
e === "pending" && Ci({
|
|
7914
7923
|
storefrontClient: t.bigcommerce.client,
|
|
7915
|
-
b2bClient:
|
|
7924
|
+
b2bClient: ni({
|
|
7916
7925
|
channelId: t.bigcommerce.client.channelId,
|
|
7917
7926
|
getB2BJwt: t.bigcommerce.getB2BJwt
|
|
7918
7927
|
}),
|
|
@@ -7922,7 +7931,7 @@ function Ei(t) {
|
|
|
7922
7931
|
"div",
|
|
7923
7932
|
{
|
|
7924
7933
|
className: `flex h-full items-center justify-center ${t.className ?? ""}`,
|
|
7925
|
-
children: /* @__PURE__ */ a(
|
|
7934
|
+
children: /* @__PURE__ */ a(sa, { message: n })
|
|
7926
7935
|
}
|
|
7927
7936
|
) : e === "pending" ? /* @__PURE__ */ a(
|
|
7928
7937
|
"div",
|
|
@@ -7934,7 +7943,7 @@ function Ei(t) {
|
|
|
7934
7943
|
"div",
|
|
7935
7944
|
{
|
|
7936
7945
|
className: `flex h-full items-center justify-center ${t.className ?? ""}`,
|
|
7937
|
-
children: /* @__PURE__ */ a(
|
|
7946
|
+
children: /* @__PURE__ */ a(na, {})
|
|
7938
7947
|
}
|
|
7939
7948
|
) : r ? /* @__PURE__ */ p(
|
|
7940
7949
|
"div",
|
|
@@ -7953,9 +7962,9 @@ function Ei(t) {
|
|
|
7953
7962
|
)
|
|
7954
7963
|
]
|
|
7955
7964
|
}
|
|
7956
|
-
) : /* @__PURE__ */ a(
|
|
7965
|
+
) : /* @__PURE__ */ a(Pi, { ...t });
|
|
7957
7966
|
}
|
|
7958
|
-
function
|
|
7967
|
+
function Pi({
|
|
7959
7968
|
className: t = "",
|
|
7960
7969
|
agentName: e = He,
|
|
7961
7970
|
inputName: r = He,
|
|
@@ -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 = ti(), $ = Pa({
|
|
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,18 +8020,18 @@ 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 (
|
|
8016
|
-
const gt =
|
|
8017
|
-
|
|
8023
|
+
const pe = C.messages[C.messages.length - 2], Xe = _.current;
|
|
8024
|
+
if (pe?.role === "assistant" && Xe.size > 0) {
|
|
8025
|
+
const gt = wi(
|
|
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
|
-
toolName:
|
|
8034
|
+
toolName: Si(Te),
|
|
8026
8035
|
toolCallId: Te.toolCallId,
|
|
8027
8036
|
state: Te.state,
|
|
8028
8037
|
input: Te.input,
|
|
@@ -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,41 +8077,41 @@ 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
|
-
ie.current = [],
|
|
8086
|
+
ie.current = [], gi(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,
|
|
8098
|
-
const T = m || J === "submitted" || J === "streaming", P = oe(() =>
|
|
8104
|
+
}, [ge, f, de, N]), F(() => {
|
|
8105
|
+
i && b === "chatting" && k(!0);
|
|
8106
|
+
}, [i, b, k]);
|
|
8107
|
+
const T = m || J === "submitted" || J === "streaming", P = oe(() => ga(j, J), [j, J]), M = Ua({
|
|
8099
8108
|
appState: b,
|
|
8100
8109
|
setAppState: x,
|
|
8101
8110
|
parser: A,
|
|
8102
8111
|
firstResponseComplete: P,
|
|
8103
8112
|
chatPanelRef: v,
|
|
8104
8113
|
bcCart: $
|
|
8105
|
-
}), L =
|
|
8114
|
+
}), L = Ta({
|
|
8106
8115
|
bcCart: $,
|
|
8107
8116
|
cartItems: V,
|
|
8108
8117
|
onCheckoutInitiated: (C) => {
|
|
@@ -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);
|
|
@@ -8163,7 +8172,7 @@ function ki({
|
|
|
8163
8172
|
]);
|
|
8164
8173
|
if (b === "upload" || b === "processing")
|
|
8165
8174
|
return /* @__PURE__ */ a("div", { className: `flex h-full ${t}`, children: /* @__PURE__ */ a(
|
|
8166
|
-
|
|
8175
|
+
wa,
|
|
8167
8176
|
{
|
|
8168
8177
|
onFileUpload: Oe,
|
|
8169
8178
|
onSkip: X,
|
|
@@ -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,15 +8221,15 @@ 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
|
}
|
|
8223
|
-
function
|
|
8232
|
+
function Ji({
|
|
8224
8233
|
takeshape: t,
|
|
8225
8234
|
bigcommerce: e,
|
|
8226
8235
|
agentName: r = He,
|
|
@@ -8239,7 +8248,7 @@ function Ki({
|
|
|
8239
8248
|
[e.endpoint, e.storefrontToken, e.channelId]
|
|
8240
8249
|
);
|
|
8241
8250
|
return /* @__PURE__ */ a(
|
|
8242
|
-
|
|
8251
|
+
Ei,
|
|
8243
8252
|
{
|
|
8244
8253
|
agentName: r,
|
|
8245
8254
|
inputName: n,
|
|
@@ -8261,14 +8270,14 @@ function Ki({
|
|
|
8261
8270
|
);
|
|
8262
8271
|
}
|
|
8263
8272
|
export {
|
|
8264
|
-
|
|
8265
|
-
|
|
8273
|
+
Ji as P,
|
|
8274
|
+
Qi as S,
|
|
8266
8275
|
Tn as a,
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8276
|
+
Hi as b,
|
|
8277
|
+
ni as c,
|
|
8278
|
+
Ei as d,
|
|
8279
|
+
Gi as i,
|
|
8280
|
+
zi as r,
|
|
8281
|
+
Ki as s
|
|
8273
8282
|
};
|
|
8274
|
-
//# sourceMappingURL=purchase-order-chat-wrapper-
|
|
8283
|
+
//# sourceMappingURL=purchase-order-chat-wrapper-fadhXbv8.js.map
|