@takeshape/purchase-order-chat 1.55.1 → 1.56.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.
@@ -1,29 +1,29 @@
1
- import { useState as _, useEffect as O, createElement as Er, useRef as D, useLayoutEffect as gt, useCallback as B, createContext as kr, useContext as Tr, useMemo as oe, forwardRef as Ar, useImperativeHandle as $r } from "react";
1
+ import { useState as U, useEffect as O, createElement as Er, useRef as D, useLayoutEffect as gt, useCallback as B, createContext as kr, useContext as Tr, useMemo as oe, forwardRef as Ar, useImperativeHandle as $r } from "react";
2
2
  import { jsxs as h, jsx as a, Fragment as we } from "react/jsx-runtime";
3
3
  import { GraphQLClient as st, ClientError as Br } from "graphql-request";
4
- import { initGraphQLTada as _t, readFragment as Se } from "gql.tada";
4
+ import { initGraphQLTada as Ut, readFragment as Se } from "gql.tada";
5
5
  import { useChat as qt } from "@ai-sdk/react";
6
6
  import { useQuery as Mr, QueryClientProvider as Or, QueryClient as Fr } from "@tanstack/react-query";
7
- import { parseJsonEventStream as Rr, uiMessageChunkSchema as Dr, DefaultChatTransport as Vt, isToolUIPart as Lr } from "ai";
7
+ import { parseJsonEventStream as Rr, uiMessageChunkSchema as Dr, DefaultChatTransport as jt, isToolUIPart as Lr } from "ai";
8
8
  import { create as at } from "zustand";
9
- import { clsx as Ur } from "clsx";
10
- import { twMerge as _r } from "tailwind-merge";
11
- import { devtools as qr, persist as jt } from "zustand/middleware";
12
- import { Streamdown as We } from "streamdown";
9
+ import { clsx as _r } from "clsx";
10
+ import { twMerge as Ur } from "tailwind-merge";
11
+ import { devtools as qr, persist as Wt } from "zustand/middleware";
12
+ import { Streamdown as Ve } from "streamdown";
13
13
  import { get as Je } from "lodash";
14
- import Vr from "p-map";
14
+ import jr from "p-map";
15
15
  import { z as yt } from "zod";
16
16
  function Ne(...t) {
17
- return _r(Ur(t));
17
+ return Ur(_r(t));
18
18
  }
19
- function Si(t, e) {
19
+ function Ei(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 jr = "__vite_c_css_pos_initial_d25fbd5284b84466bc79857abc22b971", xt = "__vite_c_css_pos_update_d25fbd5284b84466bc79857abc22b971", Ct = () => typeof window < "u" ? window[jr] : void 0, Ni = (t) => {
26
- const [e, r] = _(() => Ct() || /* @__PURE__ */ new Map()), [n, i] = _(0);
25
+ const Wr = "__vite_c_css_pos_initial_719a74bbcc18409f8d02a8e585e13c60", xt = "__vite_c_css_pos_update_719a74bbcc18409f8d02a8e585e13c60", Ct = () => typeof window < "u" ? window[Wr] : void 0, ki = (t) => {
26
+ const [e, r] = U(() => Ct() || /* @__PURE__ */ new Map()), [n, i] = U(0);
27
27
  return O(() => {
28
28
  const s = (l) => {
29
29
  const o = Ct() || /* @__PURE__ */ new Map();
@@ -36,7 +36,7 @@ const jr = "__vite_c_css_pos_initial_d25fbd5284b84466bc79857abc22b971", xt = "__
36
36
  const l = e.get(s);
37
37
  return l ? /* @__PURE__ */ Er("style", { ...l.attributes, key: `${s}-${n}` }, l.css) : null;
38
38
  });
39
- }, ze = "bigcommercePurchaseOrderAgent", vt = "https://api.takeshape.io", Wt = "https://api-b2b.bigcommerce.com/graphql", Wr = "dl7c39mdpul6hyc489yk0vzxl6jesyx", it = "[client is providing tool response]", xe = "__po_address__", Ie = "__po_billing_address__", fe = "__checkout_address__", ot = "purchase-order-chat-session", zt = 3, Ce = _t(), lt = Ce(`
39
+ }, ze = "bigcommercePurchaseOrderAgent", vt = "https://api.takeshape.io", Vt = "https://api-b2b.bigcommerce.com/graphql", Vr = "dl7c39mdpul6hyc489yk0vzxl6jesyx", it = "[client is providing tool response]", xe = "__po_address__", Ie = "__po_billing_address__", fe = "__checkout_address__", ot = "purchase-order-chat-session", zt = 3, Ce = Ut(), lt = Ce(`
40
40
  fragment UserAuthorizationFragment on UserAuthorization {
41
41
  result {
42
42
  token
@@ -126,7 +126,7 @@ const Hr = Ce(
126
126
  }
127
127
  }
128
128
  `
129
- ), q = _t(), Ae = q(`
129
+ ), q = Ut(), Ae = q(`
130
130
  fragment CartFields on Cart {
131
131
  id
132
132
  entityId
@@ -251,7 +251,7 @@ const Hr = Ce(
251
251
  }
252
252
  `,
253
253
  [Ae]
254
- ), Zr = q(
254
+ ), Xr = q(
255
255
  `
256
256
  mutation DeleteCartLineItem($input: DeleteCartLineItemInput!) {
257
257
  cart {
@@ -264,7 +264,7 @@ const Hr = Ce(
264
264
  }
265
265
  `,
266
266
  [Ae]
267
- ), Xr = q(`
267
+ ), Zr = q(`
268
268
  mutation DeleteCart($input: DeleteCartInput!) {
269
269
  cart {
270
270
  deleteCart(input: $input) {
@@ -868,7 +868,7 @@ const ke = 20;
868
868
  function Fe(t) {
869
869
  return Se(Ae, t);
870
870
  }
871
- function Ve(t) {
871
+ function je(t) {
872
872
  return Se($e, t);
873
873
  }
874
874
  function yn(t) {
@@ -1070,7 +1070,7 @@ class xn {
1070
1070
  */
1071
1071
  async deleteCartLineItem(e, r) {
1072
1072
  const i = (await this.request({
1073
- document: Zr,
1073
+ document: Xr,
1074
1074
  variables: {
1075
1075
  input: {
1076
1076
  cartEntityId: e,
@@ -1085,7 +1085,7 @@ class xn {
1085
1085
  */
1086
1086
  async deleteCart(e) {
1087
1087
  return (await this.request({
1088
- document: Xr,
1088
+ document: Zr,
1089
1089
  variables: {
1090
1090
  input: {
1091
1091
  cartEntityId: e
@@ -1143,7 +1143,7 @@ class xn {
1143
1143
  checkoutEntityId: e
1144
1144
  }
1145
1145
  })).site.checkout;
1146
- return n ? Ve(n) : null;
1146
+ return n ? je(n) : null;
1147
1147
  }
1148
1148
  /**
1149
1149
  * Add shipping consignments (addresses) to a checkout
@@ -1166,7 +1166,7 @@ class xn {
1166
1166
  }
1167
1167
  }
1168
1168
  })).checkout.addCheckoutShippingConsignments?.checkout;
1169
- return s ? Ve(s) : null;
1169
+ return s ? je(s) : null;
1170
1170
  }
1171
1171
  /**
1172
1172
  * Add shipping consignments (addresses) to a checkout
@@ -1184,7 +1184,7 @@ class xn {
1184
1184
  }
1185
1185
  }
1186
1186
  })).checkout.addCheckoutBillingAddress?.checkout;
1187
- return i ? Ve(i) : null;
1187
+ return i ? je(i) : null;
1188
1188
  }
1189
1189
  /**
1190
1190
  * Get customer's saved addresses and customer info
@@ -1242,7 +1242,7 @@ class xn {
1242
1242
  }
1243
1243
  }
1244
1244
  })).checkout.updateCheckoutCustomerMessage?.checkout;
1245
- return s ? Ve(s) : null;
1245
+ return s ? je(s) : null;
1246
1246
  }
1247
1247
  /**
1248
1248
  * Get product variant details for multiple products
@@ -1404,7 +1404,7 @@ class xn {
1404
1404
  return n;
1405
1405
  }
1406
1406
  }
1407
- function Pi(t) {
1407
+ function Ti(t) {
1408
1408
  return `https://store-${t}.mybigcommerce.com/graphql`;
1409
1409
  }
1410
1410
  function Cn(t) {
@@ -1475,23 +1475,47 @@ const Jt = {
1475
1475
  "application/json": ".json",
1476
1476
  "image/png": ".png",
1477
1477
  "image/jpeg": ".jpg,.jpeg",
1478
- "image/heic": ".heic",
1479
- "image/heif": ".heif"
1480
- }, bn = Object.keys(Jt), Yt = Object.values(Jt).join(","), In = "PDF, Excel, CSV, text, or image files", Zt = ["PDF", "Excel", "CSV", "Images"], wn = 10 * 1024 * 1024;
1481
- function Sn(t) {
1482
- return t.size > wn ? {
1483
- valid: !1,
1484
- error: "File size exceeds 10MB limit. Please choose a smaller file."
1485
- } : bn.includes(t.type) ? { valid: !0 } : {
1486
- valid: !1,
1487
- error: `File type not supported. Please upload ${In}.`
1488
- };
1478
+ "image/gif": ".gif",
1479
+ "image/webp": ".webp"
1480
+ }, bn = Object.keys(Jt), In = Object.values(Jt).flatMap(
1481
+ (t) => t.split(",")
1482
+ ), wn = [
1483
+ ".png",
1484
+ ".jpg",
1485
+ ".jpeg",
1486
+ ".gif",
1487
+ ".webp",
1488
+ ".heic",
1489
+ ".heif",
1490
+ ".bmp",
1491
+ ".tiff",
1492
+ ".tif",
1493
+ ".svg",
1494
+ ".avif"
1495
+ ], Yt = In.join(","), Sn = "PDF, Excel, CSV, text, or image files", Nn = "PNG, JPEG, GIF, or WebP", Xt = ["PDF", "Excel", "CSV", "Images"], Pn = 10 * 1024 * 1024;
1496
+ function En(t) {
1497
+ if (t.size > Pn)
1498
+ return {
1499
+ valid: !1,
1500
+ error: "File size exceeds 10MB limit. Please choose a smaller file."
1501
+ };
1502
+ if (!bn.includes(t.type)) {
1503
+ const e = t.name.includes(".") ? `.${t.name.split(".").pop()?.toLowerCase()}` : void 0;
1504
+ return t.type.startsWith("image/") || e && wn.includes(e) ? {
1505
+ valid: !1,
1506
+ error: `Image type not supported. Please upload ${Nn} images.`
1507
+ } : {
1508
+ valid: !1,
1509
+ error: `File type not supported. Please upload ${Sn}.`
1510
+ };
1511
+ }
1512
+ return { valid: !0 };
1489
1513
  }
1490
- function Xt({ onFile: t, onBeforeValidate: e }) {
1491
- const [r, n] = _(!1), [i, s] = _(null), l = D(null), o = D(null), c = B(
1514
+ function Zt({ onFile: t, onBeforeValidate: e }) {
1515
+ const [r, n] = U(!1), [i, s] = U(null), l = D(null), o = D(null), c = B(
1492
1516
  (x) => {
1493
1517
  e?.(), s(null);
1494
- const b = Sn(x);
1518
+ const b = En(x);
1495
1519
  if (!b.valid) {
1496
1520
  s(b.error ?? null);
1497
1521
  return;
@@ -1536,7 +1560,7 @@ function Xt({ onFile: t, onBeforeValidate: e }) {
1536
1560
  openCamera: I
1537
1561
  };
1538
1562
  }
1539
- const Nn = () => /* @__PURE__ */ h(
1563
+ const kn = () => /* @__PURE__ */ h(
1540
1564
  "svg",
1541
1565
  {
1542
1566
  width: "18",
@@ -1621,7 +1645,7 @@ const Nn = () => /* @__PURE__ */ h(
1621
1645
  /* @__PURE__ */ a("line", { x1: "3", y1: "21", x2: "10", y2: "14" })
1622
1646
  ]
1623
1647
  }
1624
- ), Pn = ({
1648
+ ), Tn = ({
1625
1649
  size: t = 12,
1626
1650
  title: e = "Error"
1627
1651
  }) => /* @__PURE__ */ h(
@@ -1640,7 +1664,7 @@ const Nn = () => /* @__PURE__ */ h(
1640
1664
  /* @__PURE__ */ a("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
1641
1665
  ]
1642
1666
  }
1643
- ), Ue = ({ size: t = 12 }) => /* @__PURE__ */ h(
1667
+ ), _e = ({ size: t = 12 }) => /* @__PURE__ */ h(
1644
1668
  "svg",
1645
1669
  {
1646
1670
  width: t,
@@ -1656,7 +1680,7 @@ const Nn = () => /* @__PURE__ */ h(
1656
1680
  ]
1657
1681
  }
1658
1682
  );
1659
- function En({
1683
+ function An({
1660
1684
  addresses: t,
1661
1685
  selectedAddressId: e,
1662
1686
  addressUpdateStatus: r = "idle",
@@ -1731,7 +1755,7 @@ function It(t) {
1731
1755
  /* @__PURE__ */ h("div", { className: "flex justify-between items-center mb-0.5", children: [
1732
1756
  /* @__PURE__ */ a("span", { className: "text-[0.625rem] text-text-tertiary uppercase tracking-[0.05em]", children: e }),
1733
1757
  i === "updating" && /* @__PURE__ */ h("span", { className: "flex items-center gap-1 text-[0.625rem] font-medium text-text-tertiary uppercase tracking-[0.025em]", children: [
1734
- /* @__PURE__ */ a(Ue, { size: 10 }),
1758
+ /* @__PURE__ */ a(_e, { size: 10 }),
1735
1759
  "Updating..."
1736
1760
  ] }),
1737
1761
  i === "success" && /* @__PURE__ */ h("span", { className: "flex items-center gap-0.5 text-[0.625rem] font-semibold text-success-text uppercase tracking-[0.025em]", children: [
@@ -1739,7 +1763,7 @@ function It(t) {
1739
1763
  "Updated"
1740
1764
  ] }),
1741
1765
  i === "error" && /* @__PURE__ */ h("span", { className: "flex items-center gap-0.5 text-[0.625rem] font-semibold text-error-text uppercase tracking-[0.025em]", children: [
1742
- /* @__PURE__ */ a(Pn, { size: 12, title: "Failed" }),
1766
+ /* @__PURE__ */ a(Tn, { size: 12, title: "Failed" }),
1743
1767
  "Failed to update"
1744
1768
  ] })
1745
1769
  ] }),
@@ -1767,7 +1791,7 @@ function It(t) {
1767
1791
  ]
1768
1792
  }
1769
1793
  ),
1770
- l && /* @__PURE__ */ a(Tn, { address: l }),
1794
+ l && /* @__PURE__ */ a(Bn, { address: l }),
1771
1795
  m && /* @__PURE__ */ a("p", { className: "mt-1.5 pt-1.5 m-0 text-[0.6875rem] leading-[1.4]", children: "Your company has a default address set. Verify your address on the checkout page as it may not populate automatically." })
1772
1796
  ]
1773
1797
  }
@@ -1792,18 +1816,18 @@ function wt(t) {
1792
1816
  e.postalCode
1793
1817
  ] });
1794
1818
  }
1795
- function kn(t) {
1819
+ function $n(t) {
1796
1820
  const e = [t.address1];
1797
1821
  t.address2 && e.push(t.address2), t.city && e.push(t.city), t.stateOrProvince && e.push(t.stateOrProvince);
1798
1822
  const r = e.pop();
1799
1823
  return t.postalCode ? e.push(`${r} ${t.postalCode}`) : r && e.push(r), e.join(", ");
1800
1824
  }
1801
- function Tn({ address: t }) {
1802
- const [e, r] = _(!1), n = D(void 0);
1825
+ function Bn({ address: t }) {
1826
+ const [e, r] = U(!1), n = D(void 0);
1803
1827
  O(() => () => {
1804
1828
  n.current && clearTimeout(n.current);
1805
1829
  }, []);
1806
- const i = kn(t), s = B(async () => {
1830
+ const i = $n(t), s = B(async () => {
1807
1831
  try {
1808
1832
  await navigator.clipboard.writeText(i), r(!0), n.current && clearTimeout(n.current), n.current = setTimeout(() => r(!1), 1500);
1809
1833
  } catch {
@@ -1837,10 +1861,10 @@ function Ye({ label: t, value: e }) {
1837
1861
  /* @__PURE__ */ a("span", { className: "text-[0.8125rem] text-text", children: e })
1838
1862
  ] });
1839
1863
  }
1840
- function Ze(t, e) {
1864
+ function Xe(t, e) {
1841
1865
  return t != null ? Te(t, e) : "...";
1842
1866
  }
1843
- function An({
1867
+ function Mn({
1844
1868
  subtotal: t,
1845
1869
  tax: e,
1846
1870
  shipping: r,
@@ -1860,17 +1884,17 @@ function An({
1860
1884
  value: Te(t, i)
1861
1885
  }
1862
1886
  ),
1863
- /* @__PURE__ */ a(Ye, { label: "Tax", value: Ze(e, i) }),
1887
+ /* @__PURE__ */ a(Ye, { label: "Tax", value: Xe(e, i) }),
1864
1888
  /* @__PURE__ */ a(
1865
1889
  Ye,
1866
1890
  {
1867
1891
  label: "Shipping",
1868
- value: Ze(r, i)
1892
+ value: Xe(r, i)
1869
1893
  }
1870
1894
  ),
1871
1895
  /* @__PURE__ */ h("div", { className: "flex justify-between mt-1 pt-1.5 border-t border-border", children: [
1872
1896
  /* @__PURE__ */ a("span", { className: "text-[0.875rem] font-semibold text-text", children: "Total" }),
1873
- /* @__PURE__ */ a("span", { className: "text-[0.875rem] font-semibold text-text", children: Ze(n, i) })
1897
+ /* @__PURE__ */ a("span", { className: "text-[0.875rem] font-semibold text-text", children: Xe(n, i) })
1874
1898
  ] }),
1875
1899
  /* @__PURE__ */ a(
1876
1900
  "button",
@@ -1946,7 +1970,7 @@ function sr({
1946
1970
  asyncMode: s = !1,
1947
1971
  testId: l
1948
1972
  }) {
1949
- const [o, c] = _(String(t)), [d, f] = _(
1973
+ const [o, c] = U(String(t)), [d, f] = U(
1950
1974
  "idle"
1951
1975
  ), u = D(null);
1952
1976
  O(() => () => {
@@ -2071,12 +2095,12 @@ function sr({
2071
2095
  )
2072
2096
  }
2073
2097
  ),
2074
- w && /* @__PURE__ */ a("span", { className: "text-text-tertiary ml-0.5", children: /* @__PURE__ */ a(Ue, {}) }),
2098
+ w && /* @__PURE__ */ a("span", { className: "text-text-tertiary ml-0.5", children: /* @__PURE__ */ a(_e, {}) }),
2075
2099
  d === "success" && /* @__PURE__ */ a("span", { className: "text-success ml-0.5", children: /* @__PURE__ */ a(Le, {}) }),
2076
2100
  d === "error" && /* @__PURE__ */ a("span", { className: "text-error text-[0.6875rem] ml-0.5", children: "Failed" })
2077
2101
  ] });
2078
2102
  }
2079
- function $n(t) {
2103
+ function On(t) {
2080
2104
  const {
2081
2105
  item: e,
2082
2106
  onUpdateQuantity: r,
@@ -2152,7 +2176,7 @@ function $n(t) {
2152
2176
  e.status === "pending" && /* @__PURE__ */ a("span", { className: "inline-block text-[0.6875rem] font-medium px-1.5 py-0.5 rounded mt-1 bg-warning/20 text-warning-text", children: "Pending" }),
2153
2177
  /* @__PURE__ */ h("div", { className: "flex items-center justify-between mt-2", children: [
2154
2178
  /* @__PURE__ */ a("div", { className: "flex items-center gap-1.5", children: /* @__PURE__ */ a(
2155
- Bn,
2179
+ Fn,
2156
2180
  {
2157
2181
  onClick: () => i(e.name, e.sku)
2158
2182
  }
@@ -2165,7 +2189,7 @@ function $n(t) {
2165
2189
  ] })
2166
2190
  ] });
2167
2191
  }
2168
- function Bn(t) {
2192
+ function Fn(t) {
2169
2193
  return /* @__PURE__ */ a(
2170
2194
  "button",
2171
2195
  {
@@ -2193,7 +2217,7 @@ function De({
2193
2217
  );
2194
2218
  }
2195
2219
  function ar({ onNewOrder: t }) {
2196
- const [e, r] = _(!1), n = D(
2220
+ const [e, r] = U(!1), n = D(
2197
2221
  void 0
2198
2222
  ), i = () => {
2199
2223
  e || (r(!0), n.current = setTimeout(() => r(!1), 3e3));
@@ -2241,7 +2265,7 @@ function ar({ onNewOrder: t }) {
2241
2265
  "New Order"
2242
2266
  ] });
2243
2267
  }
2244
- const Mn = () => /* @__PURE__ */ h(
2268
+ const Rn = () => /* @__PURE__ */ h(
2245
2269
  "svg",
2246
2270
  {
2247
2271
  width: "48",
@@ -2261,7 +2285,7 @@ const Mn = () => /* @__PURE__ */ h(
2261
2285
  ]
2262
2286
  }
2263
2287
  );
2264
- function On({
2288
+ function Dn({
2265
2289
  className: t = "",
2266
2290
  isDragging: e = !1,
2267
2291
  onNewOrder: r,
@@ -2290,7 +2314,7 @@ function On({
2290
2314
  ] })
2291
2315
  ] }),
2292
2316
  /* @__PURE__ */ h("div", { className: "flex flex-col flex-1 items-center justify-center gap-4 py-3 px-8", children: [
2293
- /* @__PURE__ */ a("div", { className: "flex items-center justify-center w-16 h-16 rounded-[14px] p-1 text-text", children: /* @__PURE__ */ a(Mn, {}) }),
2317
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-center w-16 h-16 rounded-[14px] p-1 text-text", children: /* @__PURE__ */ a(Rn, {}) }),
2294
2318
  /* @__PURE__ */ a("h3", { className: "m-0 text-base font-semibold text-text", children: "Your cart will appear here" }),
2295
2319
  /* @__PURE__ */ a("div", { className: "h-[50px]", "aria-hidden": "true" })
2296
2320
  ] }),
@@ -2302,7 +2326,7 @@ function On({
2302
2326
  const ir = {
2303
2327
  pendingMessage: null,
2304
2328
  shouldScroll: !0
2305
- }, Fn = (t) => ({
2329
+ }, Ln = (t) => ({
2306
2330
  ai: { ...ir },
2307
2331
  sendMessage: (e, r) => t(
2308
2332
  (n) => ({
@@ -2322,15 +2346,15 @@ const ir = {
2322
2346
  !1,
2323
2347
  "ai/consumeMessage"
2324
2348
  )
2325
- }), Xe = {
2349
+ }), Ze = {
2326
2350
  status: "idle",
2327
2351
  error: null,
2328
2352
  results: null,
2329
2353
  processingFailuresString: "",
2330
2354
  toolCalls: [],
2331
2355
  revealedCount: 0
2332
- }, Rn = (t) => ({
2333
- batchProcessing: { ...Xe },
2356
+ }, _n = (t) => ({
2357
+ batchProcessing: { ...Ze },
2334
2358
  setBatchProcessingStatus: (e) => t(
2335
2359
  (r) => ({ batchProcessing: { ...r.batchProcessing, status: e } }),
2336
2360
  !1,
@@ -2373,7 +2397,7 @@ const ir = {
2373
2397
  "batchProcessing/incrementRevealed"
2374
2398
  ),
2375
2399
  resetBatchProcessing: () => t(
2376
- { batchProcessing: { ...Xe } },
2400
+ { batchProcessing: { ...Ze } },
2377
2401
  !1,
2378
2402
  "batchProcessing/reset"
2379
2403
  )
@@ -2382,7 +2406,7 @@ const ir = {
2382
2406
  checkout: null,
2383
2407
  isLoading: !1,
2384
2408
  productPaths: {}
2385
- }, Dn = (t) => ({
2409
+ }, Un = (t) => ({
2386
2410
  bcSession: { ...Et },
2387
2411
  setBcCart: (e) => t(
2388
2412
  (r) => ({ bcSession: { ...r.bcSession, bcCart: e } }),
@@ -2413,7 +2437,7 @@ const ir = {
2413
2437
  function kt(t, e) {
2414
2438
  return `${t}-${e}`;
2415
2439
  }
2416
- const Ln = {
2440
+ const qn = {
2417
2441
  cartEntityId: null,
2418
2442
  poItemPrices: {},
2419
2443
  orderId: null,
@@ -2422,8 +2446,8 @@ const Ln = {
2422
2446
  billingAddress: null,
2423
2447
  poMetadataSet: !1,
2424
2448
  itemWarnings: []
2425
- }, Un = (t) => ({
2426
- cartifact: { ...Ln },
2449
+ }, jn = (t) => ({
2450
+ cartifact: { ...qn },
2427
2451
  setCartEntityId: (e) => t(
2428
2452
  (r) => ({ cartifact: { ...r.cartifact, cartEntityId: e } }),
2429
2453
  !1,
@@ -2553,13 +2577,13 @@ const Ln = {
2553
2577
  !1,
2554
2578
  "cartifact/applyPoMetadata"
2555
2579
  )
2556
- }), _n = {
2580
+ }), Wn = {
2557
2581
  messages: [],
2558
2582
  input: "",
2559
2583
  threadId: null,
2560
2584
  toolCallErrors: {}
2561
- }, qn = (t) => ({
2562
- chat: { ..._n },
2585
+ }, Vn = (t) => ({
2586
+ chat: { ...Wn },
2563
2587
  setMessages: (e) => t(
2564
2588
  (r) => ({ chat: { ...r.chat, messages: e } }),
2565
2589
  !1,
@@ -2608,11 +2632,11 @@ const Ln = {
2608
2632
  !1,
2609
2633
  "chat/clearChat"
2610
2634
  )
2611
- }), Vn = {
2635
+ }), zn = {
2612
2636
  customerInfo: null,
2613
2637
  customerAddresses: []
2614
- }, jn = (t) => ({
2615
- customer: { ...Vn },
2638
+ }, Qn = (t) => ({
2639
+ customer: { ...zn },
2616
2640
  setCustomerInfo: (e) => {
2617
2641
  t(
2618
2642
  (r) => ({
@@ -2630,12 +2654,12 @@ const Ln = {
2630
2654
  !1,
2631
2655
  "customer/setCustomerAddresses"
2632
2656
  )
2633
- }), Wn = {
2657
+ }), Hn = {
2634
2658
  uploadedFileName: null,
2635
2659
  parsedContent: null,
2636
2660
  hasProcessedDocument: !1
2637
- }, zn = (t) => ({
2638
- parser: { ...Wn },
2661
+ }, Gn = (t) => ({
2662
+ parser: { ...Hn },
2639
2663
  setUploadedFileName: (e) => t(
2640
2664
  (r) => ({ parser: { ...r.parser, uploadedFileName: e } }),
2641
2665
  !1,
@@ -2663,15 +2687,15 @@ const Ln = {
2663
2687
  !1,
2664
2688
  "parser/clearParser"
2665
2689
  )
2666
- }), Qn = {
2690
+ }), Kn = {
2667
2691
  projectId: "",
2668
2692
  apiKey: "",
2669
2693
  origin: "",
2670
2694
  sseOrigin: ""
2671
- }, Hn = (t) => ({
2672
- takeshapeConfig: { ...Qn },
2695
+ }, Jn = (t) => ({
2696
+ takeshapeConfig: { ...Kn },
2673
2697
  setTakeShapeConfig: (e) => t({ takeshapeConfig: e }, !1, "setTakeShapeConfig")
2674
- }), Gn = {
2698
+ }), Yn = {
2675
2699
  initStatus: "pending",
2676
2700
  initError: null,
2677
2701
  existingCart: null,
@@ -2680,8 +2704,8 @@ const Ln = {
2680
2704
  addressUpdateStatus: "idle",
2681
2705
  selectedBillingAddressId: null,
2682
2706
  billingAddressUpdateStatus: "idle"
2683
- }, Kn = (t) => ({
2684
- ui: { ...Gn },
2707
+ }, Xn = (t) => ({
2708
+ ui: { ...Yn },
2685
2709
  toggleMessageExpanded: (e) => t(
2686
2710
  (r) => {
2687
2711
  const n = r.ui.expandedMessageIds, i = n.includes(e);
@@ -2729,7 +2753,7 @@ const Ln = {
2729
2753
  "ui/clearAddressSelections"
2730
2754
  )
2731
2755
  });
2732
- function Jn() {
2756
+ function Zn() {
2733
2757
  return {
2734
2758
  appState: "upload",
2735
2759
  customerEntityId: null,
@@ -2776,23 +2800,23 @@ function Jn() {
2776
2800
  selectedBillingAddressId: null,
2777
2801
  billingAddressUpdateStatus: "idle"
2778
2802
  },
2779
- batchProcessing: { ...Xe }
2803
+ batchProcessing: { ...Ze }
2780
2804
  };
2781
2805
  }
2782
2806
  const g = at()(
2783
2807
  qr(
2784
- jt(
2808
+ Wt(
2785
2809
  (t, e) => ({
2786
2810
  // Combine all slices
2787
- ...Fn(t),
2788
- ...qn(t),
2789
- ...Un(t),
2811
+ ...Ln(t),
2812
+ ...Vn(t),
2790
2813
  ...jn(t),
2791
- ...Dn(t),
2792
- ...zn(t),
2793
- ...Kn(t),
2794
- ...Rn(t),
2795
- ...Hn(t),
2814
+ ...Qn(t),
2815
+ ...Un(t),
2816
+ ...Gn(t),
2817
+ ...Xn(t),
2818
+ ..._n(t),
2819
+ ...Jn(t),
2796
2820
  // Top-level state
2797
2821
  appState: "upload",
2798
2822
  customerEntityId: null,
@@ -2863,7 +2887,7 @@ const g = at()(
2863
2887
  failValidation: (r) => {
2864
2888
  t(
2865
2889
  {
2866
- ...Jn(),
2890
+ ...Zn(),
2867
2891
  appState: "upload",
2868
2892
  ui: {
2869
2893
  initStatus: "ready",
@@ -2961,7 +2985,7 @@ const g = at()(
2961
2985
  function et({ productName: t, productSku: e }) {
2962
2986
  return t && e ? `${t} (${e})` : t || e || "Unknown Product";
2963
2987
  }
2964
- function Yn({
2988
+ function es({
2965
2989
  item: t,
2966
2990
  onSuggestAlternatives: e
2967
2991
  }) {
@@ -3002,7 +3026,7 @@ function Yn({
3002
3026
  ] })
3003
3027
  ] });
3004
3028
  }
3005
- function Zn({
3029
+ function ts({
3006
3030
  items: t,
3007
3031
  itemWarnings: e = [],
3008
3032
  onUpdateQuantity: r,
@@ -3030,18 +3054,18 @@ function Zn({
3030
3054
  onExpand: F,
3031
3055
  onMinimize: Q
3032
3056
  }) {
3033
- const [H, z] = _(!1), ae = D(void 0), ee = B(() => {
3057
+ const [H, z] = U(!1), ae = D(void 0), ee = B(() => {
3034
3058
  d && navigator.clipboard.writeText(d).then(() => {
3035
3059
  z(!0), clearTimeout(ae.current), ae.current = setTimeout(() => z(!1), 2e3);
3036
3060
  });
3037
- }, [d]), se = t.filter((L) => L.status !== "unavailable").reduce((L, V) => L + (V.price ?? 0) * V.quantity, 0), Y = t.filter((L) => L.status !== "unavailable"), te = Y.reduce(
3038
- (L, V) => L + V.quantity,
3061
+ }, [d]), se = t.filter((L) => L.status !== "unavailable").reduce((L, j) => L + (j.price ?? 0) * j.quantity, 0), Y = t.filter((L) => L.status !== "unavailable"), te = Y.reduce(
3062
+ (L, j) => L + j.quantity,
3039
3063
  0
3040
- ), j = t.find(
3064
+ ), W = t.find(
3041
3065
  (L) => L.catalogPriceCurrencyCode
3042
- )?.catalogPriceCurrencyCode, W = T?.tax, ie = T?.shipping, ve = T?.grandTotal ?? (W !== null ? se + (W ?? 0) + (ie ?? 0) : null);
3066
+ )?.catalogPriceCurrencyCode, V = T?.tax, ie = T?.shipping, ve = T?.grandTotal ?? (V !== null ? se + (V ?? 0) + (ie ?? 0) : null);
3043
3067
  return t.length === 0 && e.length === 0 && !y ? /* @__PURE__ */ a(
3044
- On,
3068
+ Dn,
3045
3069
  {
3046
3070
  className: c,
3047
3071
  isDragging: A,
@@ -3095,7 +3119,7 @@ function Zn({
3095
3119
  ] })
3096
3120
  ] }),
3097
3121
  /* @__PURE__ */ a(
3098
- En,
3122
+ An,
3099
3123
  {
3100
3124
  addresses: f,
3101
3125
  selectedAddressId: u,
@@ -3112,22 +3136,22 @@ function Zn({
3112
3136
  /* @__PURE__ */ a("div", { className: "h-px shrink-0 bg-border" }),
3113
3137
  /* @__PURE__ */ a("div", { className: "flex-1 min-h-0 overflow-y-auto flex flex-col", children: /* @__PURE__ */ h("div", { className: "flex-1 min-h-0 overflow-y-auto p-2 bg-surface", children: [
3114
3138
  t.length === 0 && e.length === 0 && /* @__PURE__ */ h("div", { className: "flex flex-col items-center justify-center h-full text-center", children: [
3115
- /* @__PURE__ */ a("div", { className: "w-12 h-12 mx-auto mb-3 rounded-full bg-surface-tertiary flex items-center justify-center text-text-quaternary", children: /* @__PURE__ */ a(Nn, {}) }),
3139
+ /* @__PURE__ */ a("div", { className: "w-12 h-12 mx-auto mb-3 rounded-full bg-surface-tertiary flex items-center justify-center text-text-quaternary", children: /* @__PURE__ */ a(kn, {}) }),
3116
3140
  /* @__PURE__ */ a("p", { className: "text-sm text-text-quaternary m-0", children: "No items in cart yet" })
3117
3141
  ] }),
3118
3142
  e.length > 0 && /* @__PURE__ */ h(we, { children: [
3119
3143
  e.map((L) => /* @__PURE__ */ a(
3120
- Yn,
3144
+ es,
3121
3145
  {
3122
3146
  item: L,
3123
- onSuggestAlternatives: (V) => s(V)
3147
+ onSuggestAlternatives: (j) => s(j)
3124
3148
  },
3125
3149
  `${et(L)}-${L.status}`
3126
3150
  )),
3127
3151
  t.length > 0 && /* @__PURE__ */ a("div", { className: "border-b border-border mb-2" })
3128
3152
  ] }),
3129
3153
  t.map((L) => /* @__PURE__ */ a(
3130
- $n,
3154
+ On,
3131
3155
  {
3132
3156
  item: L,
3133
3157
  onUpdateQuantity: r,
@@ -3140,13 +3164,13 @@ function Zn({
3140
3164
  ] }) }),
3141
3165
  /* @__PURE__ */ a("div", { className: "h-px shrink-0 bg-border" }),
3142
3166
  /* @__PURE__ */ a(
3143
- An,
3167
+ Mn,
3144
3168
  {
3145
3169
  subtotal: se,
3146
- tax: W,
3170
+ tax: V,
3147
3171
  shipping: ie,
3148
3172
  total: ve,
3149
- currencyCode: j,
3173
+ currencyCode: W,
3150
3174
  totalQuantity: te,
3151
3175
  availableItemCount: Y.length,
3152
3176
  onCheckout: i,
@@ -3158,7 +3182,7 @@ function Zn({
3158
3182
  }
3159
3183
  );
3160
3184
  }
3161
- const Xn = [
3185
+ const rs = [
3162
3186
  "failed to fetch",
3163
3187
  "networkerror",
3164
3188
  "network request failed",
@@ -3167,16 +3191,16 @@ const Xn = [
3167
3191
  "net::err_internet_disconnected",
3168
3192
  "net::err_network_changed"
3169
3193
  ];
3170
- function es(t) {
3194
+ function ns(t) {
3171
3195
  if (typeof navigator < "u" && !navigator.onLine)
3172
3196
  return !0;
3173
3197
  const e = t.message.toLowerCase();
3174
- return Xn.some((r) => e.includes(r));
3198
+ return rs.some((r) => e.includes(r));
3175
3199
  }
3176
- function ts({ error: t, onRetry: e }) {
3200
+ function ss({ error: t, onRetry: e }) {
3177
3201
  if (!t)
3178
3202
  return null;
3179
- const r = es(t);
3203
+ const r = ns(t);
3180
3204
  return /* @__PURE__ */ h("div", { className: "mx-4 my-3 px-4 py-3 bg-error-bg border border-error/30 rounded-lg", children: [
3181
3205
  /* @__PURE__ */ a("p", { className: "text-sm text-error-text", children: r ? "You're offline. Please check your internet connection and try again." : "Something went wrong. Please try again." }),
3182
3206
  e && /* @__PURE__ */ a(
@@ -3190,7 +3214,7 @@ function ts({ error: t, onRetry: e }) {
3190
3214
  )
3191
3215
  ] });
3192
3216
  }
3193
- const rs = () => /* @__PURE__ */ h(
3217
+ const as = () => /* @__PURE__ */ h(
3194
3218
  "svg",
3195
3219
  {
3196
3220
  width: "18",
@@ -3206,7 +3230,7 @@ const rs = () => /* @__PURE__ */ h(
3206
3230
  ]
3207
3231
  }
3208
3232
  );
3209
- function ns({
3233
+ function is({
3210
3234
  input: t,
3211
3235
  onInputChange: e,
3212
3236
  onSubmit: r,
@@ -3243,25 +3267,25 @@ function ns({
3243
3267
  className: "w-10 h-10 mr-1.5 border-none rounded-lg bg-surface-invert text-text-invert cursor-pointer flex items-center justify-center transition-colors shrink-0 hover:bg-surface-invert-hover disabled:bg-surface-disabled disabled:cursor-not-allowed",
3244
3268
  disabled: !t.trim() || n,
3245
3269
  "aria-label": "Send message",
3246
- children: /* @__PURE__ */ a(rs, {})
3270
+ children: /* @__PURE__ */ a(as, {})
3247
3271
  }
3248
3272
  )
3249
3273
  ]
3250
3274
  }
3251
3275
  ) });
3252
3276
  }
3253
- const or = "showProducts", ss = "searchProducts", as = "searchProductsBySku", Be = "addToCart", lr = "updateCart", cr = "removeFromCart", dr = "clearCart", ur = "getCart", ct = "getPurchaseOrderData", Ge = "setPoMetadata", pr = "setItemWarnings", fr = "removeItemWarnings", dt = "addProcessingFailures", is = /* @__PURE__ */ new Set([or]);
3254
- function os(t) {
3255
- return t.type === "tool" && !is.has(t.toolName);
3277
+ const or = "showProducts", os = "searchProducts", ls = "searchProductsBySku", Be = "addToCart", lr = "updateCart", cr = "removeFromCart", dr = "clearCart", ur = "getCart", ct = "getPurchaseOrderData", Ge = "setPoMetadata", pr = "setItemWarnings", fr = "removeItemWarnings", dt = "addProcessingFailures", cs = /* @__PURE__ */ new Set([or]);
3278
+ function ds(t) {
3279
+ return t.type === "tool" && !cs.has(t.toolName);
3256
3280
  }
3257
- function ls(t) {
3281
+ function us(t) {
3258
3282
  const e = [];
3259
3283
  let r = [];
3260
3284
  function n() {
3261
3285
  r.length >= 2 ? e.push({ type: "tool-group", tools: r }) : r.length === 1 && e.push(r[0]), r = [];
3262
3286
  }
3263
3287
  for (const i of t)
3264
- os(i) ? r.push(i) : (n(), e.push(i));
3288
+ ds(i) ? r.push(i) : (n(), e.push(i));
3265
3289
  return n(), e;
3266
3290
  }
3267
3291
  const Tt = () => /* @__PURE__ */ h(
@@ -3321,7 +3345,7 @@ function ut(t) {
3321
3345
  return;
3322
3346
  }
3323
3347
  }
3324
- function cs({
3348
+ function ps({
3325
3349
  toolCallId: t,
3326
3350
  toolInput: e,
3327
3351
  toolOutput: r,
@@ -3347,7 +3371,7 @@ function cs({
3347
3371
  }
3348
3372
  );
3349
3373
  }
3350
- function ds({
3374
+ function fs({
3351
3375
  toolCallId: t,
3352
3376
  toolInput: e,
3353
3377
  toolOutput: r,
@@ -3376,7 +3400,7 @@ function ds({
3376
3400
  const mr = kr(
3377
3401
  null
3378
3402
  );
3379
- function us({
3403
+ function hs({
3380
3404
  client: t,
3381
3405
  children: e
3382
3406
  }) {
@@ -3385,7 +3409,7 @@ function us({
3385
3409
  function pt() {
3386
3410
  return Tr(mr);
3387
3411
  }
3388
- function ps(t, e) {
3412
+ function ms(t, e) {
3389
3413
  return Mr({
3390
3414
  queryKey: [
3391
3415
  "productVariants",
@@ -3429,7 +3453,7 @@ function At(t) {
3429
3453
  }
3430
3454
  return e;
3431
3455
  }
3432
- const fs = () => /* @__PURE__ */ a("div", { className: "w-full h-full bg-surface-tertiary flex items-center justify-center text-text-quaternary", children: /* @__PURE__ */ h(
3456
+ const gs = () => /* @__PURE__ */ a("div", { className: "w-full h-full bg-surface-tertiary flex items-center justify-center text-text-quaternary", children: /* @__PURE__ */ h(
3433
3457
  "svg",
3434
3458
  {
3435
3459
  width: "40",
@@ -3446,7 +3470,7 @@ const fs = () => /* @__PURE__ */ a("div", { className: "w-full h-full bg-surface
3446
3470
  ]
3447
3471
  }
3448
3472
  ) });
3449
- function hs({
3473
+ function ys({
3450
3474
  variantDetails: t,
3451
3475
  selections: e,
3452
3476
  onSelectionChange: r
@@ -3479,8 +3503,8 @@ function hs({
3479
3503
  i && /* @__PURE__ */ a("p", { className: "text-xs text-error m-0", role: "alert", "aria-live": "polite", children: "This combination is not available" })
3480
3504
  ] });
3481
3505
  }
3482
- const ms = 10;
3483
- function gs(t, e, r) {
3506
+ const xs = 10;
3507
+ function Cs(t, e, r) {
3484
3508
  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";
3485
3509
  }
3486
3510
  function $t({
@@ -3494,9 +3518,9 @@ function $t({
3494
3518
  selections: o,
3495
3519
  onSelectionChange: c
3496
3520
  }) {
3497
- const [d, f] = _(1), [u, m] = _(!1), [N, I] = _(!1), x = i === "horizontal", b = l && o ? ft(l.variants, o) : null, k = b?.entityId ?? t.variantEntityId, w = r.find(
3498
- (j) => j.productEntityId === t.productEntityId && j.variantEntityId === k
3499
- ), T = !!w, v = w?.quantity ?? 0, y = b?.sku ?? t.sku, A = b?.prices?.price?.value ?? t.price, $ = b?.inventory?.aggregated?.availableToSell ?? t.availableQuantity, F = $ !== void 0 && $ > 0 && $ < ms, Q = b?.inventory?.isInStock ?? t.isInStock, H = b !== null ? (
3521
+ const [d, f] = U(1), [u, m] = U(!1), [N, I] = U(!1), x = i === "horizontal", b = l && o ? ft(l.variants, o) : null, k = b?.entityId ?? t.variantEntityId, w = r.find(
3522
+ (W) => W.productEntityId === t.productEntityId && W.variantEntityId === k
3523
+ ), T = !!w, v = w?.quantity ?? 0, y = b?.sku ?? t.sku, A = b?.prices?.price?.value ?? t.price, $ = b?.inventory?.aggregated?.availableToSell ?? t.availableQuantity, F = $ !== void 0 && $ > 0 && $ < xs, Q = b?.inventory?.isInStock ?? t.isInStock, H = b !== null ? (
3500
3524
  // Have variant details: check variant stock
3501
3525
  !b.isPurchasable || Q === !1 || Q === void 0 && (b.inventory?.aggregated?.availableToSell ?? 0) === 0
3502
3526
  ) : (
@@ -3549,7 +3573,7 @@ function $t({
3549
3573
  alt: t.name,
3550
3574
  className: "w-full h-full object-cover"
3551
3575
  }
3552
- ) : /* @__PURE__ */ a(fs, {}),
3576
+ ) : /* @__PURE__ */ a(gs, {}),
3553
3577
  !x && H && /* @__PURE__ */ a("div", { className: "absolute top-2 right-2 bg-error text-text-invert text-[0.6875rem] font-semibold px-2 py-0.5 rounded", children: "Out of stock" })
3554
3578
  ]
3555
3579
  }
@@ -3587,7 +3611,7 @@ function $t({
3587
3611
  x && te
3588
3612
  ] }),
3589
3613
  l && o && c && /* @__PURE__ */ a("div", { className: x ? "mt-2" : "shrink-0 px-3 pt-2", children: /* @__PURE__ */ a(
3590
- hs,
3614
+ ys,
3591
3615
  {
3592
3616
  variantDetails: l,
3593
3617
  selections: o,
@@ -3626,7 +3650,7 @@ function $t({
3626
3650
  type: "button",
3627
3651
  onClick: ae,
3628
3652
  disabled: u || N || !!z || H,
3629
- className: `py-1.5 px-3 text-xs font-medium rounded border-none ${x ? "" : "w-full"} ${gs(u, N, !!z || H)}`,
3653
+ className: `py-1.5 px-3 text-xs font-medium rounded border-none ${x ? "" : "w-full"} ${Cs(u, N, !!z || H)}`,
3630
3654
  children: u ? "Adding..." : N ? "✓ Added" : "Add to cart"
3631
3655
  }
3632
3656
  )
@@ -3643,7 +3667,7 @@ function $t({
3643
3667
  }
3644
3668
  );
3645
3669
  }
3646
- function ys({
3670
+ function vs({
3647
3671
  products: t,
3648
3672
  onAddToCart: e,
3649
3673
  onViewProduct: r,
@@ -3655,7 +3679,7 @@ function ys({
3655
3679
  const o = pt(), c = oe(
3656
3680
  () => t.filter((b) => b.productEntityId !== void 0).map((b) => b.productEntityId),
3657
3681
  [t]
3658
- ), { data: d } = ps(
3682
+ ), { data: d } = ms(
3659
3683
  o,
3660
3684
  o ? c : []
3661
3685
  ), f = oe(() => {
@@ -3664,7 +3688,7 @@ function ys({
3664
3688
  for (const k of d)
3665
3689
  k.productOptions.length > 0 && b.set(k.entityId, k);
3666
3690
  return b;
3667
- }, [d]), [u, m] = _(/* @__PURE__ */ new Map());
3691
+ }, [d]), [u, m] = U(/* @__PURE__ */ new Map());
3668
3692
  O(() => {
3669
3693
  d && m((b) => {
3670
3694
  const k = new Map(b);
@@ -3735,14 +3759,14 @@ function ys({
3735
3759
  );
3736
3760
  }) });
3737
3761
  }
3738
- function xs({
3762
+ function bs({
3739
3763
  toolInput: t,
3740
3764
  toolState: e,
3741
3765
  cart: r,
3742
3766
  onAddToCart: n,
3743
3767
  onViewProduct: i
3744
3768
  }) {
3745
- const s = pt(), [l, o] = _([]), [c, d] = _(!0), [f, u] = _(null), m = e !== "output-available";
3769
+ const s = pt(), [l, o] = U([]), [c, d] = U(!0), [f, u] = U(null), m = e !== "output-available";
3746
3770
  return O(() => {
3747
3771
  async function N() {
3748
3772
  if (!s) {
@@ -3790,7 +3814,7 @@ function xs({
3790
3814
  }
3791
3815
  N();
3792
3816
  }, [s, t]), f ? /* @__PURE__ */ a("div", { className: "py-2 text-sm text-error-text", children: f }) : /* @__PURE__ */ a(
3793
- ys,
3817
+ vs,
3794
3818
  {
3795
3819
  products: l,
3796
3820
  onAddToCart: n,
@@ -3812,7 +3836,7 @@ function yr({
3812
3836
  onViewProduct: o
3813
3837
  }) {
3814
3838
  return e === or ? /* @__PURE__ */ a("div", { className: "mt-3", children: /* @__PURE__ */ a(
3815
- xs,
3839
+ bs,
3816
3840
  {
3817
3841
  toolInput: r,
3818
3842
  toolOutput: n,
@@ -3821,16 +3845,16 @@ function yr({
3821
3845
  onAddToCart: l,
3822
3846
  onViewProduct: o
3823
3847
  }
3824
- ) }) : e === ss ? /* @__PURE__ */ a(
3825
- ds,
3848
+ ) }) : e === os ? /* @__PURE__ */ a(
3849
+ fs,
3826
3850
  {
3827
3851
  toolCallId: t,
3828
3852
  toolInput: r,
3829
3853
  toolOutput: n,
3830
3854
  toolState: i ?? ""
3831
3855
  }
3832
- ) : e === as ? /* @__PURE__ */ a(
3833
- cs,
3856
+ ) : e === ls ? /* @__PURE__ */ a(
3857
+ ps,
3834
3858
  {
3835
3859
  toolCallId: t,
3836
3860
  toolInput: r,
@@ -3915,14 +3939,14 @@ function yr({
3915
3939
  }
3916
3940
  ) : null;
3917
3941
  }
3918
- function Cs({
3942
+ function Is({
3919
3943
  tools: t,
3920
3944
  messageId: e,
3921
3945
  cart: r,
3922
3946
  onAddToCart: n,
3923
3947
  onViewProduct: i
3924
3948
  }) {
3925
- const [s, l] = _(!1);
3949
+ const [s, l] = U(!1);
3926
3950
  return t.length === 0 ? null : /* @__PURE__ */ h("div", { children: [
3927
3951
  /* @__PURE__ */ h(
3928
3952
  "button",
@@ -3973,7 +3997,7 @@ function Cs({
3973
3997
  )
3974
3998
  ] });
3975
3999
  }
3976
- function vs({
4000
+ function ws({
3977
4001
  messageId: t,
3978
4002
  isLatestAssistantMessage: e,
3979
4003
  text: r
@@ -3983,7 +4007,7 @@ function vs({
3983
4007
  ), s = g(
3984
4008
  (o) => o.toggleMessageExpanded
3985
4009
  ), l = e || i.includes(t);
3986
- return e ? /* @__PURE__ */ a("div", { className: "my-2", children: /* @__PURE__ */ a(We, { className: "leading-relaxed text-text", plugins: {}, children: r }) }) : /* @__PURE__ */ h("div", { className: "", children: [
4010
+ return e ? /* @__PURE__ */ a("div", { className: "my-2", children: /* @__PURE__ */ a(Ve, { className: "leading-relaxed text-text", plugins: {}, children: r }) }) : /* @__PURE__ */ h("div", { className: "", children: [
3987
4011
  /* @__PURE__ */ h(
3988
4012
  "button",
3989
4013
  {
@@ -4012,7 +4036,7 @@ function vs({
4012
4036
  "data-testid": "collapsible-message-panel",
4013
4037
  className: `collapsible-panel ${l ? "collapsible-panel-open" : ""}`,
4014
4038
  children: /* @__PURE__ */ a("div", { className: "overflow-hidden", children: /* @__PURE__ */ a("div", { className: "pl-2.5 border-l border-gray-200 ml-[1px] my-2", children: /* @__PURE__ */ a(
4015
- We,
4039
+ Ve,
4016
4040
  {
4017
4041
  className: "text-xs leading-relaxed text-text",
4018
4042
  plugins: {},
@@ -4023,7 +4047,7 @@ function vs({
4023
4047
  )
4024
4048
  ] });
4025
4049
  }
4026
- function bs(t) {
4050
+ function Ss(t) {
4027
4051
  if (!t.parts)
4028
4052
  return [];
4029
4053
  const e = [];
@@ -4046,11 +4070,11 @@ function bs(t) {
4046
4070
  }
4047
4071
  return e;
4048
4072
  }
4049
- function Is(t) {
4073
+ function Ns(t) {
4050
4074
  const e = t?.find((r) => r.type === "file");
4051
4075
  return e && "filename" in e && typeof e.filename == "string" ? e.filename : "Attachment";
4052
4076
  }
4053
- function ws({
4077
+ function Ps({
4054
4078
  message: t,
4055
4079
  isFirstUserMessage: e,
4056
4080
  isLatestAssistantMessage: r,
@@ -4061,7 +4085,7 @@ function ws({
4061
4085
  onAddToCart: o,
4062
4086
  onViewProduct: c
4063
4087
  }) {
4064
- const d = t.role === "assistant", f = bs(t);
4088
+ const d = t.role === "assistant", f = Ss(t);
4065
4089
  return f.length === 0 ? null : /* @__PURE__ */ a(
4066
4090
  "div",
4067
4091
  {
@@ -4096,7 +4120,7 @@ function ws({
4096
4120
  }
4097
4121
  ),
4098
4122
  n && /* @__PURE__ */ a("div", { className: "mt-2 p-3 bg-surface border border-border rounded-lg max-h-96 overflow-y-auto", children: f.map((u, m) => u.type === "text" ? /* @__PURE__ */ a(
4099
- We,
4123
+ Ve,
4100
4124
  {
4101
4125
  className: "text-[0.875rem] leading-normal text-text",
4102
4126
  plugins: {},
@@ -4105,8 +4129,8 @@ function ws({
4105
4129
  `text-${t.id}-${m}`
4106
4130
  ) : null) })
4107
4131
  ] }) : /* @__PURE__ */ h(we, { children: [
4108
- ls(f).map((u, m) => u.type === "tool-group" ? /* @__PURE__ */ a(
4109
- Cs,
4132
+ us(f).map((u, m) => u.type === "tool-group" ? /* @__PURE__ */ a(
4133
+ Is,
4110
4134
  {
4111
4135
  tools: u.tools,
4112
4136
  messageId: `${t.id}-${m}`,
@@ -4116,7 +4140,7 @@ function ws({
4116
4140
  },
4117
4141
  `group-${t.id}-${m}`
4118
4142
  ) : u.type === "text" ? d ? /* @__PURE__ */ a(
4119
- vs,
4143
+ ws,
4120
4144
  {
4121
4145
  messageId: `${t.id}-${m}`,
4122
4146
  isLatestAssistantMessage: r,
@@ -4128,7 +4152,7 @@ function ws({
4128
4152
  {
4129
4153
  className: "rounded-2xl bg-surface-tertiary px-4 py-2.5",
4130
4154
  children: /* @__PURE__ */ a(
4131
- We,
4155
+ Ve,
4132
4156
  {
4133
4157
  className: "text-[0.9375rem] leading-relaxed text-text",
4134
4158
  plugins: {},
@@ -4152,14 +4176,14 @@ function ws({
4152
4176
  ) }, u.toolCallId) : null),
4153
4177
  !d && t.parts?.some((u) => u.type === "file") && /* @__PURE__ */ h("div", { className: "flex items-center gap-1.5 mt-2 text-xs text-text-tertiary", children: [
4154
4178
  /* @__PURE__ */ a(Tt, {}),
4155
- /* @__PURE__ */ a("span", { children: Is(t.parts) })
4179
+ /* @__PURE__ */ a("span", { children: Ns(t.parts) })
4156
4180
  ] })
4157
4181
  ] }) })
4158
4182
  }
4159
4183
  );
4160
4184
  }
4161
4185
  function xr() {
4162
- const [t, e] = _(!1);
4186
+ const [t, e] = U(!1);
4163
4187
  return O(() => {
4164
4188
  if (typeof window.matchMedia != "function") {
4165
4189
  e(
@@ -4190,7 +4214,7 @@ const Cr = () => /* @__PURE__ */ h(
4190
4214
  /* @__PURE__ */ a("polyline", { points: "9 15 12 12 15 15" })
4191
4215
  ]
4192
4216
  }
4193
- ), Ss = () => /* @__PURE__ */ h(
4217
+ ), Es = () => /* @__PURE__ */ h(
4194
4218
  "svg",
4195
4219
  {
4196
4220
  width: "16",
@@ -4216,13 +4240,13 @@ function vr({ onClick: t }) {
4216
4240
  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",
4217
4241
  onClick: t,
4218
4242
  children: [
4219
- /* @__PURE__ */ a(Ss, {}),
4243
+ /* @__PURE__ */ a(Es, {}),
4220
4244
  "Take a photo"
4221
4245
  ]
4222
4246
  }
4223
4247
  );
4224
4248
  }
4225
- function Ns({
4249
+ function ks({
4226
4250
  isDragging: t = !1,
4227
4251
  fileInputRef: e,
4228
4252
  cameraInputRef: r,
@@ -4273,7 +4297,7 @@ function Ns({
4273
4297
  ),
4274
4298
  /* @__PURE__ */ a("h3", { className: "m-0 text-base font-semibold text-text text-center", children: "Upload your Purchase Order" }),
4275
4299
  /* @__PURE__ */ a("p", { className: "m-0 text-sm text-text-tertiary text-center", children: "Get automagical product matching and stock availability" }),
4276
- /* @__PURE__ */ a("div", { className: "flex flex-wrap justify-center gap-2", children: Zt.map((c) => /* @__PURE__ */ a(
4300
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap justify-center gap-2", children: Xt.map((c) => /* @__PURE__ */ a(
4277
4301
  "span",
4278
4302
  {
4279
4303
  className: "py-1 px-3 bg-surface-invert/5 border border-border-strong rounded-full text-xs font-medium text-text",
@@ -4288,7 +4312,7 @@ function Ns({
4288
4312
  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 })
4289
4313
  ] }) });
4290
4314
  }
4291
- function Ps() {
4315
+ function Ts() {
4292
4316
  return /* @__PURE__ */ a("div", { className: "flex justify-start px-5 py-2", children: /* @__PURE__ */ h("div", { className: "flex flex-col gap-2 w-3/4", children: [
4293
4317
  /* @__PURE__ */ a("div", { className: "h-3 rounded-full animate-shimmer" }),
4294
4318
  /* @__PURE__ */ a(
@@ -4300,7 +4324,7 @@ function Ps() {
4300
4324
  )
4301
4325
  ] }) });
4302
4326
  }
4303
- const Es = Ar(
4327
+ const As = Ar(
4304
4328
  function({
4305
4329
  messages: e,
4306
4330
  input: r,
@@ -4317,7 +4341,7 @@ const Es = Ar(
4317
4341
  uploadedFileName: N = null,
4318
4342
  fileDrop: I
4319
4343
  }, x) {
4320
- const b = D(null), k = D(!0), [w, T] = _(!1), v = oe(() => {
4344
+ const b = D(null), k = D(!0), [w, T] = U(!1), v = oe(() => {
4321
4345
  for (let y = e.length - 1; y >= 0; y--) {
4322
4346
  const A = e[y];
4323
4347
  if (A?.role === "assistant")
@@ -4357,7 +4381,7 @@ const Es = Ar(
4357
4381
  className: "flex-1 min-h-0 overflow-y-auto py-3 flex flex-col",
4358
4382
  children: [
4359
4383
  e.length === 0 && !s && I && /* @__PURE__ */ a(
4360
- Ns,
4384
+ ks,
4361
4385
  {
4362
4386
  isDragging: I.isDragging,
4363
4387
  fileInputRef: I.fileInputRef,
@@ -4371,7 +4395,7 @@ const Es = Ar(
4371
4395
  e.map((y, A) => {
4372
4396
  const $ = m && y.role !== "assistant" && A === 0, F = y.role === "assistant" && y.id === v;
4373
4397
  return /* @__PURE__ */ a(
4374
- ws,
4398
+ Ps,
4375
4399
  {
4376
4400
  message: y,
4377
4401
  isFirstUserMessage: $,
@@ -4386,13 +4410,13 @@ const Es = Ar(
4386
4410
  y.id
4387
4411
  );
4388
4412
  }),
4389
- s && /* @__PURE__ */ a(Ps, {}),
4390
- /* @__PURE__ */ a(ts, { error: f, onRetry: u })
4413
+ s && /* @__PURE__ */ a(Ts, {}),
4414
+ /* @__PURE__ */ a(ss, { error: f, onRetry: u })
4391
4415
  ]
4392
4416
  }
4393
4417
  ),
4394
4418
  /* @__PURE__ */ a(
4395
- ns,
4419
+ is,
4396
4420
  {
4397
4421
  input: r,
4398
4422
  onInputChange: n,
@@ -4402,19 +4426,19 @@ const Es = Ar(
4402
4426
  )
4403
4427
  ] });
4404
4428
  }
4405
- ), ks = "purchase-order-chat-user-settings", Ts = 25, Bt = at()(
4406
- jt(
4429
+ ), $s = "purchase-order-chat-user-settings", Bs = 25, Bt = at()(
4430
+ Wt(
4407
4431
  (t) => ({
4408
- panelWidth: Ts,
4432
+ panelWidth: Bs,
4409
4433
  setPanelWidth: (e) => t({ panelWidth: e })
4410
4434
  }),
4411
4435
  {
4412
- name: ks
4436
+ name: $s
4413
4437
  }
4414
4438
  )
4415
4439
  );
4416
- function As() {
4417
- const t = Bt((m) => m.panelWidth), e = Bt((m) => m.setPanelWidth), [r, n] = _(
4440
+ function Ms() {
4441
+ const t = Bt((m) => m.panelWidth), e = Bt((m) => m.setPanelWidth), [r, n] = U(
4418
4442
  typeof window < "u" && window.innerWidth >= 1024
4419
4443
  ), i = D(null), s = D(!1), l = D(t);
4420
4444
  O(() => {
@@ -4467,7 +4491,7 @@ function As() {
4467
4491
  handleBlur: u
4468
4492
  };
4469
4493
  }
4470
- function $s({ activeTab: t, onTabChange: e, hasUnread: r }) {
4494
+ function Os({ activeTab: t, onTabChange: e, hasUnread: r }) {
4471
4495
  const n = r && t !== "chat";
4472
4496
  return /* @__PURE__ */ h("div", { className: "flex border-b border-border-strong shrink-0", role: "tablist", children: [
4473
4497
  /* @__PURE__ */ a(
@@ -4544,18 +4568,18 @@ function Mt({
4544
4568
  shipToAddress: se,
4545
4569
  billingAddress: Y,
4546
4570
  checkoutTotals: te,
4547
- isCartLoading: j,
4548
- poMetadataSet: W,
4571
+ isCartLoading: W,
4572
+ poMetadataSet: V,
4549
4573
  onNewOrder: ie,
4550
4574
  onExpand: ve,
4551
4575
  onMinimize: L,
4552
- className: V = ""
4576
+ className: j = ""
4553
4577
  }) {
4554
- const K = As(), [J, Pe] = _(
4578
+ const K = Ms(), [J, Pe] = U(
4555
4579
  u.length > 0 ? "cart" : "chat"
4556
- ), [he, me] = _(!1), ce = D(t.length), ge = D(J);
4580
+ ), [he, me] = U(!1), ce = D(t.length), ge = D(J);
4557
4581
  ge.current = J;
4558
- const p = t.length === 0 && u.length === 0 && !!f, S = Xt({
4582
+ const p = t.length === 0 && u.length === 0 && !!f, S = Zt({
4559
4583
  onFile: f ?? (() => {
4560
4584
  })
4561
4585
  });
@@ -4564,10 +4588,10 @@ function Mt({
4564
4588
  }, [t.length]), O(() => {
4565
4589
  K.isDesktop && me(!1);
4566
4590
  }, [K.isDesktop]);
4567
- const E = B((U) => {
4568
- Pe(U), U === "chat" && me(!1);
4591
+ const E = B((_) => {
4592
+ Pe(_), _ === "chat" && me(!1);
4569
4593
  }, []), P = /* @__PURE__ */ a(
4570
- Es,
4594
+ As,
4571
4595
  {
4572
4596
  ref: d,
4573
4597
  messages: t,
@@ -4585,7 +4609,7 @@ function Mt({
4585
4609
  fileDrop: f ? S : void 0
4586
4610
  }
4587
4611
  ), M = /* @__PURE__ */ a(
4588
- Zn,
4612
+ ts,
4589
4613
  {
4590
4614
  items: u,
4591
4615
  itemWarnings: m,
@@ -4608,8 +4632,8 @@ function Mt({
4608
4632
  shipToAddress: se ?? void 0,
4609
4633
  billingAddress: Y ?? void 0,
4610
4634
  checkoutTotals: te ?? void 0,
4611
- isLoading: j,
4612
- poMetadataSet: W,
4635
+ isLoading: W,
4636
+ poMetadataSet: V,
4613
4637
  isDragging: p && S.isDragging,
4614
4638
  onNewOrder: ie,
4615
4639
  onExpand: ve,
@@ -4623,7 +4647,7 @@ function Mt({
4623
4647
  "div",
4624
4648
  {
4625
4649
  ref: K.containerRef,
4626
- className: `flex flex-row h-full ${V}`,
4650
+ className: `flex flex-row h-full ${j}`,
4627
4651
  ...R,
4628
4652
  children: [
4629
4653
  /* @__PURE__ */ a(
@@ -4668,11 +4692,11 @@ function Mt({
4668
4692
  "div",
4669
4693
  {
4670
4694
  ref: K.containerRef,
4671
- className: `flex flex-col h-full min-h-0 border border-solid border-border-strong rounded-md overflow-hidden ${V}`,
4695
+ className: `flex flex-col h-full min-h-0 border border-solid border-border-strong rounded-md overflow-hidden ${j}`,
4672
4696
  ...R,
4673
4697
  children: [
4674
4698
  /* @__PURE__ */ a(
4675
- $s,
4699
+ Os,
4676
4700
  {
4677
4701
  activeTab: J,
4678
4702
  onTabChange: E,
@@ -4694,10 +4718,10 @@ function Mt({
4694
4718
  )
4695
4719
  );
4696
4720
  }
4697
- function Bs() {
4721
+ function Fs() {
4698
4722
  const t = pt(), e = g((o) => o.ui.existingCart), r = g(
4699
4723
  (o) => o.confirmClearExistingCart
4700
- ), [n, i] = _(!1), s = oe(
4724
+ ), [n, i] = U(!1), s = oe(
4701
4725
  () => e?.lineItems.physicalItems.reduce(
4702
4726
  (o, c) => o + c.quantity,
4703
4727
  0
@@ -4723,14 +4747,14 @@ function Bs() {
4723
4747
  disabled: n,
4724
4748
  className: "bg-surface-invert shadow-button transition-all duration-200 ease-in-out hover:bg-surface-invert-hover hover:shadow-button-hover hover:-translate-y-px px-4 py-2 text-text-invert rounded-full font-medium cursor-pointer disabled:opacity-50 disabled:pointer-events-none",
4725
4749
  children: n ? /* @__PURE__ */ h("span", { className: "flex items-center gap-2", children: [
4726
- /* @__PURE__ */ a(Ue, { size: 14 }),
4750
+ /* @__PURE__ */ a(_e, { size: 14 }),
4727
4751
  "Clearing cart…"
4728
4752
  ] }) : "Clear Cart & Continue"
4729
4753
  }
4730
4754
  )
4731
4755
  ] }) });
4732
4756
  }
4733
- function Ms({ message: t }) {
4757
+ function Rs({ message: t }) {
4734
4758
  return /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full w-full bg-surface-secondary", children: /* @__PURE__ */ h("div", { className: "text-center max-w-md px-4", children: [
4735
4759
  /* @__PURE__ */ a("p", { className: "text-lg text-text-secondary mb-2", children: "Something went wrong" }),
4736
4760
  /* @__PURE__ */ a("p", { className: "text-sm text-text-tertiary mb-6", children: t || "An unexpected error occurred. Please refresh the page to try again." }),
@@ -4755,19 +4779,19 @@ function br() {
4755
4779
  );
4756
4780
  return oe(() => t !== "processing" ? null : e ? r === "idle" || r === "processing" ? "matching" : "building" : "reading", [t, e, r]);
4757
4781
  }
4758
- const Os = [
4782
+ const Ds = [
4759
4783
  { label: "Upload", number: 1 },
4760
4784
  { label: "Analyze", number: 2 },
4761
4785
  { label: "Checkout", number: 3 }
4762
4786
  ];
4763
- function Fs(t = {}) {
4764
- return /* @__PURE__ */ a("div", { className: "flex items-center justify-center gap-0 p-4 md:py-1 md:px-0", children: Os.map((e, r) => /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
4787
+ function Ls(t = {}) {
4788
+ return /* @__PURE__ */ a("div", { className: "flex items-center justify-center gap-0 p-4 md:py-1 md:px-0", children: Ds.map((e, r) => /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
4765
4789
  r > 0 && /* @__PURE__ */ a("div", { className: "w-6 md:w-10 h-px mx-2 md:mx-3 rounded-[1px] bg-border" }),
4766
4790
  /* @__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-[0.6875rem] font-medium", children: e.number }) }),
4767
4791
  /* @__PURE__ */ a("span", { className: "text-s font-normal whitespace-nowrap text-text-quaternary", children: e.label })
4768
4792
  ] }, e.label)) });
4769
4793
  }
4770
- function Rs({
4794
+ function _s({
4771
4795
  isDragging: t,
4772
4796
  fileInputRef: e,
4773
4797
  cameraInputRef: r,
@@ -4815,7 +4839,7 @@ function Rs({
4815
4839
  ),
4816
4840
  /* @__PURE__ */ a("h2", { className: "m-0 text-2xl max-md:text-xl font-semibold text-text text-center", children: "Upload your Purchase Order" }),
4817
4841
  /* @__PURE__ */ a("p", { className: "m-0 text-[15px] text-text-tertiary text-center", children: "Get automagical product matching and stock availability" }),
4818
- /* @__PURE__ */ a("div", { className: "flex flex-wrap justify-center gap-2 mt-2", children: Zt.map((l) => /* @__PURE__ */ a(
4842
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap justify-center gap-2 mt-2", children: Xt.map((l) => /* @__PURE__ */ a(
4819
4843
  "span",
4820
4844
  {
4821
4845
  className: "py-1 px-3 bg-surface-invert/5 border border-border-strong rounded-full text-xs font-medium text-text backdrop-blur",
@@ -4827,7 +4851,7 @@ function Rs({
4827
4851
  }
4828
4852
  );
4829
4853
  }
4830
- function Ds({
4854
+ function Us({
4831
4855
  isDragging: t,
4832
4856
  fileInputRef: e,
4833
4857
  acceptedExtensions: r,
@@ -4847,9 +4871,9 @@ function Ds({
4847
4871
  t && "ring-2 ring-border-focus border-border-focus bg-surface-tertiary shadow-upload-active"
4848
4872
  ),
4849
4873
  children: [
4850
- /* @__PURE__ */ a("div", { className: "upload-zone-steps mb-3 py-4 px-8 border-b border-solid border-border-strong", children: /* @__PURE__ */ a(Fs, {}) }),
4874
+ /* @__PURE__ */ a("div", { className: "upload-zone-steps mb-3 py-4 px-8 border-b border-solid border-border-strong", children: /* @__PURE__ */ a(Ls, {}) }),
4851
4875
  /* @__PURE__ */ a(
4852
- Rs,
4876
+ _s,
4853
4877
  {
4854
4878
  isDragging: t,
4855
4879
  fileInputRef: e,
@@ -4875,7 +4899,7 @@ function Ds({
4875
4899
  }
4876
4900
  );
4877
4901
  }
4878
- function Ls({
4902
+ function qs({
4879
4903
  items: t,
4880
4904
  orderId: e,
4881
4905
  parsedContent: r,
@@ -4967,11 +4991,11 @@ function Ls({
4967
4991
  ] })
4968
4992
  ] });
4969
4993
  }
4970
- const Us = 3e3, Ot = 200;
4971
- function _s(t) {
4972
- return t <= 0 ? Ot : Math.max(Ot, Math.round(Us / t));
4994
+ const js = 3e3, Ot = 200;
4995
+ function Ws(t) {
4996
+ return t <= 0 ? Ot : Math.max(Ot, Math.round(js / t));
4973
4997
  }
4974
- function qs() {
4998
+ function Vs() {
4975
4999
  const t = g(
4976
5000
  (l) => l.batchProcessing.toolCalls
4977
5001
  ), r = g(
@@ -4980,10 +5004,10 @@ function qs() {
4980
5004
  if (o.toolName !== Be) return l;
4981
5005
  const c = o.input;
4982
5006
  return c && typeof c == "object" && "value" in c && Array.isArray(c.value) ? l + c.value.length : l;
4983
- }, 0), [i, s] = _(0);
5007
+ }, 0), [i, s] = U(0);
4984
5008
  return O(() => {
4985
5009
  if (!r || n === 0 || i >= n) return;
4986
- const l = _s(n), o = setTimeout(() => {
5010
+ const l = Ws(n), o = setTimeout(() => {
4987
5011
  s((c) => Math.min(c + 1, n));
4988
5012
  }, l);
4989
5013
  return () => clearTimeout(o);
@@ -4993,8 +5017,8 @@ function qs() {
4993
5017
  isRevealing: n > 0 && i < n
4994
5018
  };
4995
5019
  }
4996
- const Vs = 1e3;
4997
- function js() {
5020
+ const zs = 1e3;
5021
+ function Qs() {
4998
5022
  const t = g(
4999
5023
  (s) => s.batchProcessing.toolCalls
5000
5024
  ), e = g(
@@ -5005,7 +5029,7 @@ function js() {
5005
5029
  O(() => {
5006
5030
  if (e >= t.length)
5007
5031
  return;
5008
- const s = setTimeout(r, Vs);
5032
+ const s = setTimeout(r, zs);
5009
5033
  return () => clearTimeout(s);
5010
5034
  }, [t.length, e, r]);
5011
5035
  const n = t.slice(0, e);
@@ -5016,22 +5040,22 @@ function js() {
5016
5040
  };
5017
5041
  }
5018
5042
  const Ft = ["reading", "matching", "building"];
5019
- function Ws(t, e) {
5043
+ function Hs(t, e) {
5020
5044
  if (!e) return "pending";
5021
5045
  const r = Ft.indexOf(e), n = Ft.indexOf(t);
5022
5046
  return n < r ? "complete" : n === r ? "active" : "pending";
5023
5047
  }
5024
- function zs(t, e) {
5048
+ function Gs(t, e) {
5025
5049
  return t.length >= 2 && e !== "submitted" && e !== "streaming";
5026
5050
  }
5027
- function Qs(t) {
5051
+ function Ks(t) {
5028
5052
  if (t === void 0) return null;
5029
5053
  const e = ut(t);
5030
5054
  if (e === void 0) return null;
5031
5055
  const r = Je(e, "data.searchProductsBySku") ?? Je(e, "data.searchProducts");
5032
5056
  return Je(r, "total", 0);
5033
5057
  }
5034
- const Hs = {
5058
+ const Js = {
5035
5059
  searchProductsBySku: (t, { resultCount: e }) => {
5036
5060
  const r = t.sku ?? "";
5037
5061
  return e === null ? `Looking up SKU ${r}` : /* @__PURE__ */ h(we, { children: [
@@ -5060,14 +5084,14 @@ const Hs = {
5060
5084
  ] });
5061
5085
  }
5062
5086
  };
5063
- function Gs(t, e) {
5064
- const r = Hs[t.toolName];
5087
+ function Ys(t, e) {
5088
+ const r = Js[t.toolName];
5065
5089
  return r ? r(t.input, {
5066
5090
  visibleToolCalls: e,
5067
- resultCount: Qs(t.output)
5091
+ resultCount: Ks(t.output)
5068
5092
  }) : null;
5069
5093
  }
5070
- const Ks = [
5094
+ const Xs = [
5071
5095
  { id: "reading", label: "Reading document..." },
5072
5096
  { id: "matching", label: "Matching products..." },
5073
5097
  { id: "building", label: "Building cart..." }
@@ -5085,14 +5109,14 @@ const Ks = [
5085
5109
  icon: "bg-surface border-2 border-success text-success"
5086
5110
  }
5087
5111
  };
5088
- function Js({
5112
+ function Zs({
5089
5113
  currentStep: t
5090
5114
  }) {
5091
- const { currentToolCall: e, visibleToolCalls: r } = js(), { revealedCount: n, totalItems: i } = qs(), s = g(
5115
+ const { currentToolCall: e, visibleToolCalls: r } = Qs(), { revealedCount: n, totalItems: i } = Vs(), s = g(
5092
5116
  (l) => l.parser.uploadedFileName
5093
5117
  );
5094
- return /* @__PURE__ */ a("div", { className: "flex flex-col gap-6 w-64", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-6", children: Ks.map((l) => {
5095
- const o = Ws(l.id, t), c = l.id === "reading" && (o === "active" || o === "complete") && s ? s : null, d = l.id === "matching" && o === "active" && e ? Gs(e, r) : null, f = l.id === "building" && o === "active" && i > 0 ? n >= i ? `Added ${i} item${i !== 1 ? "s" : ""}` : `Adding item ${n + 1} of ${i}...` : null;
5118
+ return /* @__PURE__ */ a("div", { className: "flex flex-col gap-6 w-64", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-6", children: Xs.map((l) => {
5119
+ const o = Hs(l.id, t), c = l.id === "reading" && (o === "active" || o === "complete") && s ? s : null, d = l.id === "matching" && o === "active" && e ? Ys(e, r) : null, f = l.id === "building" && o === "active" && i > 0 ? n >= i ? `Added ${i} item${i !== 1 ? "s" : ""}` : `Adding item ${n + 1} of ${i}...` : null;
5096
5120
  return /* @__PURE__ */ h(
5097
5121
  "div",
5098
5122
  {
@@ -5106,7 +5130,7 @@ function Js({
5106
5130
  className: `flex items-center justify-center w-8 h-8 rounded-full shrink-0 transition-all duration-300 ${Rt[o].icon}${o === "complete" ? " animate-step-pulse" : ""}${o === "active" ? " bg-surface-invert shadow-step" : ""}`,
5107
5131
  children: [
5108
5132
  o === "complete" && /* @__PURE__ */ a(Le, { size: 16, title: "Complete" }),
5109
- o === "active" && /* @__PURE__ */ a(Ue, { size: 16 }),
5133
+ o === "active" && /* @__PURE__ */ a(_e, { size: 16 }),
5110
5134
  o === "pending" && /* @__PURE__ */ a("div", { className: "w-2 h-2 rounded-full bg-border-strong" })
5111
5135
  ]
5112
5136
  }
@@ -5143,7 +5167,7 @@ function Js({
5143
5167
  );
5144
5168
  }) }) });
5145
5169
  }
5146
- function Ys({
5170
+ function ea({
5147
5171
  cartItems: t,
5148
5172
  isUploading: e = !1
5149
5173
  }) {
@@ -5151,9 +5175,9 @@ function Ys({
5151
5175
  (s) => s.parser.parsedContent
5152
5176
  );
5153
5177
  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__ */ h("div", { className: "flex w-full justify-center gap-32 max-md:flex-col max-md:gap-8", children: [
5154
- /* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center", children: /* @__PURE__ */ a(Js, { currentStep: r }) }),
5178
+ /* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center", children: /* @__PURE__ */ a(Zs, { currentStep: r }) }),
5155
5179
  /* @__PURE__ */ a("div", { className: "shrink-0 flex items-center justify-center min-w-80", children: /* @__PURE__ */ a(
5156
- Ls,
5180
+ qs,
5157
5181
  {
5158
5182
  items: t,
5159
5183
  orderId: n,
@@ -5164,7 +5188,7 @@ function Ys({
5164
5188
  ) })
5165
5189
  ] }) });
5166
5190
  }
5167
- function Zs({
5191
+ function ta({
5168
5192
  onFileUpload: t,
5169
5193
  onSkip: e,
5170
5194
  onClearError: r,
@@ -5172,7 +5196,7 @@ function Zs({
5172
5196
  isUploading: i = !1,
5173
5197
  parserError: s = null
5174
5198
  }) {
5175
- const o = br() !== null, c = Xt({
5199
+ const o = br() !== null, c = Zt({
5176
5200
  onFile: t,
5177
5201
  onBeforeValidate: r
5178
5202
  }), d = s || c.fileError, f = B(() => {
@@ -5183,8 +5207,8 @@ function Zs({
5183
5207
  {
5184
5208
  className: `upload-step flex flex-col w-full flex-1 min-h-0 ${c.isDragging ? "upload-step-dragging" : ""} ${o ? "upload-step-processing" : ""}`,
5185
5209
  ...c.dragProps,
5186
- children: /* @__PURE__ */ a("div", { className: "upload-step-content animate-fade-in-up flex-1 flex items-center justify-center min-h-0 relative", children: o ? /* @__PURE__ */ a(Ys, { cartItems: n, isUploading: i }) : /* @__PURE__ */ a(
5187
- Ds,
5210
+ children: /* @__PURE__ */ a("div", { className: "upload-step-content animate-fade-in-up flex-1 flex items-center justify-center min-h-0 relative", children: o ? /* @__PURE__ */ a(ea, { cartItems: n, isUploading: i }) : /* @__PURE__ */ a(
5211
+ Us,
5188
5212
  {
5189
5213
  isDragging: c.isDragging,
5190
5214
  fileInputRef: c.fileInputRef,
@@ -5220,21 +5244,21 @@ function Dt(t, e) {
5220
5244
  function Ir(t, e) {
5221
5245
  return t !== void 0 && Math.abs(t - e) > 0.01;
5222
5246
  }
5223
- function Xs(t, e) {
5247
+ function ra(t, e) {
5224
5248
  const r = [...t];
5225
5249
  for (const n of e) {
5226
5250
  const i = r.findIndex(
5227
- (s) => s.productEntityId === n.productEntityId && s.productVariantEntityId === n.productVariantEntityId
5251
+ (s) => s.productEntityId === n.productEntityId && s.variantEntityId === n.variantEntityId
5228
5252
  );
5229
5253
  i >= 0 ? r[i] = n : r.push(n);
5230
5254
  }
5231
5255
  return r;
5232
5256
  }
5233
- function ea(t, e) {
5257
+ function na(t, e) {
5234
5258
  const r = [], n = [];
5235
5259
  for (const i of e) {
5236
5260
  const s = t.find(
5237
- (l) => l.productEntityId === i.productEntityId && l.variantEntityId === i.productVariantEntityId
5261
+ (l) => l.productEntityId === i.productEntityId && l.variantEntityId === i.variantEntityId
5238
5262
  );
5239
5263
  s ? s.quantity !== i.quantity && n.push({
5240
5264
  lineItemEntityId: s.entityId,
@@ -5245,11 +5269,11 @@ function ea(t, e) {
5245
5269
  }
5246
5270
  return { toAdd: r, toUpdate: n };
5247
5271
  }
5248
- function ta(t, e) {
5272
+ function sa(t, e) {
5249
5273
  const r = [];
5250
5274
  for (const n of t.lineItems.physicalItems) {
5251
5275
  const i = e.find(
5252
- (c) => c.productEntityId === n.productEntityId && c.productVariantEntityId === n.variantEntityId
5276
+ (c) => c.productEntityId === n.productEntityId && c.variantEntityId === n.variantEntityId
5253
5277
  ), s = i?.poPriceValue, l = n.listPrice.value, o = Ir(s, l);
5254
5278
  r.push({
5255
5279
  id: n.entityId,
@@ -5274,14 +5298,14 @@ function Qe(t) {
5274
5298
  function He(t) {
5275
5299
  return t.toLowerCase();
5276
5300
  }
5277
- function ra(t, e) {
5301
+ function aa(t, e) {
5278
5302
  return t.filter(
5279
5303
  (r) => !e.some(
5280
5304
  (n) => r.productSku && n.sku && Qe(r.productSku) === Qe(n.sku) || r.productName && n.name && He(r.productName) === He(n.name)
5281
5305
  )
5282
5306
  );
5283
5307
  }
5284
- function na(t) {
5308
+ function ia(t) {
5285
5309
  const { client: e, onError: r } = t, n = D(e), i = D(r);
5286
5310
  i.current = r;
5287
5311
  const s = g((p) => p.bcSession.bcCart), l = g((p) => p.bcSession.checkout), o = g(
@@ -5320,7 +5344,7 @@ function na(t) {
5320
5344
  const S = `${p.productEntityId}-${p.variantEntityId}`, E = N[S];
5321
5345
  return {
5322
5346
  productEntityId: p.productEntityId,
5323
- productVariantEntityId: p.variantEntityId ?? void 0,
5347
+ variantEntityId: p.variantEntityId ?? void 0,
5324
5348
  quantity: p.quantity,
5325
5349
  poPriceValue: E?.poPrice,
5326
5350
  poPriceCurrencyCode: E?.poCurrency
@@ -5385,8 +5409,8 @@ function na(t) {
5385
5409
  n.current.getProductPaths(S).then((E) => {
5386
5410
  if (E.size > 0) {
5387
5411
  const P = {};
5388
- for (const [R, U] of E)
5389
- P[R] = U;
5412
+ for (const [R, _] of E)
5413
+ P[R] = _;
5390
5414
  const M = g.getState().bcSession.productPaths;
5391
5415
  T({ ...M, ...P });
5392
5416
  }
@@ -5463,9 +5487,9 @@ function na(t) {
5463
5487
  y,
5464
5488
  se
5465
5489
  ]);
5466
- const j = D(void 0), W = D(void 0), ie = oe(() => s ? s.lineItems.physicalItems.map((p) => {
5490
+ const W = D(void 0), V = D(void 0), ie = oe(() => s ? s.lineItems.physicalItems.map((p) => {
5467
5491
  const S = z.find(
5468
- (R) => R.productEntityId === p.productEntityId && R.productVariantEntityId === p.variantEntityId
5492
+ (R) => R.productEntityId === p.productEntityId && R.variantEntityId === p.variantEntityId
5469
5493
  ), E = S?.poPriceValue, P = p.listPrice.value, M = Ir(E, P);
5470
5494
  return {
5471
5495
  id: p.entityId,
@@ -5512,50 +5536,50 @@ function na(t) {
5512
5536
  v,
5513
5537
  ee
5514
5538
  ]
5515
- ), V = B(
5539
+ ), j = B(
5516
5540
  async (p) => {
5517
5541
  if (!n.current) return { cart: null, cartItems: [], errors: [] };
5518
5542
  if (p.length === 0)
5519
5543
  return { cart: s, cartItems: [], errors: [] };
5520
5544
  w(!0);
5521
5545
  try {
5522
- const S = Xs(z, p), E = await n.current.getCart();
5546
+ const S = ra(z, p), E = await n.current.getCart();
5523
5547
  let P = null;
5524
5548
  const M = [];
5525
5549
  if (E) {
5526
- const { toAdd: G, toUpdate: le } = ea(
5550
+ const { toAdd: G, toUpdate: le } = na(
5527
5551
  E.lineItems.physicalItems,
5528
5552
  p
5529
5553
  );
5530
5554
  if (P = E, G.length > 0) {
5531
- const Z = G.map((de) => ({
5555
+ const X = G.map((de) => ({
5532
5556
  productEntityId: de.productEntityId,
5533
- variantEntityId: de.productVariantEntityId,
5557
+ variantEntityId: de.variantEntityId,
5534
5558
  quantity: de.quantity
5535
- })), { cart: X, errors: ye } = await n.current.addCartLineItems(
5559
+ })), { cart: Z, errors: ye } = await n.current.addCartLineItems(
5536
5560
  E.entityId,
5537
- Z
5561
+ X
5538
5562
  );
5539
- X && (P = X), M.push(...ye);
5563
+ Z && (P = Z), M.push(...ye);
5540
5564
  }
5541
- for (const Z of le)
5565
+ for (const X of le)
5542
5566
  P = await n.current.updateCartLineItem(
5543
5567
  E.entityId,
5544
- Z.lineItemEntityId,
5545
- Z.newQuantity,
5546
- Z.productEntityId,
5547
- Z.variantEntityId
5568
+ X.lineItemEntityId,
5569
+ X.newQuantity,
5570
+ X.productEntityId,
5571
+ X.variantEntityId
5548
5572
  ) ?? P;
5549
5573
  (G.length > 0 || le.length > 0) && await L(P);
5550
5574
  } else {
5551
- const G = p.map((X) => ({
5552
- productEntityId: X.productEntityId,
5553
- variantEntityId: X.productVariantEntityId,
5554
- quantity: X.quantity
5555
- })), { cart: le, errors: Z } = await n.current.createCart(G);
5556
- if (P = le, M.push(...Z), P) {
5557
- const X = g.getState().chat.threadId;
5558
- X && n.current.createCartMetafield(P.entityId, "thread_id", X).catch((ye) => {
5575
+ const G = p.map((Z) => ({
5576
+ productEntityId: Z.productEntityId,
5577
+ variantEntityId: Z.variantEntityId,
5578
+ quantity: Z.quantity
5579
+ })), { cart: le, errors: X } = await n.current.createCart(G);
5580
+ if (P = le, M.push(...X), P) {
5581
+ const Z = g.getState().chat.threadId;
5582
+ Z && n.current.createCartMetafield(P.entityId, "thread_id", Z).catch((ye) => {
5559
5583
  console.warn(
5560
5584
  "[useBigCommerceCart] Failed to set thread_id metafield:",
5561
5585
  ye
@@ -5569,19 +5593,19 @@ function na(t) {
5569
5593
  for (const G of S)
5570
5594
  G.poPriceValue !== void 0 && G.poPriceCurrencyCode !== void 0 && R.setPoItemPrice(
5571
5595
  G.productEntityId,
5572
- G.productVariantEntityId,
5596
+ G.variantEntityId,
5573
5597
  G.poPriceValue,
5574
5598
  G.poPriceCurrencyCode
5575
5599
  );
5576
5600
  if (P) {
5577
5601
  const G = new Set(
5578
5602
  P.lineItems.physicalItems.map(
5579
- (Z) => `${Z.productEntityId}-${Z.variantEntityId}`
5603
+ (X) => `${X.productEntityId}-${X.variantEntityId}`
5580
5604
  )
5581
5605
  ), le = Object.keys(R.cartifact.poItemPrices);
5582
- for (const Z of le)
5583
- if (!G.has(Z)) {
5584
- const X = Z.split("-"), ye = Number(X[0]), de = Number(X[1]);
5606
+ for (const X of le)
5607
+ if (!G.has(X)) {
5608
+ const Z = X.split("-"), ye = Number(Z[0]), de = Number(Z[1]);
5585
5609
  !Number.isNaN(ye) && !Number.isNaN(de) && R.removePoItemPrice(ye, de);
5586
5610
  }
5587
5611
  }
@@ -5596,14 +5620,14 @@ function na(t) {
5596
5620
  }
5597
5621
  if (!P)
5598
5622
  return { cart: null, cartItems: [], errors: M };
5599
- const { cartItems: U } = ta(
5623
+ const { cartItems: _ } = sa(
5600
5624
  P,
5601
5625
  S
5602
- ), _e = g.getState().cartifact.itemWarnings, Me = ra(
5603
- _e,
5604
- U
5626
+ ), Ue = g.getState().cartifact.itemWarnings, Me = aa(
5627
+ Ue,
5628
+ _
5605
5629
  );
5606
- return Me.length !== _e.length && H(Me), { cart: P, cartItems: U, errors: M };
5630
+ return Me.length !== Ue.length && H(Me), { cart: P, cartItems: _, errors: M };
5607
5631
  } finally {
5608
5632
  w(!1);
5609
5633
  }
@@ -5625,29 +5649,29 @@ function na(t) {
5625
5649
  const S = [];
5626
5650
  for (const M of p) {
5627
5651
  const R = S.findIndex(
5628
- (U) => U.productEntityId === M.productEntityId && U.productVariantEntityId === M.productVariantEntityId
5652
+ (_) => _.productEntityId === M.productEntityId && _.variantEntityId === M.variantEntityId
5629
5653
  );
5630
5654
  if (R >= 0) {
5631
- const U = S[R];
5632
- U && (U.quantity += M.quantity, M.poPriceValue !== void 0 && M.poPriceCurrencyCode !== void 0 && (U.poPriceValue = M.poPriceValue, U.poPriceCurrencyCode = M.poPriceCurrencyCode));
5655
+ const _ = S[R];
5656
+ _ && (_.quantity += M.quantity, M.poPriceValue !== void 0 && M.poPriceCurrencyCode !== void 0 && (_.poPriceValue = M.poPriceValue, _.poPriceCurrencyCode = M.poPriceCurrencyCode));
5633
5657
  } else
5634
5658
  S.push({ ...M });
5635
5659
  }
5636
5660
  const E = [...z];
5637
5661
  for (const M of S) {
5638
5662
  const R = E.findIndex(
5639
- (U) => U.productEntityId === M.productEntityId && U.productVariantEntityId === M.productVariantEntityId
5663
+ (_) => _.productEntityId === M.productEntityId && _.variantEntityId === M.variantEntityId
5640
5664
  );
5641
5665
  if (R >= 0) {
5642
- const U = E[R];
5643
- U && (U.quantity += M.quantity, M.poPriceValue !== void 0 && M.poPriceCurrencyCode !== void 0 && (U.poPriceValue = M.poPriceValue, U.poPriceCurrencyCode = M.poPriceCurrencyCode));
5666
+ const _ = E[R];
5667
+ _ && (_.quantity += M.quantity, M.poPriceValue !== void 0 && M.poPriceCurrencyCode !== void 0 && (_.poPriceValue = M.poPriceValue, _.poPriceCurrencyCode = M.poPriceCurrencyCode));
5644
5668
  } else
5645
5669
  E.push(M);
5646
5670
  }
5647
- const { errors: P } = await V(E);
5671
+ const { errors: P } = await j(E);
5648
5672
  return { errors: P };
5649
5673
  },
5650
- [V, z]
5674
+ [j, z]
5651
5675
  ), J = B(
5652
5676
  async (p, S, E, P) => {
5653
5677
  if (!n.current || !s?.entityId)
@@ -5691,13 +5715,13 @@ function na(t) {
5691
5715
  if (S) {
5692
5716
  const P = S.lineItems.physicalItems, M = z.filter(
5693
5717
  (R) => !P.some(
5694
- (U) => U.productEntityId === R.productEntityId && U.variantEntityId === R.productVariantEntityId
5718
+ (_) => _.productEntityId === R.productEntityId && _.variantEntityId === R.variantEntityId
5695
5719
  )
5696
5720
  );
5697
5721
  for (const R of M)
5698
5722
  E.removePoItemPrice(
5699
5723
  R.productEntityId,
5700
- R.productVariantEntityId
5724
+ R.variantEntityId
5701
5725
  );
5702
5726
  await L(S);
5703
5727
  } else
@@ -5787,14 +5811,14 @@ function na(t) {
5787
5811
  S,
5788
5812
  E
5789
5813
  );
5790
- P && x(P), b(p), k("success"), j.current !== void 0 && clearTimeout(j.current), j.current = window.setTimeout(() => {
5791
- k("idle"), j.current = void 0;
5814
+ P && x(P), b(p), k("success"), W.current !== void 0 && clearTimeout(W.current), W.current = window.setTimeout(() => {
5815
+ k("idle"), W.current = void 0;
5792
5816
  }, 1500);
5793
5817
  } catch (P) {
5794
5818
  console.error("setShippingAddressOnCheckout: API error", P), k("error"), i.current?.(
5795
5819
  P instanceof Error ? P : new Error("Failed to set shipping address")
5796
- ), j.current !== void 0 && clearTimeout(j.current), j.current = window.setTimeout(() => {
5797
- k("idle"), j.current = void 0;
5820
+ ), W.current !== void 0 && clearTimeout(W.current), W.current = window.setTimeout(() => {
5821
+ k("idle"), W.current = void 0;
5798
5822
  }, 3e3);
5799
5823
  } finally {
5800
5824
  w(!1);
@@ -5831,14 +5855,14 @@ function na(t) {
5831
5855
  s.entityId,
5832
5856
  S
5833
5857
  );
5834
- E && x(E), F(p), Q("success"), W.current !== void 0 && clearTimeout(W.current), W.current = window.setTimeout(() => {
5835
- Q("idle"), W.current = void 0;
5858
+ E && x(E), F(p), Q("success"), V.current !== void 0 && clearTimeout(V.current), V.current = window.setTimeout(() => {
5859
+ Q("idle"), V.current = void 0;
5836
5860
  }, 1500);
5837
5861
  } catch (E) {
5838
5862
  Q("error"), i.current?.(
5839
5863
  E instanceof Error ? E : new Error("Failed to set billing address")
5840
- ), W.current !== void 0 && clearTimeout(W.current), W.current = window.setTimeout(() => {
5841
- Q("idle"), W.current = void 0;
5864
+ ), V.current !== void 0 && clearTimeout(V.current), V.current = window.setTimeout(() => {
5865
+ Q("idle"), V.current = void 0;
5842
5866
  }, 3e3);
5843
5867
  } finally {
5844
5868
  w(!1);
@@ -5860,7 +5884,7 @@ function na(t) {
5860
5884
  await n.current.deleteCart(s.entityId);
5861
5885
  } catch {
5862
5886
  }
5863
- j.current !== void 0 && (clearTimeout(j.current), j.current = void 0), W.current !== void 0 && (clearTimeout(W.current), W.current = void 0), I(null), x(null);
5887
+ W.current !== void 0 && (clearTimeout(W.current), W.current = void 0), V.current !== void 0 && (clearTimeout(V.current), V.current = void 0), I(null), x(null);
5864
5888
  const p = g.getState();
5865
5889
  p.setCartEntityId(null), p.clearPoItemPrices();
5866
5890
  }, [s?.entityId, I, x]);
@@ -5887,7 +5911,7 @@ function na(t) {
5887
5911
  setSelectedBillingAddressId: F
5888
5912
  };
5889
5913
  }
5890
- function sa({
5914
+ function oa({
5891
5915
  bcCart: t,
5892
5916
  cartItems: e,
5893
5917
  onCheckoutInitiated: r,
@@ -5931,7 +5955,7 @@ function sa({
5931
5955
  return await t.addToCart([
5932
5956
  {
5933
5957
  productEntityId: I,
5934
- productVariantEntityId: x,
5958
+ variantEntityId: x,
5935
5959
  quantity: b
5936
5960
  }
5937
5961
  ]), !0;
@@ -5962,7 +5986,7 @@ function sa({
5962
5986
  handleShowMoreLikeThis: f
5963
5987
  };
5964
5988
  }
5965
- async function aa(t, e) {
5989
+ async function la(t, e) {
5966
5990
  if (!t.body)
5967
5991
  throw new Error("No response body");
5968
5992
  const r = [], n = /* @__PURE__ */ new Set(), i = [];
@@ -6015,7 +6039,7 @@ async function aa(t, e) {
6015
6039
  errorMessage: l
6016
6040
  };
6017
6041
  }
6018
- const ia = yt.object({
6042
+ const ca = yt.object({
6019
6043
  id: yt.string()
6020
6044
  });
6021
6045
  async function wr(t, e) {
@@ -6037,9 +6061,9 @@ async function wr(t, e) {
6037
6061
  );
6038
6062
  }
6039
6063
  const l = await s.json();
6040
- return ia.parse(l).id;
6064
+ return ca.parse(l).id;
6041
6065
  }
6042
- async function oa(t, e, r, n) {
6066
+ async function da(t, e, r, n) {
6043
6067
  const { sseOrigin: i, projectId: s, apiKey: l } = t, o = await fetch(
6044
6068
  `${i}/project/${s}/agents/messages`,
6045
6069
  {
@@ -6081,14 +6105,14 @@ const tt = /* @__PURE__ */ new Set([
6081
6105
  ct,
6082
6106
  Ge,
6083
6107
  dt
6084
- ]), la = "did not produce any output";
6085
- function ca(t) {
6108
+ ]), ua = "did not produce any output";
6109
+ function pa(t) {
6086
6110
  const e = t.filter((n) => tt.has(n.toolName)).map((n) => n.toolName);
6087
6111
  return e.length === 0 ? "" : `
6088
6112
 
6089
6113
  Tools called: ${[...new Set(e)].join(", ")}`;
6090
6114
  }
6091
- async function da(t, e, r, n, i, s) {
6115
+ async function fa(t, e, r, n, i, s) {
6092
6116
  const l = [], o = [], c = [], d = [];
6093
6117
  let f = [
6094
6118
  {
@@ -6100,15 +6124,15 @@ async function da(t, e, r, n, i, s) {
6100
6124
  let m = 0;
6101
6125
  for (; m < u; ) {
6102
6126
  m++;
6103
- const v = await oa(
6127
+ const v = await da(
6104
6128
  t,
6105
6129
  e,
6106
6130
  r,
6107
6131
  f
6108
- ), y = await aa(v, {
6132
+ ), y = await la(v, {
6109
6133
  onToolCall: s?.onToolCall
6110
6134
  });
6111
- if (o.push(...y.textParts), l.push(...y.toolCalls), y.finalMessage && c.push(y.finalMessage), y.errorMessage?.includes(la)) {
6135
+ if (o.push(...y.textParts), l.push(...y.toolCalls), y.finalMessage && c.push(y.finalMessage), y.errorMessage?.includes(ua)) {
6112
6136
  s?.logger?.debug(
6113
6137
  `Batch ${i}: Exiting loop - no output error`
6114
6138
  );
@@ -6176,7 +6200,7 @@ async function da(t, e, r, n, i, s) {
6176
6200
  );
6177
6201
  const N = c.length > 0 ? c.join(`
6178
6202
 
6179
- `) : o.join(""), I = ca(l), x = N + I, k = d.filter(
6203
+ `) : o.join(""), I = pa(l), x = N + I, k = d.filter(
6180
6204
  (v) => v.toolName === Be
6181
6205
  ).reduce((v, y) => {
6182
6206
  const A = y.input?.value;
@@ -6197,7 +6221,7 @@ async function da(t, e, r, n, i, s) {
6197
6221
  pendingClientToolCalls: d
6198
6222
  };
6199
6223
  }
6200
- async function ua(t, e, r, n) {
6224
+ async function ha(t, e, r, n) {
6201
6225
  if (r.length === 0)
6202
6226
  return { results: [], hasErrors: !1 };
6203
6227
  const s = (await Promise.allSettled(
@@ -6210,7 +6234,7 @@ async function ua(t, e, r, n) {
6210
6234
  `Failed to create thread for batch ${d}`,
6211
6235
  c.reason
6212
6236
  ), n?.onError?.(d, f), null;
6213
- }), l = await Vr(
6237
+ }), l = await jr(
6214
6238
  r,
6215
6239
  async (c, d) => {
6216
6240
  const f = s[d];
@@ -6224,7 +6248,7 @@ async function ua(t, e, r, n) {
6224
6248
  error: "Failed to create thread"
6225
6249
  };
6226
6250
  try {
6227
- const u = await da(
6251
+ const u = await fa(
6228
6252
  t,
6229
6253
  e,
6230
6254
  f,
@@ -6249,7 +6273,7 @@ async function ua(t, e, r, n) {
6249
6273
  ), o = l.some((c) => c.error !== void 0);
6250
6274
  return { results: l, hasErrors: o };
6251
6275
  }
6252
- function pa(t) {
6276
+ function ma(t) {
6253
6277
  const e = [];
6254
6278
  let r = null;
6255
6279
  const n = [];
@@ -6270,7 +6294,7 @@ function pa(t) {
6270
6294
  }
6271
6295
  return { addToCartItems: e, setPoMetadataArgs: r, processingFailures: n };
6272
6296
  }
6273
- function fa(t) {
6297
+ function ga(t) {
6274
6298
  return t.length === 0 ? "" : `
6275
6299
 
6276
6300
  ---
@@ -6281,7 +6305,7 @@ ${t.map(
6281
6305
  ).join(`
6282
6306
  `)}`;
6283
6307
  }
6284
- function ha(t) {
6308
+ function ya(t) {
6285
6309
  if (t.length === 0) return "";
6286
6310
  const e = ["Failed Tool Calls:", ""];
6287
6311
  for (const r of t) {
@@ -6297,8 +6321,8 @@ function ha(t) {
6297
6321
  return e.join(`
6298
6322
  `);
6299
6323
  }
6300
- async function ma(t, e) {
6301
- const r = pa(t);
6324
+ async function xa(t, e) {
6325
+ const r = ma(t);
6302
6326
  if (r.setPoMetadataArgs) {
6303
6327
  const s = r.setPoMetadataArgs;
6304
6328
  g.getState().applyPoMetadata(s.poMetadata);
@@ -6308,20 +6332,20 @@ async function ma(t, e) {
6308
6332
  const { errors: s } = await e.addToCart(r.addToCartItems);
6309
6333
  n = s, s.length > 0 && console.error("Failed to add some items to cart:", s);
6310
6334
  }
6311
- const i = fa(
6335
+ const i = ga(
6312
6336
  r.processingFailures
6313
6337
  );
6314
6338
  if (n.length > 0) {
6315
- const s = ha(n);
6339
+ const s = ya(n);
6316
6340
  return i ? `${i}
6317
6341
  ${s}` : s;
6318
6342
  }
6319
6343
  return i;
6320
6344
  }
6321
- async function ga(t, e) {
6345
+ async function Ca(t, e) {
6322
6346
  if (e.length === 0)
6323
6347
  return { results: [], processingFailuresString: "", hasErrors: !1 };
6324
- const r = await ua(
6348
+ const r = await ha(
6325
6349
  t.takeshapeConfig,
6326
6350
  t.agentName,
6327
6351
  e,
@@ -6332,7 +6356,7 @@ async function ga(t, e) {
6332
6356
  }
6333
6357
  );
6334
6358
  let n = "";
6335
- return t.bcCart && (n = await ma(
6359
+ return t.bcCart && (n = await xa(
6336
6360
  r.results,
6337
6361
  t.bcCart
6338
6362
  )), {
@@ -6341,7 +6365,7 @@ async function ga(t, e) {
6341
6365
  hasErrors: r.hasErrors
6342
6366
  };
6343
6367
  }
6344
- function ya(t) {
6368
+ function va(t) {
6345
6369
  const { bcCart: e } = t, r = g(
6346
6370
  (d) => d.takeshapeConfig
6347
6371
  ), n = g(
@@ -6365,7 +6389,7 @@ function ya(t) {
6365
6389
  bcCart: e
6366
6390
  };
6367
6391
  try {
6368
- const u = await ga(f, d);
6392
+ const u = await Ca(f, d);
6369
6393
  if (s(
6370
6394
  u.results,
6371
6395
  u.processingFailuresString
@@ -6395,7 +6419,7 @@ function ya(t) {
6395
6419
  reset: l
6396
6420
  };
6397
6421
  }
6398
- function xa({
6422
+ function ba({
6399
6423
  appState: t,
6400
6424
  setAppState: e,
6401
6425
  parser: r,
@@ -6407,7 +6431,7 @@ function xa({
6407
6431
  (u) => u.parser.hasProcessedDocument
6408
6432
  ), c = g(
6409
6433
  (u) => u.setHasProcessedDocument
6410
- ), { processBatches: d } = ya({ bcCart: s });
6434
+ ), { processBatches: d } = va({ bcCart: s });
6411
6435
  return O(() => {
6412
6436
  t === "processing" && r.parserStatus !== "streaming" && r.parserStatus !== "submitted" && r.parsedContent && r.parserMessages.length > 0 && !l.current && (l.current = !0, c(!0), d(r.parsedContent));
6413
6437
  }, [
@@ -6433,11 +6457,11 @@ function xa({
6433
6457
  }
6434
6458
  };
6435
6459
  }
6436
- const Ca = "<!-- BATCH -->";
6437
- function va(t) {
6438
- return t.split(Ca).map((e) => e.trim()).filter(Boolean);
6460
+ const Ia = "<!-- BATCH -->";
6461
+ function wa(t) {
6462
+ return t.split(Ia).map((e) => e.trim()).filter(Boolean);
6439
6463
  }
6440
- const ba = {
6464
+ const Sa = {
6441
6465
  end: () => {
6442
6466
  },
6443
6467
  setStatus: () => {
@@ -6446,32 +6470,32 @@ const ba = {
6446
6470
  }
6447
6471
  };
6448
6472
  let rt = null;
6449
- function Ei(t) {
6473
+ function Ai(t) {
6450
6474
  rt = t;
6451
6475
  }
6452
6476
  function nt(t) {
6453
- return rt ? rt.startInactiveSpan(t) : ba;
6477
+ return rt ? rt.startInactiveSpan(t) : Sa;
6454
6478
  }
6455
- function Ia(t) {
6479
+ function Na(t) {
6456
6480
  return new Promise((e, r) => {
6457
6481
  const n = new FileReader();
6458
6482
  n.onload = () => e(n.result), n.onerror = () => r(new Error("Failed to read file")), n.readAsText(t);
6459
6483
  });
6460
6484
  }
6461
- function wa(t) {
6485
+ function Pa(t) {
6462
6486
  return new Promise((e, r) => {
6463
6487
  const n = new FileReader();
6464
6488
  n.onload = () => e(n.result), n.onerror = () => r(new Error("Failed to read file")), n.readAsDataURL(t);
6465
6489
  });
6466
6490
  }
6467
- const Sa = /* @__PURE__ */ new Set([
6491
+ const Ea = /* @__PURE__ */ new Set([
6468
6492
  "application/vnd.ms-excel",
6469
6493
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
6470
6494
  ]);
6471
6495
  function Lt(t) {
6472
- return Sa.has(t);
6496
+ return Ea.has(t);
6473
6497
  }
6474
- async function Na(t) {
6498
+ async function ka(t) {
6475
6499
  const e = await import("xlsx"), r = await t.arrayBuffer(), n = e.read(r, { type: "array" });
6476
6500
  if (n.SheetNames.length === 0)
6477
6501
  throw new Error("Workbook contains no sheets");
@@ -6483,27 +6507,27 @@ async function Na(t) {
6483
6507
  const s = e.utils.json_to_sheet(i);
6484
6508
  return e.utils.sheet_to_csv(s);
6485
6509
  }
6486
- const Pa = "%PDF-", Ea = "%%EOF", ka = 256;
6487
- function Ta(t) {
6510
+ const Ta = "%PDF-", Aa = "%%EOF", $a = 256;
6511
+ function Ba(t) {
6488
6512
  return new Promise((e, r) => {
6489
6513
  const n = new FileReader();
6490
6514
  n.onload = () => e(n.result), n.onerror = () => r(n.error), n.readAsArrayBuffer(t);
6491
6515
  });
6492
6516
  }
6493
- async function Aa(t) {
6494
- if (t.size < ka) return { valid: !1, reason: "invalid" };
6517
+ async function Ma(t) {
6518
+ if (t.size < $a) return { valid: !1, reason: "invalid" };
6495
6519
  let e;
6496
6520
  try {
6497
- e = new Uint8Array(await Ta(t));
6521
+ e = new Uint8Array(await Ba(t));
6498
6522
  } catch {
6499
6523
  return { valid: !1, reason: "invalid" };
6500
6524
  }
6501
- if (!String.fromCharCode(...e.slice(0, 5)).startsWith(Pa))
6525
+ if (!String.fromCharCode(...e.slice(0, 5)).startsWith(Ta))
6502
6526
  return { valid: !1, reason: "invalid" };
6503
6527
  const n = Math.min(1024, e.length);
6504
6528
  if (!String.fromCharCode(
6505
6529
  ...e.slice(e.length - n)
6506
- ).includes(Ea))
6530
+ ).includes(Aa))
6507
6531
  return { valid: !1, reason: "invalid" };
6508
6532
  const s = Math.max(0, e.length - 8192), l = new TextDecoder().decode(e.slice(s)), o = l.lastIndexOf("<<"), c = l.lastIndexOf(">>");
6509
6533
  if (o !== -1 && c !== -1 && o < c && l.substring(o, c).includes("/Encrypt"))
@@ -6527,12 +6551,12 @@ async function Aa(t) {
6527
6551
  }
6528
6552
  return { valid: !0 };
6529
6553
  }
6530
- const $a = /* @__PURE__ */ new Set([
6554
+ const Oa = /* @__PURE__ */ new Set([
6531
6555
  "text/csv",
6532
6556
  "text/plain",
6533
6557
  "application/json"
6534
6558
  ]), Sr = "Please parse this document and extract relevant purchase order information.";
6535
- function Ut(t, e) {
6559
+ function _t(t, e) {
6536
6560
  return [
6537
6561
  {
6538
6562
  type: "text",
@@ -6542,7 +6566,7 @@ ${e}`
6542
6566
  }
6543
6567
  ];
6544
6568
  }
6545
- function Ba(t, e, r) {
6569
+ function Fa(t, e, r) {
6546
6570
  return [
6547
6571
  { type: "text", text: Sr },
6548
6572
  {
@@ -6553,15 +6577,15 @@ function Ba(t, e, r) {
6553
6577
  }
6554
6578
  ];
6555
6579
  }
6556
- function Ma({
6580
+ function Ra({
6557
6581
  createParserThread: t,
6558
6582
  sendParserMessage: e
6559
6583
  }) {
6560
- const [r, n] = _(!1), [i, s] = _(null), l = B(
6584
+ const [r, n] = U(!1), [i, s] = U(null), l = B(
6561
6585
  async (o) => {
6562
6586
  const c = g.getState();
6563
6587
  if (c.setParsedContent(null), n(!0), c.setUploadedFileName(o.name), s(null), o.type === "application/pdf") {
6564
- const d = await Aa(o);
6588
+ const d = await Ma(o);
6565
6589
  if (!d.valid)
6566
6590
  return s(
6567
6591
  d.reason === "password-protected" ? "The PDF appears to be password protected." : "The file does not appear to be a valid PDF."
@@ -6570,15 +6594,15 @@ function Ma({
6570
6594
  await t();
6571
6595
  try {
6572
6596
  if (Lt(o.type)) {
6597
+ const d = await ka(o);
6598
+ e({ parts: _t(o.name, d) });
6599
+ } else if (Oa.has(o.type)) {
6573
6600
  const d = await Na(o);
6574
- e({ parts: Ut(o.name, d) });
6575
- } else if ($a.has(o.type)) {
6576
- const d = await Ia(o);
6577
- e({ parts: Ut(o.name, d) });
6601
+ e({ parts: _t(o.name, d) });
6578
6602
  } else {
6579
- const d = await wa(o);
6603
+ const d = await Pa(o);
6580
6604
  e({
6581
- parts: Ba(d, o.type, o.name)
6605
+ parts: Fa(d, o.type, o.name)
6582
6606
  });
6583
6607
  }
6584
6608
  } catch (d) {
@@ -6605,7 +6629,7 @@ function Nr(t) {
6605
6629
  persist: i = !0
6606
6630
  } = t, { projectId: s, apiKey: l, origin: o } = g(
6607
6631
  (m) => m.takeshapeConfig
6608
- ), [c, d] = _(!1), f = D(
6632
+ ), [c, d] = U(!1), f = D(
6609
6633
  n ? { id: n } : null
6610
6634
  ), u = B(async () => {
6611
6635
  d(!0);
@@ -6642,7 +6666,7 @@ function Nr(t) {
6642
6666
  createThread: u
6643
6667
  };
6644
6668
  }
6645
- function Oa() {
6669
+ function Da() {
6646
6670
  const { sseOrigin: t, projectId: e, apiKey: r } = g(
6647
6671
  (v) => v.takeshapeConfig
6648
6672
  ), { thread: n, createThread: i } = Nr({
@@ -6662,7 +6686,7 @@ function Oa() {
6662
6686
  status: f,
6663
6687
  setMessages: u
6664
6688
  } = qt({
6665
- transport: new Vt({
6689
+ transport: new jt({
6666
6690
  api: `${t}/project/${e}/agents/messages`,
6667
6691
  headers: {
6668
6692
  Authorization: `Bearer ${r}`
@@ -6697,7 +6721,7 @@ function Oa() {
6697
6721
  parserError: I,
6698
6722
  setParserError: x,
6699
6723
  handleFileUpload: b
6700
- } = Ma({
6724
+ } = Ra({
6701
6725
  createParserThread: i,
6702
6726
  sendParserMessage: d
6703
6727
  }), k = B(
@@ -6716,7 +6740,7 @@ function Oa() {
6716
6740
  if (c.length > 0) {
6717
6741
  const v = c[c.length - 1];
6718
6742
  if (v?.role === "assistant" && Array.isArray(v.parts)) {
6719
- const y = v.parts.filter(($) => $.type === "text").map(($) => $.text).filter(Boolean), A = va(y.join(""));
6743
+ const y = v.parts.filter(($) => $.type === "text").map(($) => $.text).filter(Boolean), A = wa(y.join(""));
6720
6744
  g.getState().setParsedContent(A), A && N(!1);
6721
6745
  }
6722
6746
  }
@@ -6747,7 +6771,7 @@ function Oa() {
6747
6771
  reset: T
6748
6772
  };
6749
6773
  }
6750
- class Fa {
6774
+ class La {
6751
6775
  b2bToken = null;
6752
6776
  companyId = null;
6753
6777
  channelId;
@@ -6755,7 +6779,7 @@ class Fa {
6755
6779
  getB2BJwt;
6756
6780
  initPromise;
6757
6781
  constructor(e) {
6758
- this.channelId = e.channelId, this.getB2BJwt = e.getB2BJwt ?? null, this.graphQLClient = new st(Wt, {
6782
+ this.channelId = e.channelId, this.getB2BJwt = e.getB2BJwt ?? null, this.graphQLClient = new st(Vt, {
6759
6783
  credentials: "same-origin",
6760
6784
  headers: {
6761
6785
  "content-type": "application/json",
@@ -6892,16 +6916,16 @@ class Fa {
6892
6916
  }
6893
6917
  }
6894
6918
  }
6895
- function Ra(t) {
6919
+ function _a(t) {
6896
6920
  return console.debug(
6897
6921
  `[createB2BClient] Initializing B2B client for channelId=${t.channelId}`
6898
- ), new Fa(t);
6922
+ ), new La(t);
6899
6923
  }
6900
- async function ki(t) {
6924
+ async function $i(t) {
6901
6925
  let e = null;
6902
6926
  try {
6903
6927
  const r = await fetch(
6904
- `/customer/current.jwt?app_client_id=${Wr}`,
6928
+ `/customer/current.jwt?app_client_id=${Vr}`,
6905
6929
  {
6906
6930
  method: "GET",
6907
6931
  credentials: "same-origin",
@@ -6921,7 +6945,7 @@ async function ki(t) {
6921
6945
  console.debug(
6922
6946
  "[stencilB2BJwt] Exchanging customer JWT for B2B storefront token"
6923
6947
  );
6924
- const n = await new st(Wt, {
6948
+ const n = await new st(Vt, {
6925
6949
  credentials: "same-origin",
6926
6950
  headers: {
6927
6951
  "content-type": "application/json",
@@ -6945,7 +6969,7 @@ async function ki(t) {
6945
6969
  return null;
6946
6970
  }
6947
6971
  }
6948
- async function Da(t, e) {
6972
+ async function Ua(t, e) {
6949
6973
  const { setToolCallError: r } = g.getState(), n = t.input;
6950
6974
  let i = "No items provided to add to cart.";
6951
6975
  if (n.value && n.value.length > 0) {
@@ -6962,7 +6986,7 @@ async function Da(t, e) {
6962
6986
  output: i
6963
6987
  };
6964
6988
  }
6965
- async function La(t, e) {
6989
+ async function qa(t, e) {
6966
6990
  const { setToolCallError: r } = g.getState();
6967
6991
  let n = "Cart cleared successfully.";
6968
6992
  try {
@@ -6977,7 +7001,7 @@ async function La(t, e) {
6977
7001
  output: n
6978
7002
  };
6979
7003
  }
6980
- function Ua(t, e) {
7004
+ function ja(t, e) {
6981
7005
  const r = {
6982
7006
  items: e.cartItems.map((n) => ({
6983
7007
  productEntityId: n.productEntityId,
@@ -6997,7 +7021,7 @@ function Ua(t, e) {
6997
7021
  output: JSON.stringify(r)
6998
7022
  };
6999
7023
  }
7000
- function _a(t) {
7024
+ function Wa(t) {
7001
7025
  const { parser: e } = g.getState(), r = {
7002
7026
  uploadedFileName: e.uploadedFileName,
7003
7027
  parsedContent: e.parsedContent
@@ -7008,12 +7032,12 @@ function _a(t) {
7008
7032
  output: JSON.stringify(r)
7009
7033
  };
7010
7034
  }
7011
- async function qa(t, e) {
7035
+ async function Va(t, e) {
7012
7036
  const { setToolCallError: r } = g.getState(), n = t.input;
7013
7037
  let i = "Item removed from cart successfully.";
7014
7038
  try {
7015
7039
  const s = e.bcCart?.lineItems.physicalItems.find(
7016
- (l) => l.productEntityId === n.productEntityId && l.variantEntityId === n.productVariantEntityId
7040
+ (l) => l.productEntityId === n.productEntityId && l.variantEntityId === n.variantEntityId
7017
7041
  );
7018
7042
  if (s)
7019
7043
  await e.removeLineItem(s.entityId);
@@ -7033,7 +7057,7 @@ async function qa(t, e) {
7033
7057
  output: i
7034
7058
  };
7035
7059
  }
7036
- function Va(t) {
7060
+ function za(t) {
7037
7061
  const {
7038
7062
  cartifact: { itemWarnings: e },
7039
7063
  setItemWarnings: r
@@ -7046,7 +7070,7 @@ function Va(t) {
7046
7070
  output: "Item warnings removed successfully."
7047
7071
  };
7048
7072
  }
7049
- function ja(t) {
7073
+ function Qa(t) {
7050
7074
  const { setItemWarnings: e } = g.getState(), r = t.input;
7051
7075
  return r.itemWarnings && e(r.itemWarnings), {
7052
7076
  tool: pr,
@@ -7054,7 +7078,7 @@ function ja(t) {
7054
7078
  output: "Item warnings set successfully."
7055
7079
  };
7056
7080
  }
7057
- function Wa(t) {
7081
+ function Ha(t) {
7058
7082
  const e = t.input;
7059
7083
  return g.getState().applyPoMetadata(e.poMetadata), {
7060
7084
  tool: Ge,
@@ -7062,12 +7086,12 @@ function Wa(t) {
7062
7086
  output: "PO metadata set successfully."
7063
7087
  };
7064
7088
  }
7065
- async function za(t, e) {
7089
+ async function Ga(t, e) {
7066
7090
  const { setToolCallError: r, setPoItemPrice: n } = g.getState(), i = t.input;
7067
7091
  let s = 0;
7068
7092
  try {
7069
7093
  const l = e.bcCart?.lineItems.physicalItems.find(
7070
- (o) => o.productEntityId === i.where.productEntityId && o.variantEntityId === i.where.productVariantEntityId
7094
+ (o) => o.productEntityId === i.where.productEntityId && o.variantEntityId === i.where.variantEntityId
7071
7095
  );
7072
7096
  l && i.data.quantity !== void 0 && (await e.updateLineItemQuantity(
7073
7097
  l.entityId,
@@ -7076,7 +7100,7 @@ async function za(t, e) {
7076
7100
  l.variantEntityId ?? void 0
7077
7101
  ), s++), i.data.poPriceValue !== void 0 && i.data.poPriceCurrencyCode !== void 0 && n(
7078
7102
  i.where.productEntityId,
7079
- i.where.productVariantEntityId,
7103
+ i.where.variantEntityId,
7080
7104
  i.data.poPriceValue,
7081
7105
  i.data.poPriceCurrencyCode
7082
7106
  );
@@ -7095,21 +7119,21 @@ async function za(t, e) {
7095
7119
  };
7096
7120
  }
7097
7121
  const Pr = {
7098
- addToCart: Da,
7099
- updateCart: za,
7100
- removeFromCart: qa,
7101
- clearCart: La,
7102
- getCart: Ua,
7103
- getPurchaseOrderData: _a,
7104
- setPoMetadata: Wa,
7105
- setItemWarnings: ja,
7106
- removeItemWarnings: Va
7107
- }, Qa = new Set(Object.keys(Pr));
7108
- async function Ha(t, e) {
7122
+ addToCart: Ua,
7123
+ updateCart: Ga,
7124
+ removeFromCart: Va,
7125
+ clearCart: qa,
7126
+ getCart: ja,
7127
+ getPurchaseOrderData: Wa,
7128
+ setPoMetadata: Ha,
7129
+ setItemWarnings: Qa,
7130
+ removeItemWarnings: za
7131
+ }, Ka = new Set(Object.keys(Pr));
7132
+ async function Ja(t, e) {
7109
7133
  const r = Pr[t.toolName];
7110
7134
  return r?.(t, e);
7111
7135
  }
7112
- function Ga(t, e) {
7136
+ function Ya(t, e) {
7113
7137
  const n = [...t].reverse().find((i) => i.role === "assistant")?.parts?.find(
7114
7138
  (i) => "toolCallId" in i && i.toolCallId === e && "state" in i && (i.state === "output-available" || i.state === "output-error")
7115
7139
  );
@@ -7119,12 +7143,12 @@ function Ga(t, e) {
7119
7143
  errorText: "errorText" in n ? String(n.errorText) : void 0
7120
7144
  };
7121
7145
  }
7122
- async function Ka(t, e, r) {
7146
+ async function Xa(t, e, r) {
7123
7147
  const n = [], i = [];
7124
7148
  for (const s of t) {
7125
- if (!Qa.has(s.toolName))
7149
+ if (!Ka.has(s.toolName))
7126
7150
  continue;
7127
- const l = Ga(
7151
+ const l = Ya(
7128
7152
  e,
7129
7153
  s.toolCallId
7130
7154
  );
@@ -7143,7 +7167,7 @@ async function Ka(t, e, r) {
7143
7167
  continue;
7144
7168
  }
7145
7169
  try {
7146
- const o = await Ha(s, r);
7170
+ const o = await Ja(s, r);
7147
7171
  o && (n.push(o.toolCallId), i.push(o));
7148
7172
  } catch (o) {
7149
7173
  console.error("[handleToolCall] Error:", { toolCall: s, error: o });
@@ -7153,7 +7177,7 @@ async function Ka(t, e, r) {
7153
7177
  }
7154
7178
  return { completedToolCallIds: n, outputs: i };
7155
7179
  }
7156
- function Ja() {
7180
+ function Za() {
7157
7181
  try {
7158
7182
  const t = localStorage.getItem(ot);
7159
7183
  if (!t)
@@ -7202,14 +7226,14 @@ function Ja() {
7202
7226
  };
7203
7227
  }
7204
7228
  }
7205
- function je() {
7229
+ function We() {
7206
7230
  try {
7207
7231
  localStorage.removeItem(ot);
7208
7232
  } catch (t) {
7209
7233
  console.error("Failed to clear persisted session:", t);
7210
7234
  }
7211
7235
  }
7212
- function Ya(t, e) {
7236
+ function ei(t, e) {
7213
7237
  return !t && !e ? { valid: !0 } : t && !e ? {
7214
7238
  valid: !1,
7215
7239
  error: "Your previous session was reset because you signed out."
@@ -7221,22 +7245,22 @@ function Ya(t, e) {
7221
7245
  error: "Your previous session was reset because you signed in as a different user."
7222
7246
  } : { valid: !0 };
7223
7247
  }
7224
- async function Za(t, e) {
7248
+ async function ti(t, e) {
7225
7249
  return { valid: !0 };
7226
7250
  }
7227
- function Xa(t) {
7251
+ function ri(t) {
7228
7252
  return t ? { valid: !0 } : {
7229
7253
  valid: !1,
7230
7254
  error: "The cart from your previous session is no longer available."
7231
7255
  };
7232
7256
  }
7233
- async function ei(t) {
7257
+ async function ni(t) {
7234
7258
  const e = g.getState();
7235
7259
  if (e.ui.initStatus !== "pending")
7236
7260
  return;
7237
- const r = Ja();
7261
+ const r = Za();
7238
7262
  if (e.setTakeShapeConfig(t.takeShapeConfig), !r.valid) {
7239
- je(), e.failValidation(r.error ?? "Session validation failed");
7263
+ We(), e.failValidation(r.error ?? "Session validation failed");
7240
7264
  return;
7241
7265
  }
7242
7266
  let n = [], i = null;
@@ -7249,7 +7273,7 @@ async function ei(t) {
7249
7273
  }
7250
7274
  } catch (m) {
7251
7275
  if (console.error("Failed to fetch customer addresses:", m), r.data) {
7252
- je(), e.failValidation("Unable to verify customer identity.");
7276
+ We(), e.failValidation("Unable to verify customer identity.");
7253
7277
  return;
7254
7278
  }
7255
7279
  }
@@ -7276,35 +7300,35 @@ async function ei(t) {
7276
7300
  try {
7277
7301
  c = await t.storefrontClient.getCart(l);
7278
7302
  } catch (m) {
7279
- console.error("Failed to fetch cart:", m), je(), e.failValidation("Unable to restore previous cart.");
7303
+ console.error("Failed to fetch cart:", m), We(), e.failValidation("Unable to restore previous cart.");
7280
7304
  return;
7281
7305
  }
7282
7306
  const d = [];
7283
7307
  d.push(
7284
7308
  Promise.resolve(
7285
- Ya(
7309
+ ei(
7286
7310
  o.customerEntityId ?? null,
7287
7311
  i
7288
7312
  )
7289
7313
  )
7290
- ), s && d.push(Za()), l && d.push(Promise.resolve(Xa(c)));
7314
+ ), s && d.push(ti()), l && d.push(Promise.resolve(ri(c)));
7291
7315
  const u = (await Promise.all(d)).find((m) => !m.valid);
7292
7316
  if (u) {
7293
- je(), e.failValidation(u.error ?? "Session validation failed");
7317
+ We(), e.failValidation(u.error ?? "Session validation failed");
7294
7318
  return;
7295
7319
  }
7296
7320
  o && e.restoreSession(o), c && e.setBcCart(c), i && e.setCustomerInfo(i), n.length > 0 && e.setCustomerAddresses(n), e.completeValidation();
7297
7321
  }
7298
- function ti(t) {
7322
+ function si(t) {
7299
7323
  return Lr(t) && "toolCallId" in t && typeof t.toolCallId == "string" && "output" in t && t.output !== void 0 && "state" in t && t.state === "output-available";
7300
7324
  }
7301
- function ri(t) {
7302
- return t ? t.filter(ti) : [];
7325
+ function ai(t) {
7326
+ return t ? t.filter(si) : [];
7303
7327
  }
7304
- function ni(t) {
7328
+ function ii(t) {
7305
7329
  return t.type === "dynamic-tool" ? t.toolName ?? "unknown" : t.type.slice(5);
7306
7330
  }
7307
- const si = new Fr({
7331
+ const oi = new Fr({
7308
7332
  defaultOptions: {
7309
7333
  queries: {
7310
7334
  staleTime: 300 * 1e3
@@ -7312,15 +7336,15 @@ const si = new Fr({
7312
7336
  }
7313
7337
  }
7314
7338
  });
7315
- function ai(t) {
7316
- return /* @__PURE__ */ a(Or, { client: si, children: /* @__PURE__ */ a(us, { client: t.bigcommerce.client, children: /* @__PURE__ */ a(ii, { ...t }) }) });
7339
+ function li(t) {
7340
+ return /* @__PURE__ */ a(Or, { client: oi, children: /* @__PURE__ */ a(hs, { client: t.bigcommerce.client, children: /* @__PURE__ */ a(ci, { ...t }) }) });
7317
7341
  }
7318
- function ii(t) {
7342
+ function ci(t) {
7319
7343
  const e = g((s) => s.ui.initStatus), r = g((s) => s.ui.initError), n = g((s) => s.fatalError), i = g((s) => s.clearInitError);
7320
7344
  return O(() => {
7321
- e === "pending" && ei({
7345
+ e === "pending" && ni({
7322
7346
  storefrontClient: t.bigcommerce.client,
7323
- b2bClient: Ra({
7347
+ b2bClient: _a({
7324
7348
  channelId: t.bigcommerce.client.channelId,
7325
7349
  getB2BJwt: t.bigcommerce.getB2BJwt
7326
7350
  }),
@@ -7330,19 +7354,19 @@ function ii(t) {
7330
7354
  "div",
7331
7355
  {
7332
7356
  className: `flex h-full items-center justify-center ${t.className ?? ""}`,
7333
- children: /* @__PURE__ */ a(Ms, { message: n })
7357
+ children: /* @__PURE__ */ a(Rs, { message: n })
7334
7358
  }
7335
7359
  ) : e === "pending" ? /* @__PURE__ */ a(
7336
7360
  "div",
7337
7361
  {
7338
7362
  className: `flex h-full items-center justify-center ${t.className ?? ""}`,
7339
- children: /* @__PURE__ */ a("div", { className: "flex items-center", children: /* @__PURE__ */ a(Ue, { size: 16 }) })
7363
+ children: /* @__PURE__ */ a("div", { className: "flex items-center", children: /* @__PURE__ */ a(_e, { size: 16 }) })
7340
7364
  }
7341
7365
  ) : e === "existing-cart" ? /* @__PURE__ */ a(
7342
7366
  "div",
7343
7367
  {
7344
7368
  className: `flex h-full items-center justify-center ${t.className ?? ""}`,
7345
- children: /* @__PURE__ */ a(Bs, {})
7369
+ children: /* @__PURE__ */ a(Fs, {})
7346
7370
  }
7347
7371
  ) : r ? /* @__PURE__ */ h(
7348
7372
  "div",
@@ -7361,9 +7385,9 @@ function ii(t) {
7361
7385
  )
7362
7386
  ]
7363
7387
  }
7364
- ) : /* @__PURE__ */ a(oi, { ...t });
7388
+ ) : /* @__PURE__ */ a(di, { ...t });
7365
7389
  }
7366
- function oi({
7390
+ function di({
7367
7391
  className: t = "",
7368
7392
  agentName: e = ze,
7369
7393
  inputName: r = ze,
@@ -7389,7 +7413,7 @@ function oi({
7389
7413
  null
7390
7414
  ), w = D(
7391
7415
  null
7392
- ), T = Re((C) => C.isExpanded), v = Re((C) => C.setExpanded), y = Re((C) => C.reset), A = Oa(), $ = na({
7416
+ ), T = Re((C) => C.isExpanded), v = Re((C) => C.setExpanded), y = Re((C) => C.reset), A = Da(), $ = ia({
7393
7417
  client: n.client,
7394
7418
  onError: (C) => console.error("BigCommerce error:", C)
7395
7419
  }), F = g((C) => C.cartifact.orderId), Q = g((C) => C.cartifact.buyerInfo), H = g(
@@ -7402,13 +7426,13 @@ function oi({
7402
7426
  (C) => C.cartifact.itemWarnings
7403
7427
  ), se = g((C) => C.clearCartifact), Y = g((C) => C.clearBcSession), te = g(
7404
7428
  (C) => C.clearAddressSelections
7405
- ), j = g((C) => C.clearChat), { cartItems: W } = $, ie = D([]), ve = B(
7429
+ ), W = g((C) => C.clearChat), { cartItems: V } = $, ie = D([]), ve = B(
7406
7430
  async ({ toolCall: C }) => {
7407
7431
  ie.current.push(C);
7408
7432
  },
7409
7433
  []
7410
- ), L = D(/* @__PURE__ */ new Set()), { messages: V, sendMessage: K, status: J, error: Pe, setMessages: he, addToolOutput: me } = qt({
7411
- transport: new Vt({
7434
+ ), L = D(/* @__PURE__ */ new Set()), { messages: j, sendMessage: K, status: J, error: Pe, setMessages: he, addToolOutput: me } = qt({
7435
+ transport: new jt({
7412
7436
  api: `${s}/project/${l}/agents/messages`,
7413
7437
  headers: {
7414
7438
  Authorization: `Bearer ${o}`
@@ -7421,7 +7445,7 @@ function oi({
7421
7445
  if (re.role === "user" && C.messages.length >= 2) {
7422
7446
  const ue = C.messages[C.messages.length - 2], Ke = L.current;
7423
7447
  if (ue?.role === "assistant" && Ke.size > 0) {
7424
- const ht = ri(
7448
+ const ht = ai(
7425
7449
  ue.parts
7426
7450
  ).filter(
7427
7451
  (mt) => Ke.has(mt.toolCallId)
@@ -7430,7 +7454,7 @@ function oi({
7430
7454
  ...ue,
7431
7455
  parts: ht.map((Ee) => ({
7432
7456
  type: Ee.type,
7433
- toolName: ni(Ee),
7457
+ toolName: ii(Ee),
7434
7458
  toolCallId: Ee.toolCallId,
7435
7459
  state: Ee.state,
7436
7460
  input: Ee.input,
@@ -7482,7 +7506,7 @@ function oi({
7482
7506
  }, []), O(() => {
7483
7507
  if (J === "ready" && ie.current.length > 0) {
7484
7508
  const C = [...ie.current];
7485
- ie.current = [], Ka(C, V, $).then(async (re) => {
7509
+ ie.current = [], Xa(C, j, $).then(async (re) => {
7486
7510
  for (const be of re.outputs)
7487
7511
  L.current.add(be.toolCallId), await me(be);
7488
7512
  re.outputs.length > 0 && ce({ text: it });
@@ -7490,9 +7514,9 @@ function oi({
7490
7514
  console.error("[executeDeferredToolCalls] Error:", re);
7491
7515
  });
7492
7516
  }
7493
- }, [J, V, $, me, ce]), O(() => {
7494
- g.getState().setMessages(V);
7495
- }, [V]);
7517
+ }, [J, j, $, me, ce]), O(() => {
7518
+ g.getState().setMessages(j);
7519
+ }, [j]);
7496
7520
  const ge = g(
7497
7521
  (C) => C.ai.pendingMessage
7498
7522
  ), p = g((C) => C.ai.shouldScroll), S = g((C) => C.consumeMessage);
@@ -7503,23 +7527,23 @@ function oi({
7503
7527
  }, [ge, p, ce, S]), O(() => {
7504
7528
  i && I === "chatting" && v(!0);
7505
7529
  }, [i, I, v]);
7506
- const E = m || J === "submitted" || J === "streaming", P = oe(() => zs(V, J), [V, J]), M = xa({
7530
+ const E = m || J === "submitted" || J === "streaming", P = oe(() => Gs(j, J), [j, J]), M = ba({
7507
7531
  appState: I,
7508
7532
  setAppState: x,
7509
7533
  parser: A,
7510
7534
  firstResponseComplete: P,
7511
7535
  chatPanelRef: b,
7512
7536
  bcCart: $
7513
- }), R = sa({
7537
+ }), R = oa({
7514
7538
  bcCart: $,
7515
- cartItems: W,
7539
+ cartItems: V,
7516
7540
  onCheckoutInitiated: (C) => {
7517
7541
  C ? w.current?.setStatus({ code: 2, message: C.message }) : w.current?.setStatus({ code: 1, message: "ok" }), w.current?.end(), w.current = null;
7518
7542
  },
7519
7543
  onCheckout: n.onCheckout
7520
- }), U = (C) => {
7544
+ }), _ = (C) => {
7521
7545
  g.getState().setInput(C.target.value);
7522
- }, _e = (C) => {
7546
+ }, Ue = (C) => {
7523
7547
  C.preventDefault(), d.trim() && (g.getState().sendMessage(d), g.getState().setInput(""));
7524
7548
  }, Me = async (C) => {
7525
7549
  w.current?.end(), w.current = nt({
@@ -7540,29 +7564,29 @@ function oi({
7540
7564
  },
7541
7565
  [n.onViewProduct]
7542
7566
  ), le = B(() => {
7543
- const C = [...V].reverse().find((ue) => ue.role === "user");
7567
+ const C = [...j].reverse().find((ue) => ue.role === "user");
7544
7568
  if (!C) return;
7545
7569
  const re = C.parts?.filter(
7546
7570
  (ue) => ue.type === "text"
7547
7571
  ).map((ue) => ue.text).join(`
7548
7572
  `);
7549
7573
  if (!re) return;
7550
- const be = V.lastIndexOf(C);
7551
- he(V.slice(0, be)), g.getState().sendMessage(re);
7552
- }, [V, he]), Z = B(() => {
7574
+ const be = j.lastIndexOf(C);
7575
+ he(j.slice(0, be)), g.getState().sendMessage(re);
7576
+ }, [j, he]), X = B(() => {
7553
7577
  x("chatting");
7554
- }, [x]), X = g(
7578
+ }, [x]), Z = g(
7555
7579
  (C) => C.resetBatchProcessing
7556
7580
  ), ye = B(async () => {
7557
- w.current?.setStatus({ code: 2, message: "cancelled" }), w.current?.end(), w.current = null, await $.clearCart(), se(), Y(), te(), j(), he([]), X(), y(), A.reset(), M.reset(), x("upload"), N();
7581
+ w.current?.setStatus({ code: 2, message: "cancelled" }), w.current?.end(), w.current = null, await $.clearCart(), se(), Y(), te(), W(), he([]), Z(), y(), A.reset(), M.reset(), x("upload"), N();
7558
7582
  }, [
7559
7583
  $.clearCart,
7560
7584
  se,
7561
7585
  Y,
7562
7586
  te,
7563
- j,
7587
+ W,
7564
7588
  he,
7565
- X,
7589
+ Z,
7566
7590
  y,
7567
7591
  A.reset,
7568
7592
  M.reset,
@@ -7571,22 +7595,22 @@ function oi({
7571
7595
  ]);
7572
7596
  if (I === "upload" || I === "processing")
7573
7597
  return /* @__PURE__ */ a("div", { className: `flex h-full ${t}`, children: /* @__PURE__ */ a(
7574
- Zs,
7598
+ ta,
7575
7599
  {
7576
7600
  onFileUpload: Me,
7577
- onSkip: Z,
7601
+ onSkip: X,
7578
7602
  onClearError: A.handleClearError,
7579
- cartItems: W,
7603
+ cartItems: V,
7580
7604
  isUploading: A.isUploadingFile,
7581
7605
  parserError: A.parserError
7582
7606
  }
7583
7607
  ) });
7584
7608
  const de = {
7585
7609
  className: t,
7586
- messages: V,
7610
+ messages: j,
7587
7611
  input: d,
7588
- onInputChange: U,
7589
- onSubmit: _e,
7612
+ onInputChange: _,
7613
+ onSubmit: Ue,
7590
7614
  isLoading: E,
7591
7615
  error: Pe,
7592
7616
  onRetry: Pe ? le : void 0,
@@ -7594,7 +7618,7 @@ function oi({
7594
7618
  uploadedFileName: A.uploadedFileName,
7595
7619
  chatPanelRef: b,
7596
7620
  onFileUpload: Me,
7597
- cartItems: W,
7621
+ cartItems: V,
7598
7622
  itemWarnings: ee,
7599
7623
  onUpdateQuantity: R.handleUpdateQuantity,
7600
7624
  onRemove: R.handleRemoveItem,
@@ -7628,7 +7652,7 @@ function oi({
7628
7652
  }
7629
7653
  ) });
7630
7654
  }
7631
- function Ti({
7655
+ function Bi({
7632
7656
  takeshape: t,
7633
7657
  bigcommerce: e,
7634
7658
  agentName: r = ze,
@@ -7647,7 +7671,7 @@ function Ti({
7647
7671
  [e.endpoint, e.storefrontToken, e.channelId]
7648
7672
  );
7649
7673
  return /* @__PURE__ */ a(
7650
- ai,
7674
+ li,
7651
7675
  {
7652
7676
  agentName: r,
7653
7677
  inputName: n,
@@ -7669,14 +7693,14 @@ function Ti({
7669
7693
  );
7670
7694
  }
7671
7695
  export {
7672
- Ti as P,
7673
- Ni as S,
7696
+ Bi as P,
7697
+ ki as S,
7674
7698
  Cn as a,
7675
- Pi as b,
7676
- Ra as c,
7677
- ai as d,
7678
- Ei as i,
7679
- Si as r,
7680
- ki as s
7699
+ Ti as b,
7700
+ _a as c,
7701
+ li as d,
7702
+ Ai as i,
7703
+ Ei as r,
7704
+ $i as s
7681
7705
  };
7682
- //# sourceMappingURL=purchase-order-chat-wrapper-BMkMivUL.js.map
7706
+ //# sourceMappingURL=purchase-order-chat-wrapper-gK2fXT2-.js.map