@gengage/assistant-fe 0.6.14 → 0.6.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/agentic/adaptor/fetch-bridge.d.ts +20 -1
  2. package/dist/agentic/index.js +517 -367
  3. package/dist/agentic/worker.js +18 -18
  4. package/dist/agentic.iife.js +5 -5
  5. package/dist/{api-paths-kwROurUu.js → api-paths-xsHH9jtm.js} +1 -1
  6. package/dist/chat/components/InlineLauncher.d.ts +152 -0
  7. package/dist/chat/index.d.ts +2 -0
  8. package/dist/chat/runtime.d.ts +3 -0
  9. package/dist/chat/types.d.ts +6 -0
  10. package/dist/chat-runtime.js +9 -9
  11. package/dist/chat.iife.js +160 -35
  12. package/dist/chat.js +13 -12
  13. package/dist/common/overlay.d.ts +2 -0
  14. package/dist/{common-DZuPNgWh.js → common-O0BUdXOn.js} +2 -2
  15. package/dist/common.js +7 -7
  16. package/dist/{connection-warning-Bg4gn-cq.js → connection-warning-DWMfjv0Y.js} +1 -1
  17. package/dist/{fastIntent-BSgLJDlW.js → fastIntent-RTSVRJhw.js} +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +16 -16
  20. package/dist/{native-webview-DbKq9lN8.js → native-webview-U9HtGabb.js} +1 -1
  21. package/dist/native.iife.js +140 -15
  22. package/dist/native.js +1 -1
  23. package/dist/{overlay-CyoB1K0w.js → overlay-ClYgI2Kl.js} +5 -5
  24. package/dist/overlay.js +1 -1
  25. package/dist/qna-runtime.js +1 -1
  26. package/dist/qna.iife.js +1 -1
  27. package/dist/qna.js +1 -1
  28. package/dist/{request-text-su3Vlhrs.js → request-text-DThlE-Xd.js} +106 -106
  29. package/dist/{runtime-CAJp9Ehc.js → runtime-BKU-NQXf.js} +2101 -1745
  30. package/dist/{runtime-KV5wCTc-.js → runtime-COh3CwNU.js} +3 -3
  31. package/dist/{runtime-DwQSV54I.js → runtime-n7fEJGDt.js} +3 -3
  32. package/dist/{simbut-Bm96zEAo.js → simbut-DaFCfvp7.js} +1 -1
  33. package/dist/simbut.iife.js +1 -1
  34. package/dist/simbut.js +1 -1
  35. package/dist/{simrel-C9sM9CCV.js → simrel-CX1JBDa5.js} +1 -1
  36. package/dist/simrel-runtime.js +1 -1
  37. package/dist/simrel.iife.js +1 -1
  38. package/dist/simrel.js +2 -2
  39. package/dist/{widget-base-TZjXRr3u.js → widget-base-DoZrhVze.js} +1 -1
  40. package/package.json +1 -1
@@ -888,7 +888,69 @@ function j(e) {
888
888
  function W(e) {
889
889
  return Array.isArray(e) ? e.map(String).filter(Boolean) : typeof e == "string" && e ? [e] : [];
890
890
  }
891
- function It(e = []) {
891
+ function It(e, t, r = {}) {
892
+ return `${e}:${r.version || "v2"}:${oe(t)}`;
893
+ }
894
+ function Et(e, t = {}) {
895
+ return ie(e).map((r) => ae(typeof r == "string" ? r : r.sku, t.locale)).filter(Boolean).filter((r, n, o) => o.indexOf(r) === n).sort((r, n) => D(r, n, t.locale)).slice(0, t.limit || 16).join(",");
896
+ }
897
+ function jt(e, t = {}) {
898
+ return oe(ie(e).map((r) => Ye(r, t)).filter((r) => !!r).sort((r, n) => D(String(r.sku || r.name || ""), String(n.sku || n.name || ""), t.locale)).slice(0, t.limit || 16));
899
+ }
900
+ function Ot(e, t) {
901
+ return S(e, t);
902
+ }
903
+ function oe(e) {
904
+ let t = 2166136261;
905
+ const r = Xe(e);
906
+ for (let n = 0; n < r.length; n += 1)
907
+ t ^= r.charCodeAt(n), t = Math.imul(t, 16777619);
908
+ return (t >>> 0).toString(36);
909
+ }
910
+ function Ye(e, t) {
911
+ if (!e || typeof e != "object" || Array.isArray(e)) return null;
912
+ const r = e, n = t.mapProduct?.(r);
913
+ if (n) return C(n);
914
+ const o = ne(r);
915
+ return o && typeof o == "object" && !Array.isArray(o) ? C(Ze(o, t)) : null;
916
+ }
917
+ function ie(e) {
918
+ return Array.isArray(e) ? e.filter((t) => typeof t == "string" || !!(t && typeof t == "object" && !Array.isArray(t))) : [];
919
+ }
920
+ function Xe(e) {
921
+ return JSON.stringify(C(e));
922
+ }
923
+ function C(e) {
924
+ return Array.isArray(e) ? e.map(C) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => [t, C(r)]));
925
+ }
926
+ function Ze(e, t) {
927
+ return {
928
+ sku: ae(e.sku, t.locale),
929
+ name: S(e.name, t.locale),
930
+ url: S(e.url, t.locale),
931
+ price: e.price,
932
+ currency: S(e.currency, t.locale),
933
+ category: S(e.category, t.locale),
934
+ category_names: et(e.category_names, t.locale, 16),
935
+ image: S(e.image, t.locale),
936
+ in_stock: e.in_stock,
937
+ rating: e.rating,
938
+ review_count: e.review_count
939
+ };
940
+ }
941
+ function ae(e, t) {
942
+ return S(e, t).toUpperCase();
943
+ }
944
+ function S(e, t) {
945
+ return typeof e == "string" ? e.trim().replace(/\s+/gu, " ").toLocaleLowerCase(t || void 0) : "";
946
+ }
947
+ function D(e, t, r) {
948
+ return e.localeCompare(t, r, { numeric: !0 });
949
+ }
950
+ function et(e, t, r) {
951
+ return Array.isArray(e) ? e.map((n) => S(n, t)).filter(Boolean).sort((n, o) => D(n, o, t)).slice(0, r) : void 0;
952
+ }
953
+ function Ct(e = []) {
892
954
  const t = {}, r = [];
893
955
  return (Array.isArray(e) ? e.map(F).filter((n) => !!n) : []).forEach((n, o) => {
894
956
  const i = `product-${o.toString()}`;
@@ -922,7 +984,7 @@ function It(e = []) {
922
984
  }
923
985
  };
924
986
  }
925
- function Et(e) {
987
+ function Pt(e) {
926
988
  return {
927
989
  widget: "chat",
928
990
  panelHint: "panel",
@@ -935,7 +997,7 @@ function Et(e) {
935
997
  }
936
998
  };
937
999
  }
938
- function jt(e = {}) {
1000
+ function Mt(e = {}) {
939
1001
  const t = (e.multiple_product_details || e.products || []).map(F).filter((n) => !!n), r = e.table || {};
940
1002
  return {
941
1003
  widget: "chat",
@@ -967,7 +1029,7 @@ function jt(e = {}) {
967
1029
  }
968
1030
  };
969
1031
  }
970
- function Ot(e = []) {
1032
+ function Nt(e = []) {
971
1033
  return {
972
1034
  widget: "chat",
973
1035
  panelHint: "inline",
@@ -990,7 +1052,7 @@ function Ot(e = []) {
990
1052
  }
991
1053
  };
992
1054
  }
993
- function Ct(e) {
1055
+ function Bt(e) {
994
1056
  return Object.freeze([...e]);
995
1057
  }
996
1058
  var V = /* @__PURE__ */ new Set([
@@ -1000,7 +1062,7 @@ var V = /* @__PURE__ */ new Set([
1000
1062
  "from",
1001
1063
  "the",
1002
1064
  "with"
1003
- ]), Ye = {
1065
+ ]), tt = {
1004
1066
  token: 0.26,
1005
1067
  keyword: 0.22,
1006
1068
  category: 0.18,
@@ -1009,7 +1071,7 @@ var V = /* @__PURE__ */ new Set([
1009
1071
  attribute: 0.06,
1010
1072
  price: 0.08,
1011
1073
  retrieval: 0.08
1012
- }, Xe = [
1074
+ }, rt = [
1013
1075
  "amber",
1014
1076
  "beige",
1015
1077
  "black",
@@ -1043,8 +1105,8 @@ function w(e, t = V) {
1043
1105
  return o;
1044
1106
  }
1045
1107
  function B(e, t = {}) {
1046
- if (et(e)) return e;
1047
- const r = t.facetKeys, n = y(e.category_names ?? e.category), o = y(e.category_ids), i = tt(e.facet_hits), a = Object.entries(i).filter(([p]) => !r || r.some((A) => _(A) === _(p))).map(([, p]) => p), c = k(e.name, e.title), s = k(e.brand), u = t.sourceKeywords ?? [], l = [
1108
+ if (ot(e)) return e;
1109
+ const r = t.facetKeys, n = y(e.category_names ?? e.category), o = y(e.category_ids), i = it(e.facet_hits), a = Object.entries(i).filter(([p]) => !r || r.some((A) => _(A) === _(p))).map(([, p]) => p), c = k(e.name, e.title), s = k(e.brand), u = t.sourceKeywords ?? [], l = [
1048
1110
  c,
1049
1111
  s,
1050
1112
  ...n,
@@ -1052,7 +1114,7 @@ function B(e, t = {}) {
1052
1114
  ...y(e.promotions),
1053
1115
  k(e.description),
1054
1116
  ...u
1055
- ].join(" "), f = w(l, t.stopWords), m = k(t.sourceProductType, ot(n, c, f), f[0]), d = b([...nt(l, Xe), ...Object.entries(i).filter(([p]) => /colou?r/iu.test(p)).flatMap(([, p]) => w(p, t.stopWords))]), h = b([...a.flatMap((p) => w(p, t.stopWords)), ...y(e.promotions).flatMap((p) => w(p, t.stopWords))]).slice(0, 24);
1117
+ ].join(" "), f = w(l, t.stopWords), m = k(t.sourceProductType, st(n, c, f), f[0]), d = b([...ct(l, rt), ...Object.entries(i).filter(([p]) => /colou?r/iu.test(p)).flatMap(([, p]) => w(p, t.stopWords))]), h = b([...a.flatMap((p) => w(p, t.stopWords)), ...y(e.promotions).flatMap((p) => w(p, t.stopWords))]).slice(0, 24);
1056
1118
  return {
1057
1119
  sku: k(e.sku),
1058
1120
  title: c,
@@ -1065,10 +1127,10 @@ function B(e, t = {}) {
1065
1127
  tokens: f,
1066
1128
  colors: d,
1067
1129
  attributes: h,
1068
- price: rt(e)
1130
+ price: at(e)
1069
1131
  };
1070
1132
  }
1071
- function Pt(e, t = {}) {
1133
+ function vt(e, t = {}) {
1072
1134
  const r = k(e.product_type, e.productType), n = k(e.title, r, y(e.keywords).join(" ")), o = b([
1073
1135
  ...y(e.keywords),
1074
1136
  ...y(e.colors),
@@ -1093,7 +1155,7 @@ function Pt(e, t = {}) {
1093
1155
  sourceKeywords: o
1094
1156
  });
1095
1157
  }
1096
- function Mt(e, t = {}) {
1158
+ function Rt(e, t = {}) {
1097
1159
  const r = B(e, t);
1098
1160
  return b([
1099
1161
  ...t.sourceQueries ?? [],
@@ -1108,23 +1170,23 @@ function Mt(e, t = {}) {
1108
1170
  r.productType
1109
1171
  ].map((n) => n.trim()).filter(Boolean)).slice(0, t.queryLimit ?? 6);
1110
1172
  }
1111
- function Ze(e, t, r = {}) {
1173
+ function nt(e, t, r = {}) {
1112
1174
  const n = {
1113
- ...Ye,
1175
+ ...tt,
1114
1176
  ...r.weights
1115
- }, o = B(t, r), i = [], a = I(e.tokens, o.tokens), c = I(e.keywords, o.tokens), s = it(e.categoryNames, o.categoryNames) || I(G(e.categoryNames), G(o.categoryNames)), u = I(e.attributes, o.attributes), l = I(e.colors, o.colors), f = I(e.attributes, o.tokens), m = at(e.price, o.price), d = ct(o.sku, r.hitCounts) > 0 ? 1 : 0, h = st(e, o), p = a * n.token + c * n.keyword + s * n.category + u * n.facet + l * n.color + f * n.attribute + m * n.price + d * n.retrieval, A = ut(h ? p : p * 0.35);
1177
+ }, o = B(t, r), i = [], a = I(e.tokens, o.tokens), c = I(e.keywords, o.tokens), s = ut(e.categoryNames, o.categoryNames) || I(G(e.categoryNames), G(o.categoryNames)), u = I(e.attributes, o.attributes), l = I(e.colors, o.colors), f = I(e.attributes, o.tokens), m = lt(e.price, o.price), d = ft(o.sku, r.hitCounts) > 0 ? 1 : 0, h = dt(e, o), p = a * n.token + c * n.keyword + s * n.category + u * n.facet + l * n.color + f * n.attribute + m * n.price + d * n.retrieval, A = pt(h ? p : p * 0.35);
1116
1178
  return h && e.productType && e.productType === o.productType && i.push("same product type"), s > 0.4 && i.push("similar category"), u > 0.2 && i.push("matching product attributes"), l > 0 && i.push("matching colour"), m > 0.8 && i.push("similar price"), h || i.push("weaker product-type match"), {
1117
1179
  score: Number(A.toFixed(4)),
1118
1180
  reasons: i
1119
1181
  };
1120
1182
  }
1121
- function Nt(e, t, r = {}) {
1183
+ function $t(e, t, r = {}) {
1122
1184
  const n = B(e, r), o = new Set([n.sku, ...r.ignoreSkus ?? []].filter(Boolean));
1123
1185
  return t.filter((i) => {
1124
1186
  const a = k(i.sku);
1125
1187
  return a && !o.has(a);
1126
1188
  }).map((i) => {
1127
- const a = Ze(n, i, r);
1189
+ const a = nt(n, i, r);
1128
1190
  return {
1129
1191
  ...i,
1130
1192
  similarity_score: a.score,
@@ -1132,7 +1194,7 @@ function Nt(e, t, r = {}) {
1132
1194
  };
1133
1195
  }).sort((i, a) => a.similarity_score - i.similarity_score).slice(0, Math.max(1, Math.min(r.limit ?? 12, 100)));
1134
1196
  }
1135
- function et(e) {
1197
+ function ot(e) {
1136
1198
  return !!(e && typeof e == "object" && Array.isArray(e.tokens));
1137
1199
  }
1138
1200
  function k(...e) {
@@ -1142,10 +1204,10 @@ function k(...e) {
1142
1204
  function y(e) {
1143
1205
  return Array.isArray(e) ? e.map((t) => k(t)).filter(Boolean) : typeof e == "string" && e.trim() ? e.split(/[,;/|]+/u).map((t) => t.trim()).filter(Boolean) : [];
1144
1206
  }
1145
- function tt(e) {
1207
+ function it(e) {
1146
1208
  return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.fromEntries(Object.entries(e).map(([t, r]) => [t, k(r)]).filter(([, t]) => t));
1147
1209
  }
1148
- function rt(e) {
1210
+ function at(e) {
1149
1211
  const t = Number(e.price_discounted);
1150
1212
  if (Number.isFinite(t) && t > 0) return t;
1151
1213
  const r = Number(e.price);
@@ -1159,11 +1221,11 @@ function b(e) {
1159
1221
  }
1160
1222
  return r;
1161
1223
  }
1162
- function nt(e, t) {
1224
+ function ct(e, t) {
1163
1225
  const r = ` ${_(e)} `;
1164
1226
  return t.filter((n) => r.includes(` ${_(n)} `));
1165
1227
  }
1166
- function ot(e, t, r) {
1228
+ function st(e, t, r) {
1167
1229
  const n = _(e[e.length - 1] ?? e[0] ?? "");
1168
1230
  if (n) {
1169
1231
  const o = w(n), i = new Set(w(t));
@@ -1181,86 +1243,24 @@ function I(e, t) {
1181
1243
  const r = b(e), n = new Set(b(t));
1182
1244
  return r.length === 0 || n.size === 0 ? 0 : r.filter((o) => n.has(o)).length / r.length;
1183
1245
  }
1184
- function it(e, t) {
1246
+ function ut(e, t) {
1185
1247
  const r = b(e), n = new Set(b(t));
1186
1248
  return r.length === 0 || n.size === 0 ? 0 : r.filter((o) => n.has(o)).length / r.length;
1187
1249
  }
1188
- function at(e, t) {
1250
+ function lt(e, t) {
1189
1251
  return e <= 0 || t <= 0 ? 0 : Math.min(e, t) / Math.max(e, t);
1190
1252
  }
1191
- function ct(e, t) {
1253
+ function ft(e, t) {
1192
1254
  return !e || !t ? 0 : typeof t.get == "function" ? t.get(e) ?? 0 : t[e] ?? 0;
1193
1255
  }
1194
- function st(e, t) {
1256
+ function dt(e, t) {
1195
1257
  if (!e.productType || !t.productType || e.productType === t.productType) return !0;
1196
1258
  const r = new Set(w(e.productType)), n = /* @__PURE__ */ new Set([...w(t.productType), ...t.tokens]);
1197
1259
  return [...r].some((o) => n.has(o));
1198
1260
  }
1199
- function ut(e) {
1261
+ function pt(e) {
1200
1262
  return Math.max(0, Math.min(1, e));
1201
1263
  }
1202
- function Bt(e, t, r = {}) {
1203
- return `${e}:${r.version || "v2"}:${oe(t)}`;
1204
- }
1205
- function vt(e, t = {}) {
1206
- return ie(e).map((r) => ae(typeof r == "string" ? r : r.sku, t.locale)).filter(Boolean).filter((r, n, o) => o.indexOf(r) === n).sort((r, n) => D(r, n, t.locale)).slice(0, t.limit || 16).join(",");
1207
- }
1208
- function Rt(e, t = {}) {
1209
- return oe(ie(e).map((r) => lt(r, t)).filter((r) => !!r).sort((r, n) => D(String(r.sku || r.name || ""), String(n.sku || n.name || ""), t.locale)).slice(0, t.limit || 16));
1210
- }
1211
- function $t(e, t) {
1212
- return S(e, t);
1213
- }
1214
- function oe(e) {
1215
- let t = 2166136261;
1216
- const r = ft(e);
1217
- for (let n = 0; n < r.length; n += 1)
1218
- t ^= r.charCodeAt(n), t = Math.imul(t, 16777619);
1219
- return (t >>> 0).toString(36);
1220
- }
1221
- function lt(e, t) {
1222
- if (!e || typeof e != "object" || Array.isArray(e)) return null;
1223
- const r = e, n = t.mapProduct?.(r);
1224
- if (n) return C(n);
1225
- const o = ne(r);
1226
- return o && typeof o == "object" && !Array.isArray(o) ? C(dt(o, t)) : null;
1227
- }
1228
- function ie(e) {
1229
- return Array.isArray(e) ? e.filter((t) => typeof t == "string" || !!(t && typeof t == "object" && !Array.isArray(t))) : [];
1230
- }
1231
- function ft(e) {
1232
- return JSON.stringify(C(e));
1233
- }
1234
- function C(e) {
1235
- return Array.isArray(e) ? e.map(C) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => [t, C(r)]));
1236
- }
1237
- function dt(e, t) {
1238
- return {
1239
- sku: ae(e.sku, t.locale),
1240
- name: S(e.name, t.locale),
1241
- url: S(e.url, t.locale),
1242
- price: e.price,
1243
- currency: S(e.currency, t.locale),
1244
- category: S(e.category, t.locale),
1245
- category_names: pt(e.category_names, t.locale, 16),
1246
- image: S(e.image, t.locale),
1247
- in_stock: e.in_stock,
1248
- rating: e.rating,
1249
- review_count: e.review_count
1250
- };
1251
- }
1252
- function ae(e, t) {
1253
- return S(e, t).toUpperCase();
1254
- }
1255
- function S(e, t) {
1256
- return typeof e == "string" ? e.trim().replace(/\s+/gu, " ").toLocaleLowerCase(t || void 0) : "";
1257
- }
1258
- function D(e, t, r) {
1259
- return e.localeCompare(t, r, { numeric: !0 });
1260
- }
1261
- function pt(e, t, r) {
1262
- return Array.isArray(e) ? e.map((n) => S(n, t)).filter(Boolean).sort((n, o) => D(n, o, t)).slice(0, r) : void 0;
1263
- }
1264
1264
  function Ut(e) {
1265
1265
  const t = e?.payload;
1266
1266
  if (typeof t == "string") return t;
@@ -1290,27 +1290,27 @@ export {
1290
1290
  xt as T,
1291
1291
  me as U,
1292
1292
  yt as V,
1293
- Et as _,
1294
- oe as a,
1293
+ oe as _,
1294
+ _ as a,
1295
1295
  ne as b,
1296
- B as c,
1297
- Nt as d,
1298
- Ze as f,
1299
- jt as g,
1300
- Ot as h,
1301
- vt as i,
1296
+ w as c,
1297
+ Mt as d,
1298
+ Pt as f,
1299
+ Et as g,
1300
+ jt as h,
1301
+ Rt as i,
1302
1302
  kt as j,
1303
1303
  Be as k,
1304
- Mt as l,
1305
- Ct as m,
1306
- Bt as n,
1304
+ Bt as l,
1305
+ It as m,
1306
+ vt as n,
1307
1307
  $t as o,
1308
- w as p,
1309
- Rt as r,
1310
- Pt as s,
1308
+ Ct as p,
1309
+ B as r,
1310
+ nt as s,
1311
1311
  Ut as t,
1312
- _ as u,
1313
- It as v,
1312
+ Nt as u,
1313
+ Ot as v,
1314
1314
  Re as w,
1315
1315
  Tt as x,
1316
1316
  F as y,