@sledge-app/react-instant-search 0.0.87 → 0.0.89

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,4 +1,4 @@
1
- import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as $a093c7e1ec25a057$export$2881499e37b75b9a, F as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, G as $a093c7e1ec25a057$export$41fb9f06171c75f4, H as $a093c7e1ec25a057$export$602eac185826482c, I as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, J as $a093c7e1ec25a057$export$21b07c8f274aebd5, K as $57acba87d6e25586$export$be92b6f5f03c0fe9, L as $57acba87d6e25586$export$d5c6c08dc2d3ca7, M as $57acba87d6e25586$export$9a4e88b92edfce6b, N as $57acba87d6e25586$export$6521433ed15a34db, O as $57acba87d6e25586$export$ac61190d9fc311a9, P as MasonryResponsive, Q as Masonry, R as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, S as $5d3850c4d0b4e6c7$export$602eac185826482c, T as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, U as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-90dfd914.js";
1
+ import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as client, E as motion, F as $a093c7e1ec25a057$export$2881499e37b75b9a, G as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, H as $a093c7e1ec25a057$export$41fb9f06171c75f4, I as $a093c7e1ec25a057$export$602eac185826482c, J as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, K as $a093c7e1ec25a057$export$21b07c8f274aebd5, L as $57acba87d6e25586$export$be92b6f5f03c0fe9, M as $57acba87d6e25586$export$d5c6c08dc2d3ca7, N as $57acba87d6e25586$export$9a4e88b92edfce6b, O as $57acba87d6e25586$export$6521433ed15a34db, P as $57acba87d6e25586$export$ac61190d9fc311a9, Q as MasonryResponsive, R as Masonry, S as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, T as $5d3850c4d0b4e6c7$export$602eac185826482c, U as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, V as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-1f00eb2b.js";
2
2
  import React__default, { createElement } from "react";
3
3
  import { SledgeContext } from "@sledge-app/core";
4
4
  import "react-dom";
@@ -7,6 +7,51 @@ const ProductFilterWidget = (props) => {
7
7
  };
8
8
  const API_URL = "https://sledge-api-preprod.offstack.io";
9
9
  const INSTANT_SEARCH_ENGINE_URL = "https://instant-search-engine.offstack.io";
10
+ const SELECTOR_ATTRIBUTE_KEY = "data-component";
11
+ const DATASET_ATTRIBUTE_KEY = {
12
+ GLOBAL: {
13
+ ON_AFTER_ADD_WISHLIST: "data-on-after-add-wishlist",
14
+ ON_AFTER_REMOVE_WISHLIST: "data-on-after-remove-wishlist",
15
+ ON_AFTER_ADD_TO_CART: "data-on-after-add-to-cart",
16
+ ON_AFTER_ADD_REVIEW: "data-on-after-add-review",
17
+ ON_AFTER_RENDER_PRODUCT: "data-on-after-render-product",
18
+ PRODUCT_ID: "data-product-id",
19
+ PRODUCT_VARIANT_ID: "data-product-variant-id",
20
+ PRODUCT_NAME: "data-product-name",
21
+ PRODUCT_VENDOR: "data-product-vendor",
22
+ PRODUCT_SKU: "data-product-sku",
23
+ PRODUCT_VARIANT_NAME: "data-product-variant-name",
24
+ PRODUCT_LINK: "data-product-link",
25
+ PRODUCT_IMAGE: "data-product-image",
26
+ PRODUCT_CURRENCY: "data-product-currency",
27
+ PRODUCT_PRICE: "data-product-price",
28
+ USER_ID: "data-user-id",
29
+ USER_EMAIL: "data-user-email",
30
+ USER_FULLNAME: "data-user-fullname",
31
+ COLLECTION_ID: "data-collection-id",
32
+ WIDTH_ELEMENT: "data-width-element",
33
+ ICON_SIZE: "data-icon-size",
34
+ API_KEY: "data-api-key",
35
+ INSTANT_SEARCH_API_KEY: "data-instant-search-api-key",
36
+ RENDER_PRODUCT_CARD: "data-render-product-card"
37
+ },
38
+ WISHLIST: {
39
+ SHARE_ID: "data-share-id",
40
+ QUERY_SHARE_ID: "data-query-share-id",
41
+ CUSTOM_ROUTE_PAGE: "data-custom-route-page",
42
+ RENDER_WISHLIST_WIDGET_ALERT: "data-render-wishlist-widget-alert",
43
+ USE_PROXY_URL: "data-use-proxy-url"
44
+ },
45
+ PRODUCT_REVIEW: {
46
+ RATING_SIZE: "data-rating-size"
47
+ },
48
+ INSTANT_SEARCH: {
49
+ QUERY_KEYWORD: "data-query-keyword",
50
+ RENDER_SUGGESTION_KEYWORD_LIST: "data-render-suggestion-keyword-list",
51
+ RENDER_OTHER_INDEX_LIST: "data-render-other-index-list",
52
+ RENDER_SEARCH_VIEW_MORE_RESULT: "data-render-search-view-more-result"
53
+ }
54
+ };
10
55
  const LOCAL_STORAGE_KEY = {
11
56
  ANONYM_ID: "sledge-anonym-id",
12
57
  AUTH_APP: "sledge-auth-app",
@@ -16,6 +61,45 @@ const LOCAL_STORAGE_KEY = {
16
61
  INSTANT_SEARCH_SETTING: "sledge-instant-search-setting",
17
62
  EXPIRY_SETTING: "sledge-expiry-setting"
18
63
  };
64
+ const INTERNAL_SELECTOR_VALUE = {
65
+ ELEMENT_TOAST_NOTIFICATION: "toast-notification",
66
+ ELEMENT_CONFIRMATION_POPUP: "confirmation-popup",
67
+ ELEMENT_INFO_POPUP: "info-popup",
68
+ WISHLIST: {
69
+ ELEMENT_BADGE_FLOATING_ICON: "wishlist-badge-floating-icon",
70
+ ELEMENT_BADGE_FLOATING_FULL: "wishlist-badge-floating-full",
71
+ ELEMENT_WIDGET_POPUP: "wishlist-widget-popup"
72
+ },
73
+ PRODUCT_REVIEW: {
74
+ ELEMENT_WIDGET_POPUP_DETAIL: "product-review-widget-popup-detail",
75
+ ELEMENT_WIDGET_FORM_ADD: "product-review-widget-form-add"
76
+ },
77
+ INSTANT_SEARCH: {
78
+ ELEMENT_SEARCH_ICON_WIDGET_POPUP: "instant-search-icon-widget-popup"
79
+ }
80
+ };
81
+ const SELECTOR = {
82
+ GLOBAL: {
83
+ ELEMENT_CUSTOM_COMPONENTS: `[${SELECTOR_ATTRIBUTE_KEY}="custom-components"]`
84
+ },
85
+ WISHLIST: {
86
+ ELEMENT_BADGE: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-badge"]`,
87
+ ELEMENT_BADGE_MENU_ITEM: `[href="#sledge-wishlist-badge-menu-item"]`,
88
+ ELEMENT_TRIGGER: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-trigger"]`,
89
+ ELEMENT_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-widget"]`,
90
+ ELEMENT_BUTTON_DETAIL: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-button-detail"]`
91
+ },
92
+ PRODUCT_REVIEW: {
93
+ ELEMENT_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-widget"]`,
94
+ ELEMENT_RATING: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-rating"]`
95
+ },
96
+ INSTANT_SEARCH: {
97
+ ELEMENT_SEARCH_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-widget"]`,
98
+ ELEMENT_SEARCH_ICON_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-icon-widget"]`,
99
+ ELEMENT_SEARCH_RESULT_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-result-widget"]`,
100
+ ELEMENT_PLP_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-product-filter-widget"]`
101
+ }
102
+ };
19
103
  const SEARCH_RESULT_URL = "/pages/search-result";
20
104
  const ELEMENT_ID = {
21
105
  PRODUCT_REVIEW: {
@@ -33,6 +117,15 @@ const sanitizeDataId = (id) => {
33
117
  return getId;
34
118
  }
35
119
  };
120
+ const detectInitSelector = (element, init) => {
121
+ let hasRunning = false;
122
+ document.body.addEventListener("DOMNodeInserted", () => {
123
+ if (!hasRunning && element) {
124
+ hasRunning = true;
125
+ init();
126
+ }
127
+ });
128
+ };
36
129
  const isFunction = (data) => typeof data === "function";
37
130
  const scrollToElement = (element, headerOffset) => {
38
131
  if (!element)
@@ -510,6 +603,113 @@ const addToCart = async (data) => {
510
603
  return;
511
604
  });
512
605
  };
606
+ const BadgeFloatingFull = (props) => {
607
+ var _a;
608
+ const { sledgeAnonymId } = React__default.useContext(SledgeContext);
609
+ const { isFirstLoading, isLoading, totalWishlist, isMaximizeTotalWishlist, proxyUrl, position = "left", dataSettings, useProxyUrl } = props || {};
610
+ const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
611
+ const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
612
+ React__default.useEffect(() => {
613
+ setIsRequiredLogin(sledgeAnonymId && is_required_login);
614
+ }, [sledgeAnonymId]);
615
+ const handleRequiredLogin = (e) => {
616
+ if (isRequiredLogin) {
617
+ e.preventDefault();
618
+ e.stopPropagation();
619
+ }
620
+ if (isRequiredLogin) {
621
+ if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
622
+ window.sledgeConfirmationPopup({
623
+ title: "Login required!",
624
+ message: "Please login to save your wishlist across devices.",
625
+ textSubmit: "Login",
626
+ textCancel: "Cancel",
627
+ buttonSubmitType: "info",
628
+ onSubmit: () => window.location.href = "/account/login"
629
+ });
630
+ } else {
631
+ if (useProxyUrl)
632
+ window.location.href = proxyUrl || "/";
633
+ }
634
+ };
635
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge-wishlist__badge-floating sledge-wishlist__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: [
636
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-wishlist__badge-floating-text", children: "My Wishlist" }),
637
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
638
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 18, height: 18, type: "fill", color: "#000000" }),
639
+ !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
640
+ ] })
641
+ ] }) });
642
+ };
643
+ const BadgeFloatingIcon = (props) => {
644
+ var _a;
645
+ const { sledgeAnonymId } = React__default.useContext(SledgeContext);
646
+ const { isFirstLoading, isLoading, totalWishlist, isMaximizeTotalWishlist, proxyUrl, position = "bottom-right", dataSettings, useProxyUrl } = props || {};
647
+ const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
648
+ const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
649
+ React__default.useEffect(() => {
650
+ setIsRequiredLogin(sledgeAnonymId && is_required_login);
651
+ }, [sledgeAnonymId]);
652
+ const handleRequiredLogin = (e) => {
653
+ if (isRequiredLogin) {
654
+ e.preventDefault();
655
+ e.stopPropagation();
656
+ }
657
+ if (isRequiredLogin) {
658
+ if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
659
+ window.sledgeConfirmationPopup({
660
+ title: "Login required!",
661
+ message: "Please login to save your wishlist across devices.",
662
+ textSubmit: "Login",
663
+ textCancel: "Cancel",
664
+ buttonSubmitType: "info",
665
+ onSubmit: () => window.location.href = "/account/login"
666
+ });
667
+ } else {
668
+ if (useProxyUrl)
669
+ window.location.href = proxyUrl || "/";
670
+ }
671
+ };
672
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge-wishlist__badge-floating-icon sledge-wishlist__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
673
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 27.01, height: 25.73, type: "outline", color: "#000000" }),
674
+ !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
675
+ ] }) }) });
676
+ };
677
+ const BadgeHeaderMenu = (props) => {
678
+ var _a;
679
+ const { sledgeAnonymId } = React__default.useContext(SledgeContext);
680
+ const { isFirstLoading, isLoading, totalWishlist, isMaximizeTotalWishlist, proxyUrl, dataSettings, useProxyUrl } = props || {};
681
+ const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
682
+ const defaultColorIcon = "#000000";
683
+ const [colorIcon, setColorIcon] = React__default.useState(defaultColorIcon);
684
+ const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
685
+ React__default.useEffect(() => {
686
+ setIsRequiredLogin(sledgeAnonymId && is_required_login);
687
+ }, [sledgeAnonymId]);
688
+ const handleRequiredLogin = (e) => {
689
+ if (isRequiredLogin) {
690
+ e.preventDefault();
691
+ e.stopPropagation();
692
+ }
693
+ if (isRequiredLogin) {
694
+ if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
695
+ window.sledgeConfirmationPopup({
696
+ title: "Login required!",
697
+ message: "Please login to save your wishlist across devices.",
698
+ textSubmit: "Login",
699
+ textCancel: "Cancel",
700
+ buttonSubmitType: "info",
701
+ onSubmit: () => window.location.href = "/account/login"
702
+ });
703
+ } else {
704
+ if (useProxyUrl)
705
+ window.location.href = proxyUrl || "/";
706
+ }
707
+ };
708
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge", onClick: handleRequiredLogin, onMouseEnter: () => setColorIcon("#F85538"), onMouseLeave: () => setColorIcon(defaultColorIcon), children: [
709
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 20, height: 20, type: "outline", color: colorIcon }),
710
+ !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
711
+ ] });
712
+ };
513
713
  const addWishlist = async (data) => {
514
714
  const { productId, productVariantId, productName, productVendor, productSku, productVariantName, productLink, productImage, productCurrency, productPrice } = data;
515
715
  let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
@@ -575,6 +775,21 @@ const bulkAddWishlist = async (data) => {
575
775
  return;
576
776
  });
577
777
  };
778
+ const getWishlistInfo = async (token) => {
779
+ let sledgeAuthApp = token || localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
780
+ var myHeaders = new Headers();
781
+ myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
782
+ var requestOptions = {
783
+ method: "GET",
784
+ headers: myHeaders,
785
+ redirect: "follow"
786
+ };
787
+ return await fetch(`${API_URL}/wishlist/info`, requestOptions).then((response) => response.json()).then((result) => {
788
+ return result;
789
+ }).catch(() => {
790
+ return;
791
+ });
792
+ };
578
793
  const checkWishlist = async (id, variantId) => {
579
794
  let convertId = sanitizeDataId(id);
580
795
  let convertVariantId = variantId ? sanitizeDataId(variantId) : "";
@@ -618,11 +833,160 @@ const addToCartTrigger$1 = async (data) => {
618
833
  return;
619
834
  });
620
835
  };
836
+ const BadgeRoot = (props) => {
837
+ const { children, useProxyUrl = false, data: propsData } = props;
838
+ const { isRenderApp, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
839
+ const { wishlist: isRenderAppWishlist } = isRenderApp || {};
840
+ const [totalWishlist, setTotalWishlist] = React__default.useState((propsData == null ? void 0 : propsData.total_data) || 0);
841
+ const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
842
+ const [isLoading, setIsLoading] = React__default.useState(!propsData);
843
+ const [isMaximizeTotalWishlist, setIsMaximizeTotalWishlist] = React__default.useState(false);
844
+ const [proxyUrl, setProxyUrl] = React__default.useState((propsData == null ? void 0 : propsData.proxy_url) || "");
845
+ const [dataSettings, setDataSettings] = React__default.useState({});
846
+ const handleGetWishlistInfo = async () => {
847
+ var _a, _b, _c;
848
+ let response;
849
+ let run = false;
850
+ let valueTotalWishlist;
851
+ let valueProxyUrl;
852
+ response = await getWishlistInfo();
853
+ run = ((_a = response == null ? void 0 : response.status) == null ? void 0 : _a.code) === 200 || false;
854
+ valueTotalWishlist = !((_b = response == null ? void 0 : response.data) == null ? void 0 : _b.total_data) ? 0 : response.data.total_data;
855
+ valueProxyUrl = ((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.proxy_url) || "";
856
+ if (run) {
857
+ setTotalWishlist(valueTotalWishlist);
858
+ setIsMaximizeTotalWishlist(valueTotalWishlist > 99);
859
+ setProxyUrl(valueProxyUrl);
860
+ setIsFirstLoading(false);
861
+ setIsLoading(false);
862
+ }
863
+ };
864
+ const handleSettings = async (LOCAL_STORAGE_WISHLIST_SETTING) => {
865
+ let response;
866
+ response = JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
867
+ if (!response)
868
+ return;
869
+ setDataSettings(response);
870
+ await handleGetWishlistInfo();
871
+ };
872
+ React__default.useEffect(() => {
873
+ if (!isRenderAppWishlist)
874
+ return;
875
+ handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || "");
876
+ }, [isRenderAppWishlist, triggerRenderMultipleComponent]);
877
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.count(children) && React__default.Children.map(
878
+ children,
879
+ (child) => React__default.cloneElement(child, {
880
+ isFirstLoading,
881
+ isLoading,
882
+ totalWishlist,
883
+ isMaximizeTotalWishlist,
884
+ proxyUrl,
885
+ dataSettings,
886
+ useProxyUrl
887
+ })
888
+ ) });
889
+ };
890
+ const Badge = ({ children }) => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.count(children) && React__default.Children.map(children, (child) => React__default.cloneElement(child, {})) });
891
+ Badge.Root = BadgeRoot;
892
+ Badge.HeaderMenu = BadgeHeaderMenu;
893
+ Badge.FloatingFull = BadgeFloatingFull;
894
+ Badge.FloatingIcon = BadgeFloatingIcon;
895
+ const BadgeInitSelector = () => {
896
+ const sledgeWishlistSettings = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || "");
897
+ if (!sledgeWishlistSettings)
898
+ return;
899
+ const { floating_button_type } = (sledgeWishlistSettings == null ? void 0 : sledgeWishlistSettings.launch_point) || {};
900
+ const isBottomFloatingType = String(floating_button_type).includes("bottom");
901
+ if (floating_button_type !== "none") {
902
+ if (isBottomFloatingType) {
903
+ let elementFloatingIcon = document.createElement("div");
904
+ elementFloatingIcon.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.WISHLIST.ELEMENT_BADGE_FLOATING_ICON);
905
+ document.body.appendChild(elementFloatingIcon);
906
+ if (elementFloatingIcon) {
907
+ elementFloatingIcon.innerHTML = "";
908
+ const USE_PROXY_URL = elementFloatingIcon.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
909
+ client.createRoot(elementFloatingIcon).render(
910
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
911
+ SledgeContext.Provider,
912
+ {
913
+ value: {
914
+ isRenderApp: {
915
+ wishlist: true,
916
+ productReview: true,
917
+ instantSearch: true
918
+ },
919
+ sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
920
+ isJsVersion: true
921
+ },
922
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge.Root, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge.FloatingIcon, { position: floating_button_type }) })
923
+ }
924
+ ) })
925
+ );
926
+ }
927
+ } else {
928
+ let elementFloatingFull = document.createElement("div");
929
+ elementFloatingFull.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.WISHLIST.ELEMENT_BADGE_FLOATING_FULL);
930
+ document.body.appendChild(elementFloatingFull);
931
+ if (elementFloatingFull) {
932
+ elementFloatingFull.innerHTML = "";
933
+ const USE_PROXY_URL = elementFloatingFull.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
934
+ client.createRoot(elementFloatingFull).render(
935
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
936
+ SledgeContext.Provider,
937
+ {
938
+ value: {
939
+ isRenderApp: {
940
+ wishlist: true,
941
+ productReview: true,
942
+ instantSearch: true
943
+ },
944
+ sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
945
+ isJsVersion: true
946
+ },
947
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge.Root, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge.FloatingFull, { position: floating_button_type }) })
948
+ }
949
+ ) })
950
+ );
951
+ }
952
+ }
953
+ } else {
954
+ let element = Array.from(document.querySelectorAll(SELECTOR.WISHLIST.ELEMENT_BADGE));
955
+ detectInitSelector(element, () => {
956
+ if (element.length) {
957
+ element.map((item) => {
958
+ if (item) {
959
+ const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
960
+ item.innerHTML = "";
961
+ client.createRoot(item).render(
962
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
963
+ SledgeContext.Provider,
964
+ {
965
+ value: {
966
+ isRenderApp: {
967
+ wishlist: true,
968
+ productReview: true,
969
+ instantSearch: true
970
+ },
971
+ sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
972
+ isJsVersion: true
973
+ },
974
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge.Root, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge.HeaderMenu, {}) })
975
+ }
976
+ ) })
977
+ );
978
+ }
979
+ });
980
+ }
981
+ });
982
+ }
983
+ };
621
984
  const Trigger = (props) => {
622
985
  var _a, _b, _c;
623
986
  const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked } = props;
624
987
  const { productId, productVariantId } = params || {};
625
988
  const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
989
+ const { wishlist: isRenderAppWishlist } = isRenderApp || {};
626
990
  const defaultColorIcon = "#767676";
627
991
  const defaultTypeIcon = "outline";
628
992
  const activeColorIcon = "#F85538";
@@ -675,11 +1039,9 @@ const Trigger = (props) => {
675
1039
  const { code } = status || {};
676
1040
  if (code === 200) {
677
1041
  if (typeof window !== "undefined") {
678
- if (window.sledgeWishlistBadgeUpdate) {
679
- if (((_b2 = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a2.badge) == null ? void 0 : _b2.trigger) && typeof wishlistChecked !== "boolean")
680
- (_f = (_c2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _c2.badge) == null ? void 0 : _f.trigger(!((_e = (_d = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _d.badge) == null ? void 0 : _e.value));
681
- window.sledgeWishlistBadgeUpdate();
682
- }
1042
+ if (((_b2 = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a2.badge) == null ? void 0 : _b2.trigger) && typeof wishlistChecked !== "boolean")
1043
+ (_f = (_c2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _c2.badge) == null ? void 0 : _f.trigger(!((_e = (_d = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _d.badge) == null ? void 0 : _e.value));
1044
+ BadgeInitSelector();
683
1045
  if (window.sledgeWishlistWidgetListUpdate)
684
1046
  window.sledgeWishlistWidgetListUpdate();
685
1047
  if (window.sledgeWishlistButtonDetailUpdate)
@@ -725,7 +1087,7 @@ const Trigger = (props) => {
725
1087
  setIsLoading(false);
726
1088
  };
727
1089
  React__default.useEffect(() => {
728
- if (!(isRenderApp == null ? void 0 : isRenderApp.wishlist))
1090
+ if (!isRenderAppWishlist)
729
1091
  return;
730
1092
  if (typeof window !== "undefined") {
731
1093
  window.sledgeWishlistTriggerUpdate = () => {
@@ -733,15 +1095,15 @@ const Trigger = (props) => {
733
1095
  };
734
1096
  }
735
1097
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || "");
736
- }, [isRenderApp]);
1098
+ }, [isRenderAppWishlist]);
737
1099
  React__default.useEffect(() => {
738
1100
  setIsRequiredLogin(sledgeAnonymId && is_required_login);
739
1101
  }, [sledgeAnonymId]);
740
1102
  React__default.useEffect(() => {
741
- if (!(isRenderApp == null ? void 0 : isRenderApp.wishlist))
1103
+ if (!isRenderAppWishlist)
742
1104
  return;
743
1105
  handleCheckWishlist();
744
- }, [isRenderApp, productVariantId]);
1106
+ }, [isRenderAppWishlist, productVariantId]);
745
1107
  const isActive = (isWishlist || forceActive) && !isRequiredLogin;
746
1108
  React__default.useEffect(() => {
747
1109
  if (isActive) {
@@ -881,11 +1243,9 @@ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger,
881
1243
  let resBulkAddWishlist = await bulkAddWishlist(data);
882
1244
  if (((_a2 = resBulkAddWishlist == null ? void 0 : resBulkAddWishlist.status) == null ? void 0 : _a2.code) === 200) {
883
1245
  if (typeof window !== "undefined") {
884
- if (window.sledgeWishlistBadgeUpdate) {
885
- if ((_c2 = (_b2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _b2.badge) == null ? void 0 : _c2.trigger)
886
- (_g = (_d2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _d2.badge) == null ? void 0 : _g.trigger(!((_f2 = (_e2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _e2.badge) == null ? void 0 : _f2.value));
887
- window.sledgeWishlistBadgeUpdate();
888
- }
1246
+ if ((_c2 = (_b2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _b2.badge) == null ? void 0 : _c2.trigger)
1247
+ (_g = (_d2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _d2.badge) == null ? void 0 : _g.trigger(!((_f2 = (_e2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _e2.badge) == null ? void 0 : _f2.value));
1248
+ BadgeInitSelector();
889
1249
  if (window.sledgeInfoPopup)
890
1250
  window.sledgeInfoPopup({
891
1251
  title: title_added_all_to_wishlist,
@@ -1165,6 +1525,7 @@ const Rating = (props) => {
1165
1525
  const { value, size = "md", params, withSkeletonLoading = true, isScrollToElementWidget = true, data: propsData, sledgeSettings } = props;
1166
1526
  const { productId } = params || {};
1167
1527
  const { isRenderApp, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
1528
+ const { productReview: isRenderAppProductReview } = isRenderApp || {};
1168
1529
  const initLoading = propsData || value ? false : true;
1169
1530
  const [isFirstLoading, setIsFirstLoading] = React__default.useState(initLoading);
1170
1531
  const [isLoading, setIsLoading] = React__default.useState(initLoading);
@@ -1238,7 +1599,7 @@ const Rating = (props) => {
1238
1599
  }, 200);
1239
1600
  };
1240
1601
  React__default.useEffect(() => {
1241
- if (!(isRenderApp == null ? void 0 : isRenderApp.productReview))
1602
+ if (!isRenderAppProductReview)
1242
1603
  return;
1243
1604
  if (size === "xs") {
1244
1605
  setSizing({
@@ -1260,7 +1621,7 @@ const Rating = (props) => {
1260
1621
  if (isProductIdChanged)
1261
1622
  setIsFirstLoading(true);
1262
1623
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || "");
1263
- }, [isRenderApp, productId]);
1624
+ }, [isRenderAppProductReview, productId]);
1264
1625
  React__default.useEffect(() => {
1265
1626
  var _a2, _b2, _c, _d;
1266
1627
  if (!productId || productId && ((_b2 = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _a2.rating) == null ? void 0 : _b2.value) !== productId)
@@ -2258,6 +2619,7 @@ const SkeletonLoading = {
2258
2619
  };
2259
2620
  const SearchIconWidget = (props) => {
2260
2621
  const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
2622
+ const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
2261
2623
  const { size = "sm", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props || {};
2262
2624
  let productCardsComponent = null;
2263
2625
  let suggestionKeywordListsComponent = null;
@@ -2281,7 +2643,7 @@ const SearchIconWidget = (props) => {
2281
2643
  height: 0
2282
2644
  });
2283
2645
  React__default.useEffect(() => {
2284
- if (!(isRenderApp == null ? void 0 : isRenderApp.instantSearch))
2646
+ if (!isRenderAppInstantSearch)
2285
2647
  return;
2286
2648
  if (size === "xs") {
2287
2649
  setSizing({
@@ -2299,7 +2661,7 @@ const SearchIconWidget = (props) => {
2299
2661
  height: 25
2300
2662
  });
2301
2663
  }
2302
- }, [isRenderApp]);
2664
+ }, [isRenderAppInstantSearch]);
2303
2665
  const handleShowWidget = () => {
2304
2666
  if (typeof window !== "undefined" && window.sledgeInstantSearchIconWidgetPopup)
2305
2667
  window.sledgeInstantSearchIconWidgetPopup({
@@ -3995,6 +4357,7 @@ const ResultEmpty = (props) => {
3995
4357
  const SearchWidget = (props) => {
3996
4358
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
3997
4359
  const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
4360
+ const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
3998
4361
  const { width = "400px", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
3999
4362
  let productCardsComponent = null;
4000
4363
  let suggestionKeywordListsComponent = null;
@@ -4091,7 +4454,7 @@ const SearchWidget = (props) => {
4091
4454
  await handleMultiSearch(response);
4092
4455
  };
4093
4456
  React__default.useEffect(() => {
4094
- if (!(isRenderApp == null ? void 0 : isRenderApp.instantSearch))
4457
+ if (!isRenderAppInstantSearch)
4095
4458
  return;
4096
4459
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
4097
4460
  }, [keyword]);