@akropolys/kiku 1.5.17 → 1.5.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -71,7 +71,7 @@ function SearchBar({
71
71
  }
72
72
  ignoreNextQueryChange.current = true;
73
73
  setOpen(false);
74
- setQuery(r.product.name ?? "");
74
+ setQuery(r.entity.title ?? r.entity.name ?? "");
75
75
  onSelect?.(r);
76
76
  };
77
77
  const handleCommitSearch = () => {
@@ -151,8 +151,8 @@ function SearchBar({
151
151
  children: [
152
152
  /* @__PURE__ */ jsx("span", { className: "hsk-sb-row-icon", children: /* @__PURE__ */ jsx(SearchIcon, {}) }),
153
153
  /* @__PURE__ */ jsxs("div", { className: "hsk-sb-row-body", children: [
154
- /* @__PURE__ */ jsx("div", { className: "hsk-sb-row-title", children: r.product.name }),
155
- (r.product.category || r.product.brand) && /* @__PURE__ */ jsx("div", { className: "hsk-sb-row-sub", children: r.product.category ?? r.product.brand })
154
+ /* @__PURE__ */ jsx("div", { className: "hsk-sb-row-title", children: r.entity.title ?? r.entity.name }),
155
+ (r.entity.category || r.entity.brand) && /* @__PURE__ */ jsx("div", { className: "hsk-sb-row-sub", children: r.entity.category ?? r.entity.brand })
156
156
  ] })
157
157
  ]
158
158
  },
@@ -653,7 +653,7 @@ I couldn't find any matching products in the store.`;
653
653
  }) }) });
654
654
  }
655
655
  const featured = sources.filter((src) => src.id && referencedIds.includes(src.id));
656
- const general = featured.length > 0 ? [] : sources.filter((src) => !src.id || !referencedIds.includes(src.id));
656
+ const general = referencedIds.length > 0 ? [] : sources.filter((src) => !src.id || !referencedIds.includes(src.id));
657
657
  return /* @__PURE__ */ jsxs4("div", { className: "hsk-sources-container", children: [
658
658
  featured.length > 0 && /* @__PURE__ */ jsxs4("div", { className: "hsk-sources-group", style: { marginBottom: "10px" }, children: [
659
659
  /* @__PURE__ */ jsx5("div", { className: "hsk-sources-group-title", children: "\u2B50 Featured in response" }),
@@ -1325,7 +1325,7 @@ function SourcesCarousel({ sources, defaultCurrency, onSelectSource, referencedI
1325
1325
  railRef.current?.scrollBy({ left: 170, behavior: "smooth" });
1326
1326
  };
1327
1327
  const referenced = sources.filter((s) => s.id && referencedIds.includes(s.id));
1328
- const display = referenced.length > 0 ? referenced : sources;
1328
+ const display = referencedIds.length > 0 ? referenced : sources;
1329
1329
  return /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-sources-wrap", children: [
1330
1330
  /* @__PURE__ */ jsx7("div", { className: "hsk-cb-sources", ref: railRef, children: display.map((src, si) => {
1331
1331
  const isReferenced = !!(src.id && referencedIds.includes(src.id));
@@ -1751,30 +1751,14 @@ function ChatModal({
1751
1751
  } : void 0;
1752
1752
  const handlePhoneSubmit = async () => {
1753
1753
  if (!phoneInput.trim()) return;
1754
- try {
1755
- if (typeof window !== "undefined") {
1756
- localStorage.setItem("akropolys_user_phone", phoneInput.trim());
1757
- }
1758
- const isHistoryIntent = lastIntent === "capture" || lastIntent === "delete" || lastIntent === "view_history";
1759
- if (isHistoryIntent) {
1760
- const { phone, word } = parseMemoryKey(phoneInput);
1761
- if (!phone) return;
1762
- client.setShopperIdentity(phone, word);
1763
- setMemoryKey(phone + word);
1764
- setPaymentPhase("idle");
1765
- const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
1766
- if (lastUserMsg) {
1767
- await send(lastUserMsg.content);
1768
- }
1769
- return;
1770
- }
1771
- const res = await client.api.initiatePayment(phoneInput.trim());
1772
- setMerchantRef(res.merchantReference);
1773
- setPaymentPhase("awaiting");
1774
- } catch (e) {
1775
- console.error("[Akropolys] initiatePayment error", e);
1776
- setPaymentPhase("failed");
1777
- }
1754
+ const { phone, word } = parseMemoryKey(phoneInput);
1755
+ if (!phone) return;
1756
+ if (typeof window !== "undefined") localStorage.setItem("akropolys_user_phone", phone);
1757
+ client.setShopperIdentity(phone, word);
1758
+ setMemoryKey(phone + word);
1759
+ setPaymentPhase("idle");
1760
+ const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
1761
+ if (lastUserMsg) await send(lastUserMsg.content);
1778
1762
  };
1779
1763
  const msgsContainerRef = useRef5(null);
1780
1764
  useEffect3(() => {
@@ -2063,49 +2047,25 @@ function ChatModal({
2063
2047
  ] })
2064
2048
  ] }),
2065
2049
  error && /* @__PURE__ */ jsx7("div", { className: "hsk-cb-error", children: getFriendlyError(error) }),
2066
- !replayMessages && paymentPhase === "prompt_phone" && (() => {
2067
- const isHistoryIntent = lastIntent === "capture" || lastIntent === "delete" || lastIntent === "view_history";
2068
- if (isHistoryIntent) {
2069
- return /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
2070
- /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
2071
- /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-phone-form", children: [
2072
- /* @__PURE__ */ jsx7("label", { className: "hsk-cb-phone-label", children: "Your phone number \u2014 or paste your memory key" }),
2073
- /* @__PURE__ */ jsx7(
2074
- "input",
2075
- {
2076
- type: "text",
2077
- className: "hsk-cb-phone-input",
2078
- placeholder: "0712345678 or 0712345678flyingthunder",
2079
- value: phoneInput,
2080
- onChange: (e) => setPhoneInput(e.target.value.replace(/[^0-9a-zA-Z]/g, "")),
2081
- onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
2082
- autoFocus: true
2083
- }
2084
- ),
2085
- /* @__PURE__ */ jsx7("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Save & sync my items" })
2086
- ] }) }) })
2087
- ] });
2088
- }
2089
- return /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
2090
- /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
2091
- /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-phone-form", children: [
2092
- /* @__PURE__ */ jsx7("label", { className: "hsk-cb-phone-label", children: "Enter your M-Pesa number to pay" }),
2093
- /* @__PURE__ */ jsx7(
2094
- "input",
2095
- {
2096
- type: "tel",
2097
- className: "hsk-cb-phone-input",
2098
- placeholder: "0712 345 678",
2099
- value: phoneInput,
2100
- onChange: (e) => setPhoneInput(e.target.value.replace(/\D/g, "")),
2101
- onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
2102
- autoFocus: true
2103
- }
2104
- ),
2105
- /* @__PURE__ */ jsx7("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Send STK push" })
2106
- ] }) }) })
2107
- ] });
2108
- })(),
2050
+ !replayMessages && paymentPhase === "prompt_phone" && /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
2051
+ /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
2052
+ /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-phone-form", children: [
2053
+ /* @__PURE__ */ jsx7("label", { className: "hsk-cb-phone-label", children: "Your phone number \u2014 or paste your memory key" }),
2054
+ /* @__PURE__ */ jsx7(
2055
+ "input",
2056
+ {
2057
+ type: "text",
2058
+ className: "hsk-cb-phone-input",
2059
+ placeholder: "0712345678 or 0712345678flyingthunder",
2060
+ value: phoneInput,
2061
+ onChange: (e) => setPhoneInput(e.target.value.replace(/[^0-9a-zA-Z]/g, "")),
2062
+ onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
2063
+ autoFocus: true
2064
+ }
2065
+ ),
2066
+ /* @__PURE__ */ jsx7("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Save & sync my items" })
2067
+ ] }) }) })
2068
+ ] }),
2109
2069
  !replayMessages && memoryKey && /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
2110
2070
  /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
2111
2071
  /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { style: { padding: "10px 12px", border: "1px solid var(--hsk-border, #e5e5e5)", borderRadius: 8 }, children: [
@@ -2480,7 +2440,7 @@ function SparkleModal({
2480
2440
  if (!initialProduct && !fetchedProduct) {
2481
2441
  client.api.searchVector(productName, 1).then((res) => {
2482
2442
  if (res.results && res.results.length > 0) {
2483
- setFetchedProduct(res.results[0].product);
2443
+ setFetchedProduct(res.results[0].entity);
2484
2444
  }
2485
2445
  }).catch((err) => console.error("[Akropolys] Failed to fetch product details", err));
2486
2446
  }
@@ -2513,7 +2473,7 @@ function SparkleModal({
2513
2473
  const prevent = onNavigate?.(r);
2514
2474
  if (prevent !== false) {
2515
2475
  onClose();
2516
- if (r.product.url) window.location.href = r.product.url;
2476
+ if (r.entity.url) window.location.href = r.entity.url;
2517
2477
  }
2518
2478
  };
2519
2479
  const handleSend = async (text) => {
@@ -2600,7 +2560,7 @@ Question: ${q}`;
2600
2560
  /* @__PURE__ */ jsx8("div", { className: "hsk-cb-ai-text", children: renderMarkdown(msg.content) }),
2601
2561
  idx === 0 && displayProduct && /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-mobile-attachment-deck", children: [
2602
2562
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-mobile-main-card", children: [
2603
- /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-main-card-img", children: displayProduct.images?.[0] ? /* @__PURE__ */ jsx8("img", { src: displayProduct.images[0], alt: displayProduct.name }) : /* @__PURE__ */ jsx8("span", { children: "\u{1F6CD}" }) }),
2563
+ /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-main-card-img", children: displayProduct.images?.[0] ? /* @__PURE__ */ jsx8("img", { src: displayProduct.images[0], alt: displayProduct.name }) : /* @__PURE__ */ jsx8("span", { children: "\xF0\u0178\u203A\x8D" }) }),
2604
2564
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-mobile-main-card-info", children: [
2605
2565
  /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-main-card-brand", children: displayProduct.brand || displayProduct.category || "Product" }),
2606
2566
  /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-main-card-name", children: displayProduct.name }),
@@ -2623,8 +2583,8 @@ Question: ${q}`;
2623
2583
  (() => {
2624
2584
  const similarProducts = results.filter(
2625
2585
  (r) => {
2626
- const isSameName = !!(r.product.name && displayProduct?.name && r.product.name.toLowerCase() === displayProduct.name.toLowerCase());
2627
- const isSameSlug = r.product.slug && displayProduct?.slug && r.product.slug.toLowerCase() === displayProduct.slug.toLowerCase();
2586
+ const isSameName = !!(r.entity.name && displayProduct?.name && r.entity.name.toLowerCase() === displayProduct.name.toLowerCase());
2587
+ const isSameSlug = r.entity.slug && displayProduct?.slug && r.entity.slug.toLowerCase() === displayProduct.slug.toLowerCase();
2628
2588
  return !isSameName && !isSameSlug;
2629
2589
  }
2630
2590
  );
@@ -2632,17 +2592,17 @@ Question: ${q}`;
2632
2592
  return /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-mobile-similar-carousel-inline", children: [
2633
2593
  /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-similar-carousel-title", children: "Similar Products" }),
2634
2594
  /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-similar-carousel-list", children: similarProducts.map((r) => {
2635
- const price = parseFloat(r.product.price?.replace(/[^0-9.]/g, "") || "0");
2636
- const currency = r.product.currency ?? "KES";
2595
+ const price = parseFloat(r.entity.price?.replace(/[^0-9.]/g, "") || "0");
2596
+ const currency = r.entity.currency ?? "KES";
2637
2597
  return /* @__PURE__ */ jsxs7(
2638
2598
  "div",
2639
2599
  {
2640
2600
  className: "hsk-sp-mobile-similar-carousel-item",
2641
2601
  onClick: () => handleNav(r),
2642
2602
  children: [
2643
- /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-similar-carousel-img", children: r.product.images?.[0] ? /* @__PURE__ */ jsx8("img", { src: r.product.images[0], alt: r.product.name }) : /* @__PURE__ */ jsx8("span", { children: "\u{1F6CD}" }) }),
2603
+ /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-similar-carousel-img", children: r.entity.images?.[0] ? /* @__PURE__ */ jsx8("img", { src: r.entity.images[0], alt: r.entity.name }) : /* @__PURE__ */ jsx8("span", { children: "\xF0\u0178\u203A\x8D" }) }),
2644
2604
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-mobile-similar-carousel-meta", children: [
2645
- /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-similar-carousel-name", title: r.product.name, children: r.product.name }),
2605
+ /* @__PURE__ */ jsx8("div", { className: "hsk-sp-mobile-similar-carousel-name", title: r.entity.name, children: r.entity.name }),
2646
2606
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-mobile-similar-carousel-price", children: [
2647
2607
  currency,
2648
2608
  " ",
@@ -2746,7 +2706,7 @@ Question: ${q}`;
2746
2706
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-details-pane", children: [
2747
2707
  displayProduct && /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-product-profile-container", children: [
2748
2708
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-product-profile", children: [
2749
- /* @__PURE__ */ jsx8("div", { className: "hsk-sp-details-imgwrap", children: displayProduct.images?.[0] ? /* @__PURE__ */ jsx8("img", { src: displayProduct.images[0], alt: displayProduct.name }) : /* @__PURE__ */ jsx8("span", { className: "hsk-sp-img-placeholder", children: "\u{1F6CD}" }) }),
2709
+ /* @__PURE__ */ jsx8("div", { className: "hsk-sp-details-imgwrap", children: displayProduct.images?.[0] ? /* @__PURE__ */ jsx8("img", { src: displayProduct.images[0], alt: displayProduct.name }) : /* @__PURE__ */ jsx8("span", { className: "hsk-sp-img-placeholder", children: "\xF0\u0178\u203A\x8D" }) }),
2750
2710
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-details-meta", children: [
2751
2711
  displayProduct.brand && /* @__PURE__ */ jsx8("span", { className: "hsk-sp-item-brand", children: displayProduct.brand }),
2752
2712
  displayProduct.category && /* @__PURE__ */ jsx8("span", { className: "hsk-sp-item-cat", children: displayProduct.category }),
@@ -2763,7 +2723,7 @@ Question: ${q}`;
2763
2723
  ] }),
2764
2724
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-item-meta-badges", children: [
2765
2725
  displayProduct.rating && /* @__PURE__ */ jsxs7("span", { className: "hsk-sp-meta-badge hsk-sp-meta-badge-rating", children: [
2766
- "\u2605 ",
2726
+ "\xE2\u02DC\u2026 ",
2767
2727
  parseFloat(displayProduct.rating.toString()).toFixed(1),
2768
2728
  " ",
2769
2729
  displayProduct.reviewCount ? `(${displayProduct.reviewCount})` : ""
@@ -2793,8 +2753,8 @@ Question: ${q}`;
2793
2753
  /* @__PURE__ */ jsx8("div", { className: "hsk-sp-results", children: (() => {
2794
2754
  const similarProducts = results.filter(
2795
2755
  (r) => {
2796
- const isSameName = !!(r.product.name && displayProduct?.name && r.product.name.toLowerCase() === displayProduct.name.toLowerCase());
2797
- const isSameSlug = r.product.slug && displayProduct?.slug && r.product.slug.toLowerCase() === displayProduct.slug.toLowerCase();
2756
+ const isSameName = !!(r.entity.name && displayProduct?.name && r.entity.name.toLowerCase() === displayProduct.name.toLowerCase());
2757
+ const isSameSlug = r.entity.slug && displayProduct?.slug && r.entity.slug.toLowerCase() === displayProduct.slug.toLowerCase();
2798
2758
  return !isSameName && !isSameSlug;
2799
2759
  }
2800
2760
  );
@@ -2802,8 +2762,8 @@ Question: ${q}`;
2802
2762
  return /* @__PURE__ */ jsx8("div", { className: "hsk-sp-empty", children: "No similar products found." });
2803
2763
  }
2804
2764
  return similarProducts.map((r, i) => {
2805
- const price = parseFloat(r.product.price?.replace(/[^0-9.]/g, "") || "0");
2806
- const currency = r.product.currency ?? "KES";
2765
+ const price = parseFloat(r.entity.price?.replace(/[^0-9.]/g, "") || "0");
2766
+ const currency = r.entity.currency ?? "KES";
2807
2767
  return /* @__PURE__ */ jsxs7(
2808
2768
  "div",
2809
2769
  {
@@ -2811,11 +2771,11 @@ Question: ${q}`;
2811
2771
  style: { animationDelay: `${i * 55}ms`, cursor: "pointer" },
2812
2772
  onClick: () => handleNav(r),
2813
2773
  children: [
2814
- /* @__PURE__ */ jsx8("div", { className: "hsk-sp-img-wrap", children: r.product.images?.[0] ? /* @__PURE__ */ jsx8("img", { src: r.product.images[0], alt: r.product.name }) : /* @__PURE__ */ jsx8("span", { className: "hsk-sp-img-placeholder", children: "\u{1F6CD}" }) }),
2774
+ /* @__PURE__ */ jsx8("div", { className: "hsk-sp-img-wrap", children: r.entity.images?.[0] ? /* @__PURE__ */ jsx8("img", { src: r.entity.images[0], alt: r.entity.name }) : /* @__PURE__ */ jsx8("span", { className: "hsk-sp-img-placeholder", children: "\xF0\u0178\u203A\x8D" }) }),
2815
2775
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-item-body", children: [
2816
2776
  /* @__PURE__ */ jsxs7("div", { children: [
2817
- r.product.category && /* @__PURE__ */ jsx8("div", { className: "hsk-sp-item-cat", children: r.product.category }),
2818
- /* @__PURE__ */ jsx8("div", { className: "hsk-sp-item-name", title: r.product.name, children: r.product.name })
2777
+ r.entity.category && /* @__PURE__ */ jsx8("div", { className: "hsk-sp-item-cat", children: r.entity.category }),
2778
+ /* @__PURE__ */ jsx8("div", { className: "hsk-sp-item-name", title: r.entity.name, children: r.entity.name })
2819
2779
  ] }),
2820
2780
  /* @__PURE__ */ jsxs7("div", { className: "hsk-sp-item-price-row", children: [
2821
2781
  /* @__PURE__ */ jsx8("span", { className: "hsk-sp-item-currency", children: currency }),