@takeshape/purchase-order-chat 1.54.0 → 1.54.2

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,18 +1,18 @@
1
- import { useState as U, useEffect as O, createElement as Er, useRef as D, useLayoutEffect as mt, useCallback as B, createContext as kr, useContext as Tr, useMemo as ie, 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 ie, forwardRef as Ar, useImperativeHandle as $r } from "react";
2
2
  import { jsxs as h, jsx as s, Fragment as Ce } from "react/jsx-runtime";
3
3
  import { GraphQLClient as nt, ClientError as Br } from "graphql-request";
4
- import { initGraphQLTada as _t, readFragment as ve } from "gql.tada";
5
- import { useChat as qt } from "@ai-sdk/react";
4
+ import { initGraphQLTada as qt, readFragment as ve } from "gql.tada";
5
+ import { useChat as Vt } 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 st } from "zustand";
9
9
  import { clsx as Ur } from "clsx";
10
10
  import { twMerge as _r } from "tailwind-merge";
11
- import { devtools as qr, persist as jt } from "zustand/middleware";
11
+ import { devtools as qr, persist as Wt } from "zustand/middleware";
12
12
  import { Streamdown as je } from "streamdown";
13
13
  import { get as Ge } from "lodash";
14
14
  import Vr from "p-map";
15
- import { z as gt } from "zod";
15
+ import { z as yt } from "zod";
16
16
  function be(...t) {
17
17
  return _r(Ur(t));
18
18
  }
@@ -22,27 +22,27 @@ function bi(t, e) {
22
22
  return i != null ? String(i) : "";
23
23
  });
24
24
  }
25
- const jr = "__vite_c_css_pos_initial_d22f4c66f6aa45fd9b71bc267e80c77f", yt = "__vite_c_css_pos_update_d22f4c66f6aa45fd9b71bc267e80c77f", xt = () => typeof window < "u" ? window[jr] : void 0, Ii = (t) => {
26
- const [e, r] = U(() => xt() || /* @__PURE__ */ new Map()), [n, i] = U(0);
25
+ const jr = "__vite_c_css_pos_initial_f5c07e7631ac4a2dad7e874fec2c2239", xt = "__vite_c_css_pos_update_f5c07e7631ac4a2dad7e874fec2c2239", Ct = () => typeof window < "u" ? window[jr] : void 0, Ii = (t) => {
26
+ const [e, r] = U(() => Ct() || /* @__PURE__ */ new Map()), [n, i] = U(0);
27
27
  return O(() => {
28
28
  const a = (l) => {
29
- const o = xt() || /* @__PURE__ */ new Map();
29
+ const o = Ct() || /* @__PURE__ */ new Map();
30
30
  r(o), i((c) => c + 1), t.onChange?.(o);
31
31
  };
32
- return window.addEventListener(yt, a), a(), () => {
33
- window.removeEventListener(yt, a);
32
+ return window.addEventListener(xt, a), a(), () => {
33
+ window.removeEventListener(xt, a);
34
34
  };
35
35
  }, [t.onChange]), Array.from(e?.keys() || []).map((a) => {
36
36
  const l = e.get(a);
37
37
  return l ? /* @__PURE__ */ Er("style", { ...l.attributes, key: `${a}-${n}` }, l.css) : null;
38
38
  });
39
- }, We = "bigcommercePurchaseOrderAgent", Ct = "https://api.takeshape.io", Wt = "https://api-b2b.bigcommerce.com/graphql", Wr = "dl7c39mdpul6hyc489yk0vzxl6jesyx", at = "[client is providing tool response]", xe = "__po_address__", Ne = "__po_billing_address__", ue = "__checkout_address__", it = "purchase-order-chat-session", zt = 3, ye = _t(), ot = ye(`
39
+ }, We = "bigcommercePurchaseOrderAgent", vt = "https://api.takeshape.io", zt = "https://api-b2b.bigcommerce.com/graphql", Wr = "dl7c39mdpul6hyc489yk0vzxl6jesyx", at = "[client is providing tool response]", xe = "__po_address__", Ne = "__po_billing_address__", ue = "__checkout_address__", it = "purchase-order-chat-session", Qt = 3, ye = qt(), ot = ye(`
40
40
  fragment UserAuthorizationFragment on UserAuthorization {
41
41
  result {
42
42
  token
43
43
  }
44
44
  }
45
- `), Qt = ye(
45
+ `), Ht = ye(
46
46
  `
47
47
  mutation Authorization($authData: UserAuthType!) {
48
48
  authorization(authData: $authData) {
@@ -51,7 +51,7 @@ const jr = "__vite_c_css_pos_initial_d22f4c66f6aa45fd9b71bc267e80c77f", yt = "__
51
51
  }
52
52
  `,
53
53
  [ot]
54
- ), Ht = ye(`
54
+ ), Gt = ye(`
55
55
  fragment UserFragment on UserType {
56
56
  companyInfo {
57
57
  companyId
@@ -65,8 +65,8 @@ const jr = "__vite_c_css_pos_initial_d22f4c66f6aa45fd9b71bc267e80c77f", yt = "__
65
65
  }
66
66
  }
67
67
  `,
68
- [Ht]
69
- ), Gt = ye(`
68
+ [Gt]
69
+ ), Kt = ye(`
70
70
  fragment CompanyAddressFragment on AddressType {
71
71
  id
72
72
  firstName
@@ -107,7 +107,7 @@ const jr = "__vite_c_css_pos_initial_d22f4c66f6aa45fd9b71bc267e80c77f", yt = "__
107
107
  }
108
108
  }
109
109
  `,
110
- [Gt]
110
+ [Kt]
111
111
  );
112
112
  ye(`
113
113
  fragment CheckoutResultFragment on CheckoutLoginResultType {
@@ -126,7 +126,7 @@ const Hr = ye(
126
126
  }
127
127
  }
128
128
  `
129
- ), _ = _t(), Ee = _(`
129
+ ), _ = qt(), Ee = _(`
130
130
  fragment CartFields on Cart {
131
131
  id
132
132
  entityId
@@ -603,7 +603,7 @@ const an = _(
603
603
  }
604
604
  }
605
605
  }
606
- `), Kt = _(`
606
+ `), Jt = _(`
607
607
  fragment CustomerAddressFields on CustomerAddress {
608
608
  entityId
609
609
  firstName
@@ -617,7 +617,7 @@ const an = _(
617
617
  country
618
618
  phone
619
619
  }
620
- `), vt = _(
620
+ `), bt = _(
621
621
  `
622
622
  query GetCustomerAddresses($first: Int = 50, $after: String) {
623
623
  customer {
@@ -639,7 +639,7 @@ const an = _(
639
639
  }
640
640
  }
641
641
  `,
642
- [Kt]
642
+ [Jt]
643
643
  ), dn = _(`
644
644
  query GetProductVariantsPage($entityId: Int!, $first: Int = 50, $after: String!) {
645
645
  site {
@@ -785,7 +785,7 @@ _(`
785
785
  }
786
786
  `);
787
787
  function fn(t) {
788
- const e = ve(Gt, t);
788
+ const e = ve(Kt, t);
789
789
  return {
790
790
  source: "b2b",
791
791
  id: `${e.id}`,
@@ -807,7 +807,7 @@ function fn(t) {
807
807
  };
808
808
  }
809
809
  function mn(t, e = 0) {
810
- const r = ve(Kt, t);
810
+ const r = ve(Jt, t);
811
811
  return {
812
812
  source: "storefront",
813
813
  id: `${r.entityId}`,
@@ -829,7 +829,7 @@ function mn(t, e = 0) {
829
829
  isDefaultBilling: e === 0
830
830
  };
831
831
  }
832
- function bt(t, e) {
832
+ function It(t, e) {
833
833
  return {
834
834
  source: "po",
835
835
  id: e.id,
@@ -1168,7 +1168,7 @@ class xn {
1168
1168
  */
1169
1169
  async getCustomerAddresses() {
1170
1170
  const e = await this.request({
1171
- document: vt
1171
+ document: bt
1172
1172
  });
1173
1173
  if (!e.customer)
1174
1174
  return {
@@ -1184,7 +1184,7 @@ class xn {
1184
1184
  if (e.customer.addresses.pageInfo.hasNextPage) {
1185
1185
  const a = await Ae(
1186
1186
  this,
1187
- vt,
1187
+ bt,
1188
1188
  { after: e.customer.addresses.pageInfo.endCursor },
1189
1189
  (l) => l.customer?.addresses ?? null
1190
1190
  );
@@ -1399,13 +1399,13 @@ function vn({ children: t }) {
1399
1399
  a.key === "Escape" && r(!1);
1400
1400
  };
1401
1401
  return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
1402
- }, [e, r]), mt(() => {
1402
+ }, [e, r]), gt(() => {
1403
1403
  if (!e) return;
1404
1404
  const i = window.scrollY, a = document.body.style.overflow, l = document.body.style.position, o = document.body.style.top, c = document.body.style.width;
1405
1405
  return document.body.style.overflow = "hidden", document.body.style.position = "fixed", document.body.style.top = `-${i}px`, document.body.style.width = "100%", () => {
1406
1406
  document.body.style.overflow = a, document.body.style.position = l, document.body.style.top = o, document.body.style.width = c, window.scrollTo(0, i);
1407
1407
  };
1408
- }, [e]), mt(() => {
1408
+ }, [e]), gt(() => {
1409
1409
  if (!e || !n.current) return;
1410
1410
  const i = n.current.getRootNode();
1411
1411
  if (!(i instanceof ShadowRoot)) return;
@@ -1441,7 +1441,7 @@ function vn({ children: t }) {
1441
1441
  }
1442
1442
  ) : null;
1443
1443
  }
1444
- const Jt = {
1444
+ const Yt = {
1445
1445
  "application/pdf": ".pdf",
1446
1446
  "text/csv": ".csv",
1447
1447
  "application/vnd.ms-excel": ".xls",
@@ -1452,7 +1452,7 @@ const Jt = {
1452
1452
  "image/jpeg": ".jpg,.jpeg",
1453
1453
  "image/heic": ".heic",
1454
1454
  "image/heif": ".heif"
1455
- }, 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;
1455
+ }, bn = Object.keys(Yt), Zt = Object.values(Yt).join(","), In = "PDF, Excel, CSV, text, or image files", Xt = ["PDF", "Excel", "CSV", "Images"], wn = 10 * 1024 * 1024;
1456
1456
  function Sn(t) {
1457
1457
  return t.size > wn ? {
1458
1458
  valid: !1,
@@ -1462,7 +1462,7 @@ function Sn(t) {
1462
1462
  error: `File type not supported. Please upload ${In}.`
1463
1463
  };
1464
1464
  }
1465
- function Xt({ onFile: t, onBeforeValidate: e }) {
1465
+ function er({ onFile: t, onBeforeValidate: e }) {
1466
1466
  const [r, n] = U(!1), [i, a] = U(null), l = D(null), o = D(null), c = B(
1467
1467
  (x) => {
1468
1468
  e?.(), a(null);
@@ -1541,7 +1541,7 @@ const Nn = () => /* @__PURE__ */ h(
1541
1541
  /* @__PURE__ */ s("polyline", { points: "20 6 9 17 4 12" })
1542
1542
  ]
1543
1543
  }
1544
- ), er = ({ size: t = 12 }) => /* @__PURE__ */ h(
1544
+ ), tr = ({ size: t = 12 }) => /* @__PURE__ */ h(
1545
1545
  "svg",
1546
1546
  {
1547
1547
  width: t,
@@ -1558,7 +1558,7 @@ const Nn = () => /* @__PURE__ */ h(
1558
1558
  /* @__PURE__ */ s("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1559
1559
  ]
1560
1560
  }
1561
- ), tr = ({ size: t = 16 }) => /* @__PURE__ */ h(
1561
+ ), rr = ({ size: t = 16 }) => /* @__PURE__ */ h(
1562
1562
  "svg",
1563
1563
  {
1564
1564
  width: t,
@@ -1577,7 +1577,7 @@ const Nn = () => /* @__PURE__ */ h(
1577
1577
  /* @__PURE__ */ s("line", { x1: "3", y1: "21", x2: "10", y2: "14" })
1578
1578
  ]
1579
1579
  }
1580
- ), rr = ({ size: t = 16 }) => /* @__PURE__ */ h(
1580
+ ), nr = ({ size: t = 16 }) => /* @__PURE__ */ h(
1581
1581
  "svg",
1582
1582
  {
1583
1583
  width: t,
@@ -1652,7 +1652,7 @@ function En({
1652
1652
  ),
1653
1653
  children: [
1654
1654
  a && /* @__PURE__ */ s(
1655
- It,
1655
+ wt,
1656
1656
  {
1657
1657
  label: "Bill to",
1658
1658
  onAddressChange: c,
@@ -1666,7 +1666,7 @@ function En({
1666
1666
  }
1667
1667
  ),
1668
1668
  /* @__PURE__ */ s(
1669
- It,
1669
+ wt,
1670
1670
  {
1671
1671
  label: "Ship to",
1672
1672
  onAddressChange: n,
@@ -1683,7 +1683,7 @@ function En({
1683
1683
  }
1684
1684
  );
1685
1685
  }
1686
- function It(t) {
1686
+ function wt(t) {
1687
1687
  const {
1688
1688
  label: e,
1689
1689
  addresses: r,
@@ -1727,11 +1727,11 @@ function It(t) {
1727
1727
  className: "w-full px-2 py-1.5 text-[0.8125rem] font-medium rounded cursor-pointer transition-colors focus:outline-none focus:border-border-focus disabled:opacity-50 disabled:cursor-not-allowed border border-solid font-[inherit] appearance-auto text-text bg-transparent border-border-strong",
1728
1728
  children: [
1729
1729
  l && /* @__PURE__ */ h(Ce, { children: [
1730
- /* @__PURE__ */ s("option", { value: l.id, children: /* @__PURE__ */ s(wt, { address: l }) }, l.id),
1730
+ /* @__PURE__ */ s("option", { value: l.id, children: /* @__PURE__ */ s(St, { address: l }) }, l.id),
1731
1731
  /* @__PURE__ */ s("option", { disabled: !0, children: "---" })
1732
1732
  ] }),
1733
1733
  P.map((I) => /* @__PURE__ */ s("option", { value: I.id, children: /* @__PURE__ */ s(
1734
- wt,
1734
+ St,
1735
1735
  {
1736
1736
  address: I,
1737
1737
  isDefault: o
@@ -1748,7 +1748,7 @@ function It(t) {
1748
1748
  }
1749
1749
  );
1750
1750
  }
1751
- function wt(t) {
1751
+ function St(t) {
1752
1752
  const { address: e, isDefault: r } = t;
1753
1753
  return /* @__PURE__ */ h(Ce, { children: [
1754
1754
  r?.(e) ? "[DEFAULT] " : "",
@@ -1797,7 +1797,7 @@ function Tn({ address: t }) {
1797
1797
  " ",
1798
1798
  i
1799
1799
  ] }),
1800
- /* @__PURE__ */ s("span", { className: "shrink-0 mt-0.5", children: e ? /* @__PURE__ */ s(Fe, { size: 12, title: "Copied" }) : /* @__PURE__ */ s(er, { size: 12 }) })
1800
+ /* @__PURE__ */ s("span", { className: "shrink-0 mt-0.5", children: e ? /* @__PURE__ */ s(Fe, { size: 12, title: "Copied" }) : /* @__PURE__ */ s(tr, { size: 12 }) })
1801
1801
  ]
1802
1802
  }
1803
1803
  );
@@ -1881,7 +1881,7 @@ function An({
1881
1881
  )
1882
1882
  ] });
1883
1883
  }
1884
- const nr = () => /* @__PURE__ */ h(
1884
+ const sr = () => /* @__PURE__ */ h(
1885
1885
  "svg",
1886
1886
  {
1887
1887
  width: "14",
@@ -1896,8 +1896,8 @@ const nr = () => /* @__PURE__ */ h(
1896
1896
  /* @__PURE__ */ s("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1897
1897
  ]
1898
1898
  }
1899
- ), St = "w-8 h-8 p-0 flex items-center justify-center bg-surface-tertiary border border-border rounded-sm text-text-tertiary cursor-pointer transition-all duration-150 hover:bg-surface-disabled hover:border-border-strong hover:text-text-secondary disabled:opacity-50 disabled:cursor-not-allowed";
1900
- function Nt({
1899
+ ), Nt = "w-8 h-8 p-0 flex items-center justify-center bg-surface-tertiary border border-border rounded-sm text-text-tertiary cursor-pointer transition-all duration-150 hover:bg-surface-disabled hover:border-border-strong hover:text-text-secondary disabled:opacity-50 disabled:cursor-not-allowed";
1900
+ function Pt({
1901
1901
  children: t,
1902
1902
  className: e,
1903
1903
  ...r
@@ -1906,13 +1906,13 @@ function Nt({
1906
1906
  "button",
1907
1907
  {
1908
1908
  type: "button",
1909
- className: e ? be(St, e) : St,
1909
+ className: e ? be(Nt, e) : Nt,
1910
1910
  ...r,
1911
1911
  children: t
1912
1912
  }
1913
1913
  );
1914
1914
  }
1915
- function sr({
1915
+ function ar({
1916
1916
  value: t,
1917
1917
  onChange: e,
1918
1918
  min: r = 1,
@@ -1987,7 +1987,7 @@ function sr({
1987
1987
  }, v = t <= r, k = n !== void 0 && t >= n, S = d === "saving";
1988
1988
  return /* @__PURE__ */ h("span", { className: `inline-flex items-center gap-0.5 ${i}`, children: [
1989
1989
  /* @__PURE__ */ s(
1990
- Nt,
1990
+ Pt,
1991
1991
  {
1992
1992
  onClick: () => x(-1),
1993
1993
  disabled: v || S,
@@ -2023,7 +2023,7 @@ function sr({
2023
2023
  }
2024
2024
  ),
2025
2025
  /* @__PURE__ */ s(
2026
- Nt,
2026
+ Pt,
2027
2027
  {
2028
2028
  onClick: () => x(1),
2029
2029
  disabled: k || S,
@@ -2088,7 +2088,7 @@ function $n(t) {
2088
2088
  ] }),
2089
2089
  /* @__PURE__ */ h("div", { className: "flex items-center gap-2 shrink-0", children: [
2090
2090
  /* @__PURE__ */ s(
2091
- sr,
2091
+ ar,
2092
2092
  {
2093
2093
  value: e.quantity,
2094
2094
  onChange: (f) => r(e.id, f),
@@ -2103,7 +2103,7 @@ function $n(t) {
2103
2103
  onClick: () => n(e.id),
2104
2104
  className: "p-2 text-text-quaternary hover:text-text-secondary shrink-0",
2105
2105
  "aria-label": "Remove item",
2106
- children: /* @__PURE__ */ s(nr, {})
2106
+ children: /* @__PURE__ */ s(sr, {})
2107
2107
  }
2108
2108
  )
2109
2109
  ] })
@@ -2151,7 +2151,7 @@ function Bn(t) {
2151
2151
  }
2152
2152
  );
2153
2153
  }
2154
- const Pt = "flex items-center gap-1 min-h-11 px-3 py-1 text-[0.6875rem] font-medium text-text bg-surface-secondary border border-border-focus/20 rounded-md hover:bg-surface-tertiary hover:border-border-focus/35 transition-all whitespace-nowrap";
2154
+ const Et = "flex items-center gap-1 min-h-11 px-3 py-1 text-[0.6875rem] font-medium text-text bg-surface-secondary border border-border-focus/20 rounded-md hover:bg-surface-tertiary hover:border-border-focus/35 transition-all whitespace-nowrap";
2155
2155
  function Oe({
2156
2156
  children: t,
2157
2157
  className: e,
@@ -2161,13 +2161,13 @@ function Oe({
2161
2161
  "button",
2162
2162
  {
2163
2163
  type: "button",
2164
- className: e ? be(Pt, e) : Pt,
2164
+ className: e ? be(Et, e) : Et,
2165
2165
  ...r,
2166
2166
  children: t
2167
2167
  }
2168
2168
  );
2169
2169
  }
2170
- function ar({ onNewOrder: t }) {
2170
+ function ir({ onNewOrder: t }) {
2171
2171
  const [e, r] = U(!1), n = D(
2172
2172
  void 0
2173
2173
  ), i = () => {
@@ -2254,13 +2254,13 @@ function On({
2254
2254
  ),
2255
2255
  children: [
2256
2256
  a && /* @__PURE__ */ h("div", { className: "absolute top-0 right-0 px-4 py-3 z-10 flex items-center gap-2", children: [
2257
- r && /* @__PURE__ */ s(ar, { onNewOrder: r }),
2257
+ r && /* @__PURE__ */ s(ir, { onNewOrder: r }),
2258
2258
  n && /* @__PURE__ */ h(Oe, { onClick: n, "aria-label": "Expand", children: [
2259
- /* @__PURE__ */ s(tr, { size: 14 }),
2259
+ /* @__PURE__ */ s(rr, { size: 14 }),
2260
2260
  "Expand"
2261
2261
  ] }),
2262
2262
  i && /* @__PURE__ */ h(Oe, { onClick: i, "aria-label": "Minimize", children: [
2263
- /* @__PURE__ */ s(rr, { size: 14 }),
2263
+ /* @__PURE__ */ s(nr, { size: 14 }),
2264
2264
  "Minimize"
2265
2265
  ] })
2266
2266
  ] }),
@@ -2274,11 +2274,11 @@ function On({
2274
2274
  }
2275
2275
  );
2276
2276
  }
2277
- const ir = {
2277
+ const or = {
2278
2278
  pendingMessage: null,
2279
2279
  shouldScroll: !0
2280
2280
  }, Fn = (t) => ({
2281
- ai: { ...ir },
2281
+ ai: { ...or },
2282
2282
  sendMessage: (e, r) => t(
2283
2283
  (n) => ({
2284
2284
  ai: {
@@ -2352,13 +2352,13 @@ const ir = {
2352
2352
  !1,
2353
2353
  "batchProcessing/reset"
2354
2354
  )
2355
- }), Et = {
2355
+ }), kt = {
2356
2356
  bcCart: null,
2357
2357
  checkout: null,
2358
2358
  isLoading: !1,
2359
2359
  productPaths: {}
2360
2360
  }, Dn = (t) => ({
2361
- bcSession: { ...Et },
2361
+ bcSession: { ...kt },
2362
2362
  setBcCart: (e) => t(
2363
2363
  (r) => ({ bcSession: { ...r.bcSession, bcCart: e } }),
2364
2364
  !1,
@@ -2380,12 +2380,12 @@ const ir = {
2380
2380
  "bcSession/setProductPaths"
2381
2381
  ),
2382
2382
  clearBcSession: () => t(
2383
- () => ({ bcSession: { ...Et } }),
2383
+ () => ({ bcSession: { ...kt } }),
2384
2384
  !1,
2385
2385
  "bcSession/clearBcSession"
2386
2386
  )
2387
2387
  });
2388
- function kt(t, e) {
2388
+ function Tt(t, e) {
2389
2389
  return `${t}-${e}`;
2390
2390
  }
2391
2391
  const Ln = {
@@ -2410,7 +2410,7 @@ const Ln = {
2410
2410
  ...a.cartifact,
2411
2411
  poItemPrices: {
2412
2412
  ...a.cartifact.poItemPrices,
2413
- [kt(e, r)]: {
2413
+ [Tt(e, r)]: {
2414
2414
  productEntityId: e,
2415
2415
  variantEntityId: r,
2416
2416
  poPrice: n,
@@ -2425,7 +2425,7 @@ const Ln = {
2425
2425
  removePoItemPrice: (e, r) => t(
2426
2426
  (n) => {
2427
2427
  const i = { ...n.cartifact.poItemPrices };
2428
- return delete i[kt(e, r)], { cartifact: { ...n.cartifact, poItemPrices: i } };
2428
+ return delete i[Tt(e, r)], { cartifact: { ...n.cartifact, poItemPrices: i } };
2429
2429
  },
2430
2430
  !1,
2431
2431
  "cartifact/removePoItemPrice"
@@ -2449,7 +2449,7 @@ const Ln = {
2449
2449
  (r) => ({
2450
2450
  cartifact: {
2451
2451
  ...r.cartifact,
2452
- shipToAddress: e ? bt(e, {
2452
+ shipToAddress: e ? It(e, {
2453
2453
  id: xe
2454
2454
  }) : null
2455
2455
  }
@@ -2461,7 +2461,7 @@ const Ln = {
2461
2461
  (r) => ({
2462
2462
  cartifact: {
2463
2463
  ...r.cartifact,
2464
- billingAddress: e ? bt(e, {
2464
+ billingAddress: e ? It(e, {
2465
2465
  id: Ne
2466
2466
  }) : null
2467
2467
  }
@@ -2689,7 +2689,7 @@ function Jn() {
2689
2689
  appState: "upload",
2690
2690
  customerEntityId: null,
2691
2691
  fatalError: null,
2692
- ai: { ...ir },
2692
+ ai: { ...or },
2693
2693
  chat: {
2694
2694
  messages: [],
2695
2695
  input: "",
@@ -2736,7 +2736,7 @@ function Jn() {
2736
2736
  }
2737
2737
  const g = st()(
2738
2738
  qr(
2739
- jt(
2739
+ Wt(
2740
2740
  (t, e) => ({
2741
2741
  // Combine all slices
2742
2742
  ...Fn(t),
@@ -2879,7 +2879,7 @@ const g = st()(
2879
2879
  }),
2880
2880
  {
2881
2881
  name: it,
2882
- version: zt,
2882
+ version: Qt,
2883
2883
  partialize: (t) => ({
2884
2884
  // Persist customer ID for validation
2885
2885
  customerEntityId: t.customerEntityId,
@@ -2941,7 +2941,7 @@ function Yn({
2941
2941
  onClick: () => r(t),
2942
2942
  className: "p-1 text-text-quaternary hover:text-text-secondary shrink-0",
2943
2943
  "aria-label": "Dismiss warning",
2944
- children: /* @__PURE__ */ s(nr, {})
2944
+ children: /* @__PURE__ */ s(sr, {})
2945
2945
  }
2946
2946
  )
2947
2947
  ] }),
@@ -3016,13 +3016,13 @@ function Zn({
3016
3016
  /* @__PURE__ */ h("div", { className: "flex items-center justify-between mb-2", children: [
3017
3017
  /* @__PURE__ */ s("h2", { className: "text-[1.125rem] font-normal text-text m-0", children: "Cart" }),
3018
3018
  /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
3019
- $ && /* @__PURE__ */ s(ar, { onNewOrder: $ }),
3019
+ $ && /* @__PURE__ */ s(ir, { onNewOrder: $ }),
3020
3020
  R && /* @__PURE__ */ h(Oe, { onClick: R, "aria-label": "Expand", children: [
3021
- /* @__PURE__ */ s(tr, { size: 14 }),
3021
+ /* @__PURE__ */ s(rr, { size: 14 }),
3022
3022
  "Expand"
3023
3023
  ] }),
3024
3024
  Q && /* @__PURE__ */ h(Oe, { onClick: Q, "aria-label": "Minimize", children: [
3025
- /* @__PURE__ */ s(rr, { size: 14 }),
3025
+ /* @__PURE__ */ s(nr, { size: 14 }),
3026
3026
  "Minimize"
3027
3027
  ] })
3028
3028
  ] })
@@ -3039,7 +3039,7 @@ function Zn({
3039
3039
  title: H ? "Copied!" : "Copy PO Number",
3040
3040
  children: [
3041
3041
  d,
3042
- /* @__PURE__ */ s("span", { className: "text-text-tertiary", children: H ? /* @__PURE__ */ s(Fe, { size: 12, title: "Copied" }) : /* @__PURE__ */ s(er, { size: 12 }) })
3042
+ /* @__PURE__ */ s("span", { className: "text-text-tertiary", children: H ? /* @__PURE__ */ s(Fe, { size: 12, title: "Copied" }) : /* @__PURE__ */ s(tr, { size: 12 }) })
3043
3043
  ]
3044
3044
  }
3045
3045
  )
@@ -3205,7 +3205,7 @@ function ns({
3205
3205
  }
3206
3206
  ) });
3207
3207
  }
3208
- const or = "showProducts", ss = "searchProducts", as = "searchProductsBySku", Ie = "addToCart", lr = "updateCart", cr = "removeFromCart", dr = "clearCart", ur = "getCart", lt = "getPurchaseOrderData", De = "setPoMetadata", pr = "setItemWarnings", hr = "removeItemWarnings", ct = "addProcessingFailures", is = /* @__PURE__ */ new Set([or]);
3208
+ const lr = "showProducts", ss = "searchProducts", as = "searchProductsBySku", Ie = "addToCart", cr = "updateCart", dr = "removeFromCart", ur = "clearCart", pr = "getCart", lt = "getPurchaseOrderData", De = "setPoMetadata", hr = "setItemWarnings", fr = "removeItemWarnings", ct = "addProcessingFailures", is = /* @__PURE__ */ new Set([lr]);
3209
3209
  function os(t) {
3210
3210
  return t.type === "tool" && !is.has(t.toolName);
3211
3211
  }
@@ -3219,7 +3219,7 @@ function ls(t) {
3219
3219
  os(i) ? r.push(i) : (n(), e.push(i));
3220
3220
  return n(), e;
3221
3221
  }
3222
- const Tt = () => /* @__PURE__ */ h(
3222
+ const At = () => /* @__PURE__ */ h(
3223
3223
  "svg",
3224
3224
  {
3225
3225
  width: "14",
@@ -3234,7 +3234,7 @@ const Tt = () => /* @__PURE__ */ h(
3234
3234
  /* @__PURE__ */ s("polyline", { points: "14 2 14 8 20 8" })
3235
3235
  ]
3236
3236
  }
3237
- ), fr = () => /* @__PURE__ */ h(
3237
+ ), mr = () => /* @__PURE__ */ h(
3238
3238
  "svg",
3239
3239
  {
3240
3240
  width: "12",
@@ -3268,7 +3268,7 @@ function te({
3268
3268
  }
3269
3269
  );
3270
3270
  }
3271
- function mr(t) {
3271
+ function dt(t) {
3272
3272
  if (t)
3273
3273
  try {
3274
3274
  return typeof t == "string" ? JSON.parse(t) : t;
@@ -3292,7 +3292,7 @@ function cs({
3292
3292
  successMessage: ""
3293
3293
  }
3294
3294
  );
3295
- const o = mr(r)?.data?.searchProductsBySku?.total ?? 0;
3295
+ const o = dt(r)?.data?.searchProductsBySku?.total ?? 0;
3296
3296
  return /* @__PURE__ */ s(
3297
3297
  te,
3298
3298
  {
@@ -3318,7 +3318,7 @@ function ds({
3318
3318
  successMessage: ""
3319
3319
  }
3320
3320
  );
3321
- const o = mr(r)?.data?.searchProducts?.total ?? 0;
3321
+ const o = dt(r)?.data?.searchProducts?.total ?? 0;
3322
3322
  return /* @__PURE__ */ s(
3323
3323
  te,
3324
3324
  {
@@ -3337,7 +3337,7 @@ function us({
3337
3337
  }) {
3338
3338
  return /* @__PURE__ */ s(gr.Provider, { value: t, children: e });
3339
3339
  }
3340
- function dt() {
3340
+ function ut() {
3341
3341
  return Tr(gr);
3342
3342
  }
3343
3343
  function ps(t, e) {
@@ -3360,7 +3360,7 @@ function yr(t) {
3360
3360
  }
3361
3361
  return e;
3362
3362
  }
3363
- function ut(t, e) {
3363
+ function pt(t, e) {
3364
3364
  return t.find((r) => {
3365
3365
  const n = yr(r);
3366
3366
  return Array.from(e.entries()).every(
@@ -3368,13 +3368,13 @@ function ut(t, e) {
3368
3368
  );
3369
3369
  }) ?? null;
3370
3370
  }
3371
- function At(t) {
3371
+ function $t(t) {
3372
3372
  const e = /* @__PURE__ */ new Map();
3373
3373
  for (const n of t.productOptions) {
3374
3374
  const i = n.values.find((a) => a.isDefault);
3375
3375
  i ? e.set(n.entityId, i.entityId) : n.values[0] && e.set(n.entityId, n.values[0].entityId);
3376
3376
  }
3377
- if (!ut(t.variants, e) && t.variants[0]) {
3377
+ if (!pt(t.variants, e) && t.variants[0]) {
3378
3378
  const n = t.variants[0];
3379
3379
  e.clear();
3380
3380
  for (const i of n.options) {
@@ -3406,7 +3406,7 @@ function fs({
3406
3406
  selections: e,
3407
3407
  onSelectionChange: r
3408
3408
  }) {
3409
- const i = !ut(
3409
+ const i = !pt(
3410
3410
  t.variants,
3411
3411
  e
3412
3412
  );
@@ -3438,7 +3438,7 @@ const ms = 10;
3438
3438
  function gs(t, e, r) {
3439
3439
  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";
3440
3440
  }
3441
- function $t({
3441
+ function Bt({
3442
3442
  product: t,
3443
3443
  onAddToCart: e,
3444
3444
  cart: r = [],
@@ -3449,7 +3449,7 @@ function $t({
3449
3449
  selections: o,
3450
3450
  onSelectionChange: c
3451
3451
  }) {
3452
- const [d, f] = U(1), [u, m] = U(!1), [P, I] = U(!1), x = i === "horizontal", v = l && o ? ut(l.variants, o) : null, k = v?.entityId ?? t.variantEntityId, S = r.find(
3452
+ const [d, f] = U(1), [u, m] = U(!1), [P, I] = U(!1), x = i === "horizontal", v = l && o ? pt(l.variants, o) : null, k = v?.entityId ?? t.variantEntityId, S = r.find(
3453
3453
  (q) => q.productEntityId === t.productEntityId && q.variantEntityId === k
3454
3454
  ), T = !!S, C = S?.quantity ?? 0, y = v?.sku ?? t.sku, A = v?.prices?.price?.value ?? t.price, $ = v?.inventory?.aggregated?.availableToSell ?? t.availableQuantity, R = $ !== void 0 && $ > 0 && $ < ms, Q = v?.inventory?.isInStock ?? t.isInStock, H = v !== null ? (
3455
3455
  // Have variant details: check variant stock
@@ -3566,7 +3566,7 @@ function $t({
3566
3566
  className: x ? "flex items-center gap-2" : "flex flex-col gap-2",
3567
3567
  children: [
3568
3568
  /* @__PURE__ */ s(
3569
- sr,
3569
+ ar,
3570
3570
  {
3571
3571
  value: d,
3572
3572
  onChange: f,
@@ -3607,7 +3607,7 @@ function ys({
3607
3607
  loadingText: a = "Searching for products...",
3608
3608
  className: l = ""
3609
3609
  }) {
3610
- const o = dt(), c = ie(
3610
+ const o = ut(), c = ie(
3611
3611
  () => t.filter((v) => v.productEntityId !== void 0).map((v) => v.productEntityId),
3612
3612
  [t]
3613
3613
  ), { data: d } = ps(
@@ -3634,9 +3634,9 @@ function ys({
3634
3634
  const y = T.variants.find(
3635
3635
  (A) => A.entityId === S.variantEntityId
3636
3636
  );
3637
- y ? C = yr(y) : C = At(T);
3637
+ y ? C = yr(y) : C = $t(T);
3638
3638
  } else
3639
- C = At(T);
3639
+ C = $t(T);
3640
3640
  k.set(S.id, C);
3641
3641
  }
3642
3642
  return k;
@@ -3660,7 +3660,7 @@ function ys({
3660
3660
  if (I.length === 1 && x) {
3661
3661
  const v = x.productEntityId !== void 0 ? f.get(x.productEntityId) : void 0, k = u.get(x.id);
3662
3662
  return /* @__PURE__ */ s("div", { className: `py-2 ${l}`, children: /* @__PURE__ */ s(
3663
- $t,
3663
+ Bt,
3664
3664
  {
3665
3665
  layout: "horizontal",
3666
3666
  product: x,
@@ -3676,7 +3676,7 @@ function ys({
3676
3676
  return /* @__PURE__ */ s("div", { className: `flex flex-wrap gap-3 py-2 ${l}`, children: I.map((v) => {
3677
3677
  const k = v.productEntityId !== void 0 ? f.get(v.productEntityId) : void 0, S = u.get(v.id);
3678
3678
  return /* @__PURE__ */ s(
3679
- $t,
3679
+ Bt,
3680
3680
  {
3681
3681
  product: v,
3682
3682
  onAddToCart: e,
@@ -3697,7 +3697,7 @@ function xs({
3697
3697
  onAddToCart: n,
3698
3698
  onViewProduct: i
3699
3699
  }) {
3700
- const a = dt(), [l, o] = U([]), [c, d] = U(!0), [f, u] = U(null), m = e !== "output-available";
3700
+ const a = ut(), [l, o] = U([]), [c, d] = U(!0), [f, u] = U(null), m = e !== "output-available";
3701
3701
  return O(() => {
3702
3702
  async function P() {
3703
3703
  if (!a) {
@@ -3766,7 +3766,7 @@ function xr({
3766
3766
  onAddToCart: l,
3767
3767
  onViewProduct: o
3768
3768
  }) {
3769
- return e === or ? /* @__PURE__ */ s("div", { className: "mt-3", children: /* @__PURE__ */ s(
3769
+ return e === lr ? /* @__PURE__ */ s("div", { className: "mt-3", children: /* @__PURE__ */ s(
3770
3770
  xs,
3771
3771
  {
3772
3772
  toolInput: r,
@@ -3801,7 +3801,7 @@ function xr({
3801
3801
  successMessage: "Added to cart",
3802
3802
  toolOutput: n
3803
3803
  }
3804
- ) : e === lr ? /* @__PURE__ */ s(
3804
+ ) : e === cr ? /* @__PURE__ */ s(
3805
3805
  te,
3806
3806
  {
3807
3807
  toolCallId: t,
@@ -3810,7 +3810,7 @@ function xr({
3810
3810
  successMessage: "Updated cart",
3811
3811
  toolOutput: n
3812
3812
  }
3813
- ) : e === cr ? /* @__PURE__ */ s(
3813
+ ) : e === dr ? /* @__PURE__ */ s(
3814
3814
  te,
3815
3815
  {
3816
3816
  toolCallId: t,
@@ -3819,7 +3819,7 @@ function xr({
3819
3819
  successMessage: "Removed from cart",
3820
3820
  toolOutput: n
3821
3821
  }
3822
- ) : e === dr ? /* @__PURE__ */ s(
3822
+ ) : e === ur ? /* @__PURE__ */ s(
3823
3823
  te,
3824
3824
  {
3825
3825
  toolCallId: t,
@@ -3828,7 +3828,7 @@ function xr({
3828
3828
  successMessage: "Cart cleared",
3829
3829
  toolOutput: n
3830
3830
  }
3831
- ) : e === ur ? /* @__PURE__ */ s(
3831
+ ) : e === pr ? /* @__PURE__ */ s(
3832
3832
  te,
3833
3833
  {
3834
3834
  toolCallId: t,
@@ -3852,7 +3852,7 @@ function xr({
3852
3852
  successMessage: "Saved metadata",
3853
3853
  toolOutput: n
3854
3854
  }
3855
- ) : e === pr ? /* @__PURE__ */ s(
3855
+ ) : e === hr ? /* @__PURE__ */ s(
3856
3856
  te,
3857
3857
  {
3858
3858
  toolCallId: t,
@@ -3860,7 +3860,7 @@ function xr({
3860
3860
  successMessage: "Warnings updated",
3861
3861
  toolOutput: n
3862
3862
  }
3863
- ) : e === hr ? /* @__PURE__ */ s(
3863
+ ) : e === fr ? /* @__PURE__ */ s(
3864
3864
  te,
3865
3865
  {
3866
3866
  toolCallId: t,
@@ -3893,7 +3893,7 @@ function Cs({
3893
3893
  {
3894
3894
  className: `transition-transform duration-200 ${a ? "rotate-90" : ""}`,
3895
3895
  "aria-hidden": "true",
3896
- children: /* @__PURE__ */ s(fr, {})
3896
+ children: /* @__PURE__ */ s(mr, {})
3897
3897
  }
3898
3898
  ),
3899
3899
  /* @__PURE__ */ h("span", { className: "flex-1 text-left", children: [
@@ -3953,7 +3953,7 @@ function vs({
3953
3953
  {
3954
3954
  className: `transition-transform duration-200 ${l ? "rotate-90" : ""}`,
3955
3955
  "aria-hidden": "true",
3956
- children: /* @__PURE__ */ s(fr, {})
3956
+ children: /* @__PURE__ */ s(mr, {})
3957
3957
  }
3958
3958
  ),
3959
3959
  /* @__PURE__ */ s("span", { className: "flex-1 text-left truncate", children: l ? "Hide message" : n })
@@ -4029,8 +4029,8 @@ function ws({
4029
4029
  onClick: i,
4030
4030
  className: "flex items-center gap-2 px-3 py-2 bg-surface hover:bg-surface-secondary rounded-lg transition-colors border border-border text-left w-full",
4031
4031
  children: [
4032
- /* @__PURE__ */ s(Tt, {}),
4033
- /* @__PURE__ */ s("span", { className: "text-[0.9375rem] text-text font-medium", children: a || "Uploaded Document" }),
4032
+ /* @__PURE__ */ s(At, {}),
4033
+ /* @__PURE__ */ s("span", { className: "text-[0.9375rem] text-text font-medium truncate min-w-0", children: a || "Uploaded Document" }),
4034
4034
  /* @__PURE__ */ h(
4035
4035
  "svg",
4036
4036
  {
@@ -4106,7 +4106,7 @@ function ws({
4106
4106
  }
4107
4107
  ) }, u.toolCallId) : null),
4108
4108
  !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: [
4109
- /* @__PURE__ */ s(Tt, {}),
4109
+ /* @__PURE__ */ s(At, {}),
4110
4110
  /* @__PURE__ */ s("span", { children: Is(t.parts) })
4111
4111
  ] })
4112
4112
  ] }) })
@@ -4202,7 +4202,7 @@ function Ns({
4202
4202
  type: "file",
4203
4203
  className: "hidden",
4204
4204
  onChange: i,
4205
- accept: Yt
4205
+ accept: Zt
4206
4206
  }
4207
4207
  ),
4208
4208
  /* @__PURE__ */ s(
@@ -4228,7 +4228,7 @@ function Ns({
4228
4228
  ),
4229
4229
  /* @__PURE__ */ s("h3", { className: "m-0 text-base font-semibold text-text text-center", children: "Upload your Purchase Order" }),
4230
4230
  /* @__PURE__ */ s("p", { className: "m-0 text-sm text-text-tertiary text-center", children: "Get automagical product matching and stock availability" }),
4231
- /* @__PURE__ */ s("div", { className: "flex flex-wrap justify-center gap-2", children: Zt.map((c) => /* @__PURE__ */ s(
4231
+ /* @__PURE__ */ s("div", { className: "flex flex-wrap justify-center gap-2", children: Xt.map((c) => /* @__PURE__ */ s(
4232
4232
  "span",
4233
4233
  {
4234
4234
  className: "py-1 px-3 bg-surface-invert/5 border border-border-strong rounded-full text-xs font-medium text-text",
@@ -4357,8 +4357,8 @@ const Es = Ar(
4357
4357
  )
4358
4358
  ] });
4359
4359
  }
4360
- ), ks = "purchase-order-chat-user-settings", Ts = 25, Bt = st()(
4361
- jt(
4360
+ ), ks = "purchase-order-chat-user-settings", Ts = 25, Mt = st()(
4361
+ Wt(
4362
4362
  (t) => ({
4363
4363
  panelWidth: Ts,
4364
4364
  setPanelWidth: (e) => t({ panelWidth: e })
@@ -4369,7 +4369,7 @@ const Es = Ar(
4369
4369
  )
4370
4370
  );
4371
4371
  function As() {
4372
- const t = Bt((m) => m.panelWidth), e = Bt((m) => m.setPanelWidth), [r, n] = U(
4372
+ const t = Mt((m) => m.panelWidth), e = Mt((m) => m.setPanelWidth), [r, n] = U(
4373
4373
  typeof window < "u" && window.innerWidth >= 1024
4374
4374
  ), i = D(null), a = D(!1), l = D(t);
4375
4375
  O(() => {
@@ -4463,7 +4463,7 @@ function $s({ activeTab: t, onTabChange: e, hasUnread: r }) {
4463
4463
  )
4464
4464
  ] });
4465
4465
  }
4466
- function Mt({
4466
+ function Ot({
4467
4467
  // Chat panel props
4468
4468
  messages: t,
4469
4469
  input: e,
@@ -4510,7 +4510,7 @@ function Mt({
4510
4510
  u.length > 0 ? "cart" : "chat"
4511
4511
  ), [he, fe] = U(!1), le = D(t.length), me = D(K);
4512
4512
  me.current = K;
4513
- const p = t.length === 0 && u.length === 0 && !!f, N = Xt({
4513
+ const p = t.length === 0 && u.length === 0 && !!f, N = er({
4514
4514
  onFile: f ?? (() => {
4515
4515
  })
4516
4516
  });
@@ -4650,7 +4650,7 @@ function Mt({
4650
4650
  );
4651
4651
  }
4652
4652
  function Bs() {
4653
- const t = dt(), e = g((o) => o.ui.existingCart), r = g(
4653
+ const t = ut(), e = g((o) => o.ui.existingCart), r = g(
4654
4654
  (o) => o.confirmClearExistingCart
4655
4655
  ), [n, i] = U(!1), a = ie(
4656
4656
  () => e?.lineItems.physicalItems.reduce(
@@ -4770,7 +4770,7 @@ function Rs({
4770
4770
  ),
4771
4771
  /* @__PURE__ */ s("h2", { className: "m-0 text-2xl max-md:text-xl font-semibold text-text text-center", children: "Upload your Purchase Order" }),
4772
4772
  /* @__PURE__ */ s("p", { className: "m-0 text-[15px] text-text-tertiary text-center", children: "Get automagical product matching and stock availability" }),
4773
- /* @__PURE__ */ s("div", { className: "flex flex-wrap justify-center gap-2 mt-2", children: Zt.map((l) => /* @__PURE__ */ s(
4773
+ /* @__PURE__ */ s("div", { className: "flex flex-wrap justify-center gap-2 mt-2", children: Xt.map((l) => /* @__PURE__ */ s(
4774
4774
  "span",
4775
4775
  {
4776
4776
  className: "py-1 px-3 bg-surface-invert/5 border border-border-strong rounded-full text-xs font-medium text-text backdrop-blur",
@@ -4922,9 +4922,9 @@ function Ls({
4922
4922
  ] })
4923
4923
  ] });
4924
4924
  }
4925
- const Us = 3e3, Ot = 200;
4925
+ const Us = 3e3, Ft = 200;
4926
4926
  function _s(t) {
4927
- return t <= 0 ? Ot : Math.max(Ot, Math.round(Us / t));
4927
+ return t <= 0 ? Ft : Math.max(Ft, Math.round(Us / t));
4928
4928
  }
4929
4929
  function qs() {
4930
4930
  const t = g(
@@ -4970,10 +4970,10 @@ function js() {
4970
4970
  isRevealing: e < t.length
4971
4971
  };
4972
4972
  }
4973
- const Ft = ["reading", "matching", "building"];
4973
+ const Rt = ["reading", "matching", "building"];
4974
4974
  function Ws(t, e) {
4975
4975
  if (!e) return "pending";
4976
- const r = Ft.indexOf(e), n = Ft.indexOf(t);
4976
+ const r = Rt.indexOf(e), n = Rt.indexOf(t);
4977
4977
  return n < r ? "complete" : n === r ? "active" : "pending";
4978
4978
  }
4979
4979
  function zs(t, e) {
@@ -4981,8 +4981,10 @@ function zs(t, e) {
4981
4981
  }
4982
4982
  function Qs(t) {
4983
4983
  if (t === void 0) return null;
4984
- const e = Ge(t, "data.searchProductsBySku") ?? Ge(t, "data.searchProducts");
4985
- return Ge(e, "total", 0);
4984
+ const e = dt(t);
4985
+ if (e === void 0) return null;
4986
+ const r = Ge(e, "data.searchProductsBySku") ?? Ge(e, "data.searchProducts");
4987
+ return Ge(r, "total", 0);
4986
4988
  }
4987
4989
  const Hs = {
4988
4990
  searchProductsBySku: (t, { resultCount: e }) => {
@@ -5024,7 +5026,7 @@ const Ks = [
5024
5026
  { id: "reading", label: "Reading document..." },
5025
5027
  { id: "matching", label: "Matching products..." },
5026
5028
  { id: "building", label: "Building cart..." }
5027
- ], Rt = {
5029
+ ], Dt = {
5028
5030
  pending: {
5029
5031
  row: "opacity-40",
5030
5032
  icon: "bg-surface-secondary border-2 border-border-strong"
@@ -5045,18 +5047,18 @@ function Js({
5045
5047
  (l) => l.parser.uploadedFileName
5046
5048
  );
5047
5049
  return /* @__PURE__ */ s("div", { className: "flex flex-col gap-6 w-64", children: /* @__PURE__ */ s("div", { className: "flex flex-col gap-6", children: Ks.map((l) => {
5048
- const o = Ws(l.id, t), c = l.id === "reading" && (o === "active" || o === "complete") && a ? a : null, d = l.id === "matching" && o === "active" && e ? Gs(e, r) : null, f = l.id === "building" && o === "active" && i > 0 ? `Adding item ${n} of ${i}...` : null;
5050
+ const o = Ws(l.id, t), c = l.id === "reading" && (o === "active" || o === "complete") && a ? a : 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;
5049
5051
  return /* @__PURE__ */ h(
5050
5052
  "div",
5051
5053
  {
5052
5054
  "data-testid": "processing-step-row",
5053
5055
  "data-status": o,
5054
- className: `flex items-center gap-4 transition-opacity duration-300 ${Rt[o].row}`,
5056
+ className: `flex items-center gap-4 transition-opacity duration-300 ${Dt[o].row}`,
5055
5057
  children: [
5056
5058
  /* @__PURE__ */ h(
5057
5059
  "div",
5058
5060
  {
5059
- 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" : ""}`,
5061
+ className: `flex items-center justify-center w-8 h-8 rounded-full shrink-0 transition-all duration-300 ${Dt[o].icon}${o === "complete" ? " animate-step-pulse" : ""}${o === "active" ? " bg-surface-invert shadow-step" : ""}`,
5060
5062
  children: [
5061
5063
  o === "complete" && /* @__PURE__ */ s(Fe, { size: 16, title: "Complete" }),
5062
5064
  o === "active" && /* @__PURE__ */ s(Re, { size: 16 }),
@@ -5125,7 +5127,7 @@ function Zs({
5125
5127
  isUploading: i = !1,
5126
5128
  parserError: a = null
5127
5129
  }) {
5128
- const o = Ir() !== null, c = Xt({
5130
+ const o = Ir() !== null, c = er({
5129
5131
  onFile: t,
5130
5132
  onBeforeValidate: r
5131
5133
  }), d = a || c.fileError, f = B(() => {
@@ -5141,7 +5143,7 @@ function Zs({
5141
5143
  {
5142
5144
  isDragging: c.isDragging,
5143
5145
  fileInputRef: c.fileInputRef,
5144
- acceptedExtensions: Yt,
5146
+ acceptedExtensions: Zt,
5145
5147
  displayError: d,
5146
5148
  onDropZoneClick: f,
5147
5149
  onFileChange: c.handleFileChange,
@@ -5164,7 +5166,7 @@ function de(t) {
5164
5166
  shouldSaveAddress: !1
5165
5167
  };
5166
5168
  }
5167
- function Dt(t, e) {
5169
+ function Lt(t, e) {
5168
5170
  if (!(!t.address1 || !t.postalCode))
5169
5171
  return e.find(
5170
5172
  (r) => r.address1?.toLowerCase() === t.address1.toLowerCase() && r.postalCode?.toLowerCase() === t.postalCode?.toLowerCase()
@@ -5356,7 +5358,7 @@ function na(t) {
5356
5358
  }
5357
5359
  let p;
5358
5360
  if (c.length > 0) {
5359
- const N = Dt(
5361
+ const N = Lt(
5360
5362
  C,
5361
5363
  c
5362
5364
  );
@@ -5388,7 +5390,7 @@ function na(t) {
5388
5390
  return;
5389
5391
  let p;
5390
5392
  if (c.length > 0) {
5391
- const N = Dt(
5393
+ const N = Lt(
5392
5394
  y,
5393
5395
  c
5394
5396
  );
@@ -5967,8 +5969,8 @@ async function aa(t, e) {
5967
5969
  errorMessage: l
5968
5970
  };
5969
5971
  }
5970
- const ia = gt.object({
5971
- id: gt.string()
5972
+ const ia = yt.object({
5973
+ id: yt.string()
5972
5974
  });
5973
5975
  async function Sr(t, e) {
5974
5976
  const { origin: r, projectId: n, apiKey: i } = t, a = await fetch(
@@ -6250,7 +6252,7 @@ async function ma(t, e) {
6250
6252
  n = `Failed to clear cart: ${a}`, r(t.toolCallId, a);
6251
6253
  }
6252
6254
  return {
6253
- tool: dr,
6255
+ tool: ur,
6254
6256
  toolCallId: t.toolCallId,
6255
6257
  output: n
6256
6258
  };
@@ -6270,7 +6272,7 @@ function ga(t, e) {
6270
6272
  totals: e.checkoutTotals
6271
6273
  };
6272
6274
  return {
6273
- tool: ur,
6275
+ tool: pr,
6274
6276
  toolCallId: t.toolCallId,
6275
6277
  output: JSON.stringify(r)
6276
6278
  };
@@ -6297,7 +6299,7 @@ async function xa(t, e) {
6297
6299
  await e.removeLineItem(a.entityId);
6298
6300
  else
6299
6301
  return {
6300
- tool: cr,
6302
+ tool: dr,
6301
6303
  toolCallId: t.toolCallId,
6302
6304
  output: "Cart item not found."
6303
6305
  };
@@ -6319,7 +6321,7 @@ function Ca(t) {
6319
6321
  (a) => !(n.productSku !== void 0 && a.productSku !== void 0 && ze(a.productSku) === ze(n.productSku) || n.productName !== void 0 && a.productName !== void 0 && Qe(a.productName) === Qe(n.productName))
6320
6322
  );
6321
6323
  return r(i), {
6322
- tool: hr,
6324
+ tool: fr,
6323
6325
  toolCallId: t.toolCallId,
6324
6326
  output: "Item warnings removed successfully."
6325
6327
  };
@@ -6327,7 +6329,7 @@ function Ca(t) {
6327
6329
  function va(t) {
6328
6330
  const { setItemWarnings: e } = g.getState(), r = t.input;
6329
6331
  return r.itemWarnings && e(r.itemWarnings), {
6330
- tool: pr,
6332
+ tool: hr,
6331
6333
  toolCallId: t.toolCallId,
6332
6334
  output: "Item warnings set successfully."
6333
6335
  };
@@ -6371,7 +6373,7 @@ async function Ia(t, e) {
6371
6373
  } catch (l) {
6372
6374
  const o = l instanceof Error ? l.message : "Unknown error";
6373
6375
  return r(t.toolCallId, o), {
6374
- tool: lr,
6376
+ tool: cr,
6375
6377
  toolCallId: t.toolCallId,
6376
6378
  output: `Failed to update cart item: ${o}`
6377
6379
  };
@@ -6576,7 +6578,7 @@ const Ma = /* @__PURE__ */ new Set([
6576
6578
  "application/vnd.ms-excel",
6577
6579
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
6578
6580
  ]);
6579
- function Lt(t) {
6581
+ function Ut(t) {
6580
6582
  return Ma.has(t);
6581
6583
  }
6582
6584
  async function Oa(t) {
@@ -6640,7 +6642,7 @@ const _a = /* @__PURE__ */ new Set([
6640
6642
  "text/plain",
6641
6643
  "application/json"
6642
6644
  ]), Nr = "Please parse this document and extract relevant purchase order information.";
6643
- function Ut(t, e) {
6645
+ function _t(t, e) {
6644
6646
  return [
6645
6647
  {
6646
6648
  type: "text",
@@ -6677,12 +6679,12 @@ function Va({
6677
6679
  }
6678
6680
  await t();
6679
6681
  try {
6680
- if (Lt(o.type)) {
6682
+ if (Ut(o.type)) {
6681
6683
  const d = await Oa(o);
6682
- e({ parts: Ut(o.name, d) });
6684
+ e({ parts: _t(o.name, d) });
6683
6685
  } else if (_a.has(o.type)) {
6684
6686
  const d = await $a(o);
6685
- e({ parts: Ut(o.name, d) });
6687
+ e({ parts: _t(o.name, d) });
6686
6688
  } else {
6687
6689
  const d = await Ba(o);
6688
6690
  e({
@@ -6690,7 +6692,7 @@ function Va({
6690
6692
  });
6691
6693
  }
6692
6694
  } catch (d) {
6693
- console.error("Failed to read file:", d), Lt(o.type) ? a(
6695
+ console.error("Failed to read file:", d), Ut(o.type) ? a(
6694
6696
  "Failed to read the spreadsheet file. Please try saving it as CSV and uploading again."
6695
6697
  ) : g.getState().setParsedContent(null), n(!1);
6696
6698
  }
@@ -6769,8 +6771,8 @@ function ja() {
6769
6771
  sendMessage: d,
6770
6772
  status: f,
6771
6773
  setMessages: u
6772
- } = qt({
6773
- transport: new Vt({
6774
+ } = Vt({
6775
+ transport: new jt({
6774
6776
  api: `${t}/project/${e}/agents/messages`,
6775
6777
  headers: {
6776
6778
  Authorization: `Bearer ${r}`
@@ -6870,7 +6872,7 @@ class za {
6870
6872
  getB2BJwt;
6871
6873
  initPromise;
6872
6874
  constructor(e) {
6873
- this.channelId = e.channelId, this.getB2BJwt = e.getB2BJwt ?? null, this.graphQLClient = new nt(Wt, {
6875
+ this.channelId = e.channelId, this.getB2BJwt = e.getB2BJwt ?? null, this.graphQLClient = new nt(zt, {
6874
6876
  credentials: "same-origin",
6875
6877
  headers: {
6876
6878
  "content-type": "application/json",
@@ -6924,7 +6926,7 @@ class za {
6924
6926
  }
6925
6927
  async getB2BStorefrontToken(e) {
6926
6928
  const r = await this.request({
6927
- document: Qt,
6929
+ document: Ht,
6928
6930
  variables: {
6929
6931
  authData: {
6930
6932
  bcToken: e,
@@ -6952,7 +6954,7 @@ class za {
6952
6954
  }
6953
6955
  },
6954
6956
  -1
6955
- ), i = ve(Ht, r.currentUser)?.companyInfo?.companyId;
6957
+ ), i = ve(Gt, r.currentUser)?.companyInfo?.companyId;
6956
6958
  if (!i)
6957
6959
  throw new Error("No company ID returned from current user query");
6958
6960
  return console.debug("[B2BClient] Received company ID", i), Number(i);
@@ -7036,7 +7038,7 @@ async function Ni(t) {
7036
7038
  console.debug(
7037
7039
  "[stencilB2BJwt] Exchanging customer JWT for B2B storefront token"
7038
7040
  );
7039
- const n = await new nt(Wt, {
7041
+ const n = await new nt(zt, {
7040
7042
  credentials: "same-origin",
7041
7043
  headers: {
7042
7044
  "content-type": "application/json",
@@ -7044,7 +7046,7 @@ async function Ni(t) {
7044
7046
  Authorization: `Bearer ${e}`
7045
7047
  }
7046
7048
  }).request({
7047
- document: Qt,
7049
+ document: Ht,
7048
7050
  variables: {
7049
7051
  authData: {
7050
7052
  bcToken: e,
@@ -7079,7 +7081,7 @@ function Ha() {
7079
7081
  threadId: null,
7080
7082
  cartEntityId: null
7081
7083
  };
7082
- if (r !== zt)
7084
+ if (r !== Qt)
7083
7085
  return {
7084
7086
  valid: !1,
7085
7087
  error: "The app version has changed. Your previous session is not compatible.",
@@ -7311,8 +7313,8 @@ function si({
7311
7313
  (b) => b.clearAddressSelections
7312
7314
  ), q = g((b) => b.clearChat), { cartItems: j } = $, { onToolCall: pe, pendingToolOutputsRef: oe } = Wa({
7313
7315
  bcCart: $
7314
- }), L = D(/* @__PURE__ */ new Set()), { messages: V, sendMessage: G, status: K, error: we, setMessages: he, addToolOutput: fe } = qt({
7315
- transport: new Vt({
7316
+ }), L = D(/* @__PURE__ */ new Set()), { messages: V, sendMessage: G, status: K, error: we, setMessages: he, addToolOutput: fe } = Vt({
7317
+ transport: new jt({
7316
7318
  api: `${a}/project/${l}/agents/messages`,
7317
7319
  headers: {
7318
7320
  Authorization: `Bearer ${o}`
@@ -7325,14 +7327,14 @@ function si({
7325
7327
  if (ae.role === "user" && b.messages.length >= 2) {
7326
7328
  const ce = b.messages[b.messages.length - 2], He = L.current;
7327
7329
  if (ce?.role === "assistant" && He.size > 0) {
7328
- const ht = Xa(
7330
+ const ft = Xa(
7329
7331
  ce.parts
7330
7332
  ).filter(
7331
- (ft) => He.has(ft.toolCallId)
7333
+ (mt) => He.has(mt.toolCallId)
7332
7334
  );
7333
- He.clear(), ht.length > 0 && (_e = [{
7335
+ He.clear(), ft.length > 0 && (_e = [{
7334
7336
  ...ce,
7335
- parts: ht.map((Se) => ({
7337
+ parts: ft.map((Se) => ({
7336
7338
  type: Se.type,
7337
7339
  toolName: ei(Se),
7338
7340
  toolCallId: Se.toolCallId,
@@ -7483,7 +7485,7 @@ function si({
7483
7485
  parserError: A.parserError
7484
7486
  }
7485
7487
  ) });
7486
- const pt = {
7488
+ const ht = {
7487
7489
  className: t,
7488
7490
  messages: V,
7489
7491
  input: d,
@@ -7522,10 +7524,10 @@ function si({
7522
7524
  poMetadataSet: se,
7523
7525
  onNewOrder: Ue
7524
7526
  };
7525
- return i && T ? /* @__PURE__ */ s(vn, { children: /* @__PURE__ */ s(Mt, { ...pt, onMinimize: () => C(!1) }) }) : /* @__PURE__ */ s("div", { className: "h-full max-w-[1440px] mx-auto", children: /* @__PURE__ */ s(
7526
- Mt,
7527
+ return i && T ? /* @__PURE__ */ s(vn, { children: /* @__PURE__ */ s(Ot, { ...ht, onMinimize: () => C(!1) }) }) : /* @__PURE__ */ s("div", { className: "h-full max-w-[1440px] mx-auto", children: /* @__PURE__ */ s(
7528
+ Ot,
7527
7529
  {
7528
- ...pt,
7530
+ ...ht,
7529
7531
  onExpand: i ? () => C(!0) : void 0
7530
7532
  }
7531
7533
  ) });
@@ -7558,8 +7560,8 @@ function Pi({
7558
7560
  takeshape: {
7559
7561
  projectId: t.projectId,
7560
7562
  apiKey: t.apiKey,
7561
- origin: t.origin ?? Ct,
7562
- sseOrigin: t.sseOrigin ?? Ct
7563
+ origin: t.origin ?? vt,
7564
+ sseOrigin: t.sseOrigin ?? vt
7563
7565
  },
7564
7566
  bigcommerce: {
7565
7567
  client: c,
@@ -7581,4 +7583,4 @@ export {
7581
7583
  bi as r,
7582
7584
  Ni as s
7583
7585
  };
7584
- //# sourceMappingURL=purchase-order-chat-wrapper-BL78I7f6.js.map
7586
+ //# sourceMappingURL=purchase-order-chat-wrapper-r0tGIblm.js.map