@sledge-app/react-instant-search 2.0.72 → 2.0.73

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.
@@ -720,6 +720,77 @@ const getSortMap = ({
720
720
  "title-descending": "title:desc"
721
721
  };
722
722
  };
723
+ let onStorageFallback;
724
+ const getWindowStore = () => {
725
+ if (typeof window === "undefined")
726
+ return null;
727
+ window.__SLEDGE_STORAGE__ = window.__SLEDGE_STORAGE__ || { data: {} };
728
+ return window.__SLEDGE_STORAGE__;
729
+ };
730
+ const getFallbackValue = (key) => {
731
+ var _a;
732
+ const store = getWindowStore();
733
+ return ((_a = store == null ? void 0 : store.data) == null ? void 0 : _a[key]) ?? null;
734
+ };
735
+ const setFallbackValue = (key, value) => {
736
+ const store = getWindowStore();
737
+ if (!store)
738
+ return;
739
+ store.data[key] = value;
740
+ };
741
+ const deleteFallbackValue = (key) => {
742
+ const store = getWindowStore();
743
+ if (!store)
744
+ return;
745
+ delete store.data[key];
746
+ };
747
+ const reportFallback = (key, error, operation) => {
748
+ var _a, _b;
749
+ try {
750
+ onStorageFallback == null ? void 0 : onStorageFallback(key, error, operation);
751
+ } catch {
752
+ }
753
+ if (typeof window !== "undefined") {
754
+ try {
755
+ (_b = (_a = window.posthog) == null ? void 0 : _a.capture) == null ? void 0 : _b.call(_a, "sledge_localstorage_fallback", {
756
+ key,
757
+ operation,
758
+ errorName: error == null ? void 0 : error.name
759
+ });
760
+ } catch {
761
+ }
762
+ }
763
+ };
764
+ const safeSetItem = (key, value) => {
765
+ if (typeof window === "undefined")
766
+ return;
767
+ if (typeof localStorage !== "undefined") {
768
+ try {
769
+ localStorage.setItem(key, value);
770
+ deleteFallbackValue(key);
771
+ return;
772
+ } catch (error) {
773
+ reportFallback(key, error, "setItem");
774
+ }
775
+ } else {
776
+ reportFallback(key, new Error("localStorage_unavailable"), "setItem");
777
+ }
778
+ setFallbackValue(key, value);
779
+ };
780
+ const safeGetItem = (key) => {
781
+ const fallbackValue = getFallbackValue(key);
782
+ if (fallbackValue !== null)
783
+ return fallbackValue;
784
+ if (typeof localStorage !== "undefined") {
785
+ try {
786
+ return localStorage.getItem(key);
787
+ } catch (error) {
788
+ reportFallback(key, error, "getItem");
789
+ return getFallbackValue(key);
790
+ }
791
+ }
792
+ return getFallbackValue(key);
793
+ };
723
794
  const root = "";
724
795
  const Loading = "";
725
796
  const ConfirmationPopup = "";
@@ -1692,7 +1763,7 @@ const addToCart = async (data) => {
1692
1763
  });
1693
1764
  };
1694
1765
  const getWishlist = async (query, token) => {
1695
- let sledgeAuthApp = token ? token : typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
1766
+ let sledgeAuthApp = token ? token : safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
1696
1767
  let queryParams = "?" + new URLSearchParams({
1697
1768
  ...query || {}
1698
1769
  }).toString();
@@ -1709,7 +1780,7 @@ const getWishlist = async (query, token) => {
1709
1780
  };
1710
1781
  const addWishlist = async (data) => {
1711
1782
  const { productId, productVariantId, productName, productVendor, productSku, productVariantName, productLink, productImage, productCurrency, productPrice, type = "toggle" } = data;
1712
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
1783
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
1713
1784
  let url = `${API_URL}/wishlist`;
1714
1785
  let payload = {
1715
1786
  product: JSON.stringify({
@@ -1738,7 +1809,7 @@ const addWishlist = async (data) => {
1738
1809
  });
1739
1810
  };
1740
1811
  const bulkAddWishlist = async (data) => {
1741
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
1812
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
1742
1813
  let products = data.map((item) => {
1743
1814
  const { productId, productVariantId, productName, productVariantName, productLink, productImage, productCurrency, productPrice } = item;
1744
1815
  return {
@@ -1773,7 +1844,7 @@ const bulkAddWishlist = async (data) => {
1773
1844
  });
1774
1845
  };
1775
1846
  const getWishlistInfo = async ({ token = "", query = null }) => {
1776
- let sledgeAuthApp = token ? token : typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
1847
+ let sledgeAuthApp = token ? token : safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
1777
1848
  let queryParams = "?" + new URLSearchParams({
1778
1849
  ...query
1779
1850
  }).toString();
@@ -1791,7 +1862,7 @@ const getWishlistInfo = async ({ token = "", query = null }) => {
1791
1862
  const checkWishlist = async ({ id, variantId = "", query = null }) => {
1792
1863
  let convertId = sanitizeDataId(id);
1793
1864
  let convertVariantId = variantId ? sanitizeDataId(variantId) : "";
1794
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
1865
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
1795
1866
  let queryParams = "?" + new URLSearchParams({
1796
1867
  variant_id: convertVariantId,
1797
1868
  ...query
@@ -1808,7 +1879,7 @@ const checkWishlist = async ({ id, variantId = "", query = null }) => {
1808
1879
  });
1809
1880
  };
1810
1881
  const checkWishlists = async () => {
1811
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
1882
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
1812
1883
  let url = `${API_URL}/wishlist/checks`;
1813
1884
  return await fetchApi({
1814
1885
  url,
@@ -1821,7 +1892,7 @@ const checkWishlists = async () => {
1821
1892
  });
1822
1893
  };
1823
1894
  const clearWishlist = async () => {
1824
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
1895
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
1825
1896
  let url = `${API_URL}/wishlist/clear`;
1826
1897
  return await fetchApi({
1827
1898
  url,
@@ -1835,7 +1906,7 @@ const clearWishlist = async () => {
1835
1906
  };
1836
1907
  const addToCartTrigger$2 = async (data) => {
1837
1908
  const { productId } = data;
1838
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
1909
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
1839
1910
  let url = `${API_URL}/wishlist/cart`;
1840
1911
  let payload = {
1841
1912
  product: JSON.stringify({
@@ -1901,11 +1972,11 @@ const BadgeCounter = (props) => {
1901
1972
  setIsMaximizeTotalWishlist(valueTotalWishlist > 99);
1902
1973
  setIsFirstLoading(false);
1903
1974
  setIsLoading(false);
1904
- localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, valueTotalWishlist);
1975
+ safeSetItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, String(valueTotalWishlist));
1905
1976
  }
1906
1977
  });
1907
1978
  } else {
1908
- localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, totalWishlist);
1979
+ safeSetItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, String(totalWishlist));
1909
1980
  }
1910
1981
  };
1911
1982
  const handleSettings = async (LOCAL_STORAGE_WISHLIST_SETTING) => {
@@ -1920,7 +1991,7 @@ const BadgeCounter = (props) => {
1920
1991
  React__default.useEffect(() => {
1921
1992
  if (!isRenderAppWishlist)
1922
1993
  return;
1923
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
1994
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
1924
1995
  }, [isRenderAppWishlist]);
1925
1996
  React__default.useEffect(() => {
1926
1997
  if (!(dataSettings == null ? void 0 : dataSettings.launch_point) || !isRenderAppWishlist)
@@ -1934,7 +2005,7 @@ const BadgeCounter = (props) => {
1934
2005
  triggerRenderWishlistBadge(false);
1935
2006
  handleGetWishlistInfo();
1936
2007
  }, [valueRenderWishlistBadge, isRenderAppWishlist]);
1937
- const defaultTotalWishlist = isJsVersion ? (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || null : null;
2008
+ const defaultTotalWishlist = isJsVersion ? safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER) || null : null;
1938
2009
  const contentTotalWishlist = isFirstLoading ? defaultTotalWishlist : isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0;
1939
2010
  return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "data-wishlist-counter": contentTotalWishlist, children: contentTotalWishlist });
1940
2011
  };
@@ -2721,8 +2792,8 @@ const WidgetRoot = (props) => {
2721
2792
  let responseGeneral;
2722
2793
  let responseInstantSearch;
2723
2794
  response = wishlistPreviewSettings || JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
2724
- responseGeneral = generalPreviewSettings || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
2725
- responseInstantSearch = instantSearchPreviewSettings || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
2795
+ responseGeneral = generalPreviewSettings || JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
2796
+ responseInstantSearch = instantSearchPreviewSettings || JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
2726
2797
  if (!response)
2727
2798
  return;
2728
2799
  const { sorts } = response == null ? void 0 : response.display;
@@ -2734,7 +2805,7 @@ const WidgetRoot = (props) => {
2734
2805
  setInstantSearchSettings(responseInstantSearch);
2735
2806
  };
2736
2807
  useEffectOnChange(() => {
2737
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
2808
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
2738
2809
  }, [previewSettings]);
2739
2810
  React__default.useEffect(() => {
2740
2811
  if (!isRenderAppWishlist)
@@ -2776,7 +2847,7 @@ const WidgetRoot = (props) => {
2776
2847
  };
2777
2848
  }
2778
2849
  handleShareData();
2779
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
2850
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
2780
2851
  setIsFirstLoading(false);
2781
2852
  }, [isRenderAppWishlist]);
2782
2853
  React__default.useEffect(() => {
@@ -2901,7 +2972,7 @@ const Badge = (props) => {
2901
2972
  setIsMaximizeTotalWishlist(valueTotalWishlist > 99);
2902
2973
  setProxyUrl(valueProxyUrl);
2903
2974
  setData(valueData);
2904
- localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, valueTotalWishlist);
2975
+ safeSetItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, String(valueTotalWishlist));
2905
2976
  },
2906
2977
  wishlistPreviewSettings,
2907
2978
  generalPreviewSettings
@@ -2948,7 +3019,7 @@ const Badge = (props) => {
2948
3019
  }
2949
3020
  };
2950
3021
  useEffectOnChange(() => {
2951
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
3022
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
2952
3023
  handleConfirmationPopup({
2953
3024
  isPreviewSettings: true
2954
3025
  });
@@ -2956,7 +3027,7 @@ const Badge = (props) => {
2956
3027
  React__default.useEffect(() => {
2957
3028
  if (!isRenderAppWishlist)
2958
3029
  return;
2959
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
3030
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
2960
3031
  }, [isRenderAppWishlist]);
2961
3032
  React__default.useEffect(() => {
2962
3033
  if (!(dataSettings == null ? void 0 : dataSettings.launch_point) || !isRenderAppWishlist)
@@ -3016,7 +3087,7 @@ const Badge = (props) => {
3016
3087
  data: isJsVersion ? {
3017
3088
  ...data,
3018
3089
  ...{
3019
- total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
3090
+ total_data: safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER) || (data == null ? void 0 : data.total_data)
3020
3091
  }
3021
3092
  } : data
3022
3093
  }
@@ -3043,7 +3114,7 @@ const Badge = (props) => {
3043
3114
  data: isJsVersion ? {
3044
3115
  ...data,
3045
3116
  ...{
3046
- total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
3117
+ total_data: safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER) || (data == null ? void 0 : data.total_data)
3047
3118
  }
3048
3119
  } : data
3049
3120
  }
@@ -3067,7 +3138,7 @@ const Badge = (props) => {
3067
3138
  data: isJsVersion ? {
3068
3139
  ...data,
3069
3140
  ...{
3070
- total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
3141
+ total_data: safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER) || (data == null ? void 0 : data.total_data)
3071
3142
  }
3072
3143
  } : data
3073
3144
  }
@@ -3093,7 +3164,7 @@ const Badge = (props) => {
3093
3164
  data: isJsVersion ? {
3094
3165
  ...data,
3095
3166
  ...{
3096
- total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
3167
+ total_data: safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER) || (data == null ? void 0 : data.total_data)
3097
3168
  }
3098
3169
  } : data
3099
3170
  }
@@ -3147,7 +3218,7 @@ const BadgeCounterInitSelector = (props) => {
3147
3218
  productReview: true,
3148
3219
  instantSearch: true
3149
3220
  },
3150
- sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3221
+ sledgeAnonymId: safeGetItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3151
3222
  isJsVersion: true
3152
3223
  },
3153
3224
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(BadgeCounter, { previewSettings })
@@ -3161,7 +3232,7 @@ const BadgeInitSelector = (props) => {
3161
3232
  var _a;
3162
3233
  const { selector = "", reload = false, previewSettings = null } = props || {};
3163
3234
  const getSelector = selector || SELECTOR.WISHLIST.ELEMENT_BADGE;
3164
- const LOCAL_STORAGE_WISHLIST_SETTING = localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null) : null;
3235
+ const LOCAL_STORAGE_WISHLIST_SETTING = safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) ? JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null) : null;
3165
3236
  const sledgeWishlistSettings = objectPresent((_a = previewSettings == null ? void 0 : previewSettings.settings) == null ? void 0 : _a.wishlist) || LOCAL_STORAGE_WISHLIST_SETTING;
3166
3237
  let element = Array.from(document.querySelectorAll(getSelector));
3167
3238
  let isElementDetected = !element || element && !element.length;
@@ -3202,7 +3273,7 @@ const BadgeInitSelector = (props) => {
3202
3273
  productReview: true,
3203
3274
  instantSearch: true
3204
3275
  },
3205
- sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3276
+ sledgeAnonymId: safeGetItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3206
3277
  isJsVersion: true
3207
3278
  },
3208
3279
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -3253,7 +3324,7 @@ const BadgeInitSelector = (props) => {
3253
3324
  productReview: true,
3254
3325
  instantSearch: true
3255
3326
  },
3256
- sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3327
+ sledgeAnonymId: safeGetItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3257
3328
  isJsVersion: true
3258
3329
  },
3259
3330
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -3305,7 +3376,7 @@ const BadgeInitSelector = (props) => {
3305
3376
  productReview: true,
3306
3377
  instantSearch: true
3307
3378
  },
3308
- sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3379
+ sledgeAnonymId: safeGetItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3309
3380
  isJsVersion: true
3310
3381
  },
3311
3382
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -3529,7 +3600,7 @@ const Trigger = (props) => {
3529
3600
  setIsRequiredLogin(sledgeAnonymId && is_required_login2);
3530
3601
  };
3531
3602
  useEffectOnChange(() => {
3532
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
3603
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
3533
3604
  handleConfirmationPopup({
3534
3605
  isPreviewSettings: true
3535
3606
  });
@@ -3546,7 +3617,7 @@ const Trigger = (props) => {
3546
3617
  handleCheckWishlist();
3547
3618
  };
3548
3619
  }
3549
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
3620
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
3550
3621
  }, [isRenderAppWishlist, hasEntry]);
3551
3622
  useEffectOnChange(() => {
3552
3623
  setIsRequiredLogin(sledgeAnonymId && is_required_login);
@@ -3634,7 +3705,7 @@ const ElementInit = (item, reload, previewSettings) => {
3634
3705
  productReview: true,
3635
3706
  instantSearch: true
3636
3707
  },
3637
- sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3708
+ sledgeAnonymId: safeGetItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3638
3709
  isJsVersion: true
3639
3710
  },
3640
3711
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -3680,7 +3751,7 @@ const TriggerInitSelector = (props) => {
3680
3751
  const getReviewInfo = async (props) => {
3681
3752
  const { productId = null, query = null } = props || {};
3682
3753
  let convertId = productId ? sanitizeDataId(productId) : "";
3683
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
3754
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
3684
3755
  let queryParams = "?" + new URLSearchParams({
3685
3756
  [PAYLOAD_API_ALIASES.Authorization]: sledgeAuthApp,
3686
3757
  ...query
@@ -3699,7 +3770,7 @@ const getReviewInfo = async (props) => {
3699
3770
  };
3700
3771
  const getProductsReviewInfo = async (ids, token) => {
3701
3772
  let convertIds = ids.map((v) => sanitizeDataId(v));
3702
- let sledgeAuthApp = token ? token : typeof localStorage !== "undefined" ? (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP)) || "" : "";
3773
+ let sledgeAuthApp = token ? token : safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
3703
3774
  let url = `${API_URL}/review/info/ids/${convertIds.join(",")}?${PAYLOAD_API_ALIASES.Authorization}=${sledgeAuthApp}`;
3704
3775
  return await fetchApi({
3705
3776
  url,
@@ -3836,7 +3907,7 @@ const Rating = (props) => {
3836
3907
  };
3837
3908
  useEffectOnChange(() => {
3838
3909
  handleSettings({
3839
- LOCAL_STORAGE_PRODUCT_REVIEW_SETTING: localStorage.getItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || null,
3910
+ LOCAL_STORAGE_PRODUCT_REVIEW_SETTING: safeGetItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || null,
3840
3911
  isPreviewSettings: true
3841
3912
  });
3842
3913
  }, [previewSettings]);
@@ -3867,7 +3938,7 @@ const Rating = (props) => {
3867
3938
  if (isProductIdChanged)
3868
3939
  setIsFirstLoading(true);
3869
3940
  handleSettings({
3870
- LOCAL_STORAGE_PRODUCT_REVIEW_SETTING: localStorage.getItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || null
3941
+ LOCAL_STORAGE_PRODUCT_REVIEW_SETTING: safeGetItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || null
3871
3942
  });
3872
3943
  }, [isRenderAppProductReview, hasEntry, productId]);
3873
3944
  React__default.useEffect(() => {
@@ -4235,7 +4306,7 @@ WidgetHeader.Sort = WidgetHeaderSort;
4235
4306
  WidgetHeader.AddTrigger = WidgetHeaderAddTrigger;
4236
4307
  WidgetHeader.Summary = WidgetHeaderSummary;
4237
4308
  const search = async (index, payload) => {
4238
- let sledgeInstantSearchAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_AUTH_APP) || "" : "";
4309
+ let sledgeInstantSearchAuthApp = safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_AUTH_APP) || "";
4239
4310
  let url = `${INSTANT_SEARCH_ENGINE_URL}/indexes/${index}/search`;
4240
4311
  let headers = {
4241
4312
  "Content-Type": "application/json"
@@ -4252,7 +4323,7 @@ const search = async (index, payload) => {
4252
4323
  });
4253
4324
  };
4254
4325
  const multiSearch = async (payload, token) => {
4255
- let sledgeInstantSearchAuthApp = token ? token : typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_AUTH_APP) || "" : "";
4326
+ let sledgeInstantSearchAuthApp = token ? token : safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_AUTH_APP) || "";
4256
4327
  let url = `${INSTANT_SEARCH_ENGINE_URL}/multi-search`;
4257
4328
  let headers = {
4258
4329
  "Content-Type": "application/json"
@@ -4270,7 +4341,7 @@ const multiSearch = async (payload, token) => {
4270
4341
  };
4271
4342
  const searchTrigger = async (data) => {
4272
4343
  const { keyword, resultCount } = data;
4273
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
4344
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
4274
4345
  let url = `${API_URL}/instantsearch/statistics/search`;
4275
4346
  let headers = {
4276
4347
  "Content-Type": "application/json"
@@ -4294,7 +4365,7 @@ const searchTrigger = async (data) => {
4294
4365
  };
4295
4366
  const productClickTrigger$1 = async (data) => {
4296
4367
  const { productId } = data;
4297
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
4368
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
4298
4369
  let url = `${API_URL}/instantsearch/statistics/click`;
4299
4370
  let headers = {
4300
4371
  "Content-Type": "application/json"
@@ -4319,7 +4390,7 @@ const productClickTrigger$1 = async (data) => {
4319
4390
  };
4320
4391
  const addToCartTrigger$1 = async (data) => {
4321
4392
  const { productId } = data;
4322
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
4393
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
4323
4394
  let url = `${API_URL}/instantsearch/statistics/cart`;
4324
4395
  let headers = {
4325
4396
  "Content-Type": "application/json"
@@ -4345,7 +4416,7 @@ const addToCartTrigger$1 = async (data) => {
4345
4416
  const productRecommendationSourceApps = ["recently-viewed", "related-product", "hand-picked", "new-arrival", "personalized-curated"];
4346
4417
  const productClickTrigger = async (data) => {
4347
4418
  const { productId, sourceApp } = data;
4348
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
4419
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
4349
4420
  let url = `${API_URL}/product-recommendation/statistics/click`;
4350
4421
  let headers = {
4351
4422
  "Content-Type": "application/json"
@@ -4369,7 +4440,7 @@ const productClickTrigger = async (data) => {
4369
4440
  };
4370
4441
  const addToCartTrigger = async (data) => {
4371
4442
  const { productId, sourceApp } = data;
4372
- let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
4443
+ let sledgeAuthApp = safeGetItem(LOCAL_STORAGE_KEY.AUTH_APP) || "";
4373
4444
  let url = `${API_URL}/product-recommendation/statistics/cart`;
4374
4445
  let headers = {
4375
4446
  "Content-Type": "application/json"
@@ -4594,7 +4665,7 @@ const VariantSelector = (props) => {
4594
4665
  const defaultOptionClass = `
4595
4666
  ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} sledge__product-variant-size-swatch`;
4596
4667
  const colorOptionClass = `${selectedOption === item ? "sledge__product-variant-color-swatch-active" : ""} sledge__product-variant-color-swatch`;
4597
- const colorDataSettings = ((_a3 = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING))) == null ? void 0 : _a3.colors) || [];
4668
+ const colorDataSettings = ((_a3 = JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING))) == null ? void 0 : _a3.colors) || [];
4598
4669
  const getColorSwatch = (colorDataSettings == null ? void 0 : colorDataSettings.filter(({ name }) => name === item)[0]) || {};
4599
4670
  const colorSwatch = (getColorSwatch == null ? void 0 : getColorSwatch.image) ? `url('${getColorSwatch == null ? void 0 : getColorSwatch.image}')` : (getColorSwatch == null ? void 0 : getColorSwatch.rgb) || item;
4600
4671
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -5197,7 +5268,7 @@ const ProductGrid = React__default.memo((props) => {
5197
5268
  };
5198
5269
  const handleSettings = () => {
5199
5270
  let responseGeneral;
5200
- responseGeneral = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
5271
+ responseGeneral = JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
5201
5272
  if (responseGeneral)
5202
5273
  setGeneralDataSettings(responseGeneral);
5203
5274
  };
@@ -5416,7 +5487,7 @@ const SkeletonItem = ({ width, height, rounded, color, style = {}, className = "
5416
5487
  setDataSettings(response);
5417
5488
  };
5418
5489
  React__default.useEffect(() => {
5419
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
5490
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
5420
5491
  }, []);
5421
5492
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: ((_a = dataSettings == null ? void 0 : dataSettings.skeleton) == null ? void 0 : _a.enable) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
5422
5493
  "div",
@@ -5449,7 +5520,7 @@ const SkeletonProductGrid = ({ count, type, isFlyout = false, currentColumnGrid
5449
5520
  setDataSettings(response);
5450
5521
  };
5451
5522
  React__default.useEffect(() => {
5452
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
5523
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
5453
5524
  }, []);
5454
5525
  let components = [];
5455
5526
  for (let i = 0; i < count; i++) {
@@ -6291,7 +6362,7 @@ const SearchIconWidgetPopup = () => {
6291
6362
  };
6292
6363
  }
6293
6364
  handleSettings({
6294
- LOCAL_STORAGE_INSTANT_SEARCH_SETTING: localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null
6365
+ LOCAL_STORAGE_INSTANT_SEARCH_SETTING: safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null
6295
6366
  });
6296
6367
  }, [isRenderAppInstantSearch]);
6297
6368
  React__default.useEffect(() => {
@@ -6299,7 +6370,7 @@ const SearchIconWidgetPopup = () => {
6299
6370
  }, [showInfo]);
6300
6371
  React__default.useEffect(() => {
6301
6372
  if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
6302
- const INSTANT_SEARCH_SETTING = (handleFunctions == null ? void 0 : handleFunctions.instantSearchPreviewSettings) || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
6373
+ const INSTANT_SEARCH_SETTING = (handleFunctions == null ? void 0 : handleFunctions.instantSearchPreviewSettings) || JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
6303
6374
  const delayDebounceFn = setTimeout(() => {
6304
6375
  if (INSTANT_SEARCH_SETTING)
6305
6376
  handleMultiSearch({
@@ -6312,7 +6383,7 @@ const SearchIconWidgetPopup = () => {
6312
6383
  }, [keyword]);
6313
6384
  useEffectOnChange(() => {
6314
6385
  handleSettings({
6315
- LOCAL_STORAGE_INSTANT_SEARCH_SETTING: localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null,
6386
+ LOCAL_STORAGE_INSTANT_SEARCH_SETTING: safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null,
6316
6387
  isPreviewSettings: true
6317
6388
  });
6318
6389
  }, [handleFunctions == null ? void 0 : handleFunctions.instantSearchPreviewSettings]);
@@ -8506,15 +8577,15 @@ const ColumnGridSelector = ({
8506
8577
  isDesktopLayout,
8507
8578
  showText = true
8508
8579
  }) => {
8509
- const desktopColumns = localStorage.getItem(LOCAL_STORAGE_KEY.GRID_DESKTOP_COLUMN) || "column-3";
8510
- const mobileColumns = localStorage.getItem(LOCAL_STORAGE_KEY.GRID_MOBILE_COLUMN) || "column-2";
8580
+ const desktopColumns = safeGetItem(LOCAL_STORAGE_KEY.GRID_DESKTOP_COLUMN) || "column-3";
8581
+ const mobileColumns = safeGetItem(LOCAL_STORAGE_KEY.GRID_MOBILE_COLUMN) || "column-2";
8511
8582
  const changeGridLayout = (type, value) => {
8512
8583
  const newLayout = { ...currentColumnGrid, [type]: value };
8513
8584
  setCurrentColumnGrid == null ? void 0 : setCurrentColumnGrid(newLayout);
8514
8585
  if (type === "desktop") {
8515
- localStorage.setItem(LOCAL_STORAGE_KEY.GRID_DESKTOP_COLUMN, value);
8586
+ safeSetItem(LOCAL_STORAGE_KEY.GRID_DESKTOP_COLUMN, value);
8516
8587
  } else {
8517
- localStorage.setItem(LOCAL_STORAGE_KEY.GRID_MOBILE_COLUMN, value);
8588
+ safeSetItem(LOCAL_STORAGE_KEY.GRID_MOBILE_COLUMN, value);
8518
8589
  }
8519
8590
  };
8520
8591
  React__default.useEffect(() => {
@@ -9416,15 +9487,15 @@ const SearchResultWidget = (props) => {
9416
9487
  const querySortBy = (query == null ? void 0 : query.sortBy) ? query.sortBy : DEFAULT_QUERY_PARAM.SORT_BY;
9417
9488
  const queryPage = (query == null ? void 0 : query.page) ? query.page : DEFAULT_QUERY_PARAM.PAGE;
9418
9489
  const queryLimit = (query == null ? void 0 : query.limit) ? query.limit : DEFAULT_QUERY_PARAM.LIMIT;
9419
- const desktopColumns = localStorage.getItem(LOCAL_STORAGE_KEY.GRID_DESKTOP_COLUMN) || "column-3";
9420
- const mobileColumns = localStorage.getItem(LOCAL_STORAGE_KEY.GRID_MOBILE_COLUMN) || "column-2";
9490
+ const desktopColumns = safeGetItem(LOCAL_STORAGE_KEY.GRID_DESKTOP_COLUMN) || "column-3";
9491
+ const mobileColumns = safeGetItem(LOCAL_STORAGE_KEY.GRID_MOBILE_COLUMN) || "column-2";
9421
9492
  const { collectionId } = params || {};
9422
9493
  const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
9423
9494
  const { generalPreviewSettings, instantSearchPreviewSettings, previewSettings } = usePreviewSettings({
9424
9495
  defaultSettings: previewSettingsProp,
9425
9496
  nestedProperty: layoutType === "product-filter" ? "sledge.instantSearch.productFilter.preview" : "sledge.instantSearch.searchResult.preview"
9426
9497
  });
9427
- const [settings] = React__default.useState(instantSearchPreviewSettings || typeof localStorage !== "undefined" ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}") : {});
9498
+ const [settings] = React__default.useState(instantSearchPreviewSettings || JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}"));
9428
9499
  const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
9429
9500
  const [isLoading, setIsLoading] = React__default.useState(!propsData);
9430
9501
  const [keyword, setKeyword] = React__default.useState(searchParams == null ? void 0 : searchParams.get(queryKeyword));
@@ -9639,13 +9710,11 @@ const SearchResultWidget = (props) => {
9639
9710
  facetDistribution
9640
9711
  } = isUpdateFilter ? results || {} : layoutType === "default" ? ((_a2 = results == null ? void 0 : results.find) == null ? void 0 : _a2.call(results, ({ indexUid }) => indexUid.includes(index_product))) || {} : results || {};
9641
9712
  let totalHits = totalHitsResult || 0;
9642
- if (typeof localStorage !== "undefined") {
9643
- const INIT_TOTAL_HITS = Number(localStorage.getItem(layoutType === "default" ? LOCAL_STORAGE_KEY.SEARCH_RESULT_INIT_TOTAL_HITS : LOCAL_STORAGE_KEY.PRODUCT_FILTER_INIT_TOTAL_HITS) || 0);
9644
- if (!(INIT_TOTAL_HITS > 1)) {
9645
- localStorage.setItem(layoutType === "default" ? LOCAL_STORAGE_KEY.SEARCH_RESULT_INIT_TOTAL_HITS : LOCAL_STORAGE_KEY.PRODUCT_FILTER_INIT_TOTAL_HITS, totalHits);
9646
- }
9647
- totalHits = totalHits <= 1 ? INIT_TOTAL_HITS : totalHits;
9713
+ const INIT_TOTAL_HITS = Number(safeGetItem(layoutType === "default" ? LOCAL_STORAGE_KEY.SEARCH_RESULT_INIT_TOTAL_HITS : LOCAL_STORAGE_KEY.PRODUCT_FILTER_INIT_TOTAL_HITS) || 0);
9714
+ if (!(INIT_TOTAL_HITS > 1)) {
9715
+ safeSetItem(layoutType === "default" ? LOCAL_STORAGE_KEY.SEARCH_RESULT_INIT_TOTAL_HITS : LOCAL_STORAGE_KEY.PRODUCT_FILTER_INIT_TOTAL_HITS, String(totalHits));
9648
9716
  }
9717
+ totalHits = totalHits <= 1 ? INIT_TOTAL_HITS : totalHits;
9649
9718
  setTotalHitsProduct(totalHits || 0);
9650
9719
  let valueHideFilterWhenOneValue = ((_b2 = display == null ? void 0 : display.filter) == null ? void 0 : _b2.hide_when_one_value) && totalHits <= 1;
9651
9720
  let valueSearchResultFacets = facetDistribution ? Object.fromEntries(
@@ -9776,7 +9845,7 @@ const SearchResultWidget = (props) => {
9776
9845
  let responseGeneral;
9777
9846
  let getFirstIndex;
9778
9847
  response = instantSearchPreviewSettings || JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
9779
- responseGeneral = generalPreviewSettings || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
9848
+ responseGeneral = generalPreviewSettings || JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
9780
9849
  if (!response)
9781
9850
  return;
9782
9851
  setInstantSearchSettings(response);
@@ -9826,7 +9895,7 @@ const SearchResultWidget = (props) => {
9826
9895
  valueDefaultSort = (_e2 = valueAllowedSorts == null ? void 0 : valueAllowedSorts[0]) == null ? void 0 : _e2.value;
9827
9896
  }
9828
9897
  setDefaultSort(valueDefaultSort);
9829
- setDefaultLimit(instantSearchPreviewSettings ? limit : (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT)) || limit);
9898
+ setDefaultLimit(instantSearchPreviewSettings ? limit : safeGetItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT) || limit);
9830
9899
  setLanguageSettings(languages);
9831
9900
  setHierarchicalProductTypeSettings(hierarchical_product_type);
9832
9901
  setHierarchicalCollectionsSettings(hierarchical_collections);
@@ -9883,13 +9952,13 @@ const SearchResultWidget = (props) => {
9883
9952
  window.history.replaceState(null, "", `${document.location.pathname}?${searchParams2.toString()}`);
9884
9953
  }, []);
9885
9954
  const initStates = () => {
9886
- const INSTANT_SEARCH_SETTING = instantSearchPreviewSettings || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
9955
+ const INSTANT_SEARCH_SETTING = instantSearchPreviewSettings || JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
9887
9956
  if (INSTANT_SEARCH_SETTING)
9888
9957
  handleInitStates(INSTANT_SEARCH_SETTING);
9889
9958
  };
9890
9959
  useEffectOnChange(() => {
9891
9960
  handleSettings({
9892
- LOCAL_STORAGE_INSTANT_SEARCH_SETTING: localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null,
9961
+ LOCAL_STORAGE_INSTANT_SEARCH_SETTING: safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null,
9893
9962
  isPreviewSettings: true
9894
9963
  });
9895
9964
  }, [previewSettings]);
@@ -9899,7 +9968,7 @@ const SearchResultWidget = (props) => {
9899
9968
  return;
9900
9969
  initStates();
9901
9970
  handleSettings({
9902
- LOCAL_STORAGE_INSTANT_SEARCH_SETTING: localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null
9971
+ LOCAL_STORAGE_INSTANT_SEARCH_SETTING: safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null
9903
9972
  });
9904
9973
  if (typeof window !== "undefined") {
9905
9974
  if (layoutType === "default") {
@@ -10543,7 +10612,7 @@ const ResultProduct = React__default.memo((props) => {
10543
10612
  const searchParams2 = new URLSearchParams(document.location.search);
10544
10613
  searchParams2.set(queryLimit, String(value));
10545
10614
  setClickedLimitId(Number(value));
10546
- localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT, value);
10615
+ safeSetItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT, String(value));
10547
10616
  if (!objectPresent(previewSettings))
10548
10617
  window.history.replaceState(null, "", `${document.location.pathname}?${searchParams2.toString()}`);
10549
10618
  }, []);
@@ -10666,7 +10735,7 @@ const ResultProduct = React__default.memo((props) => {
10666
10735
  const handleSearchResultData = async (props2) => {
10667
10736
  var _a2, _b2;
10668
10737
  const { isLoadMore: isLoadMore2 = false, result: resultProp, onSearch } = props2;
10669
- const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
10738
+ const INSTANT_SEARCH_SETTING = JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
10670
10739
  const { index_product } = INSTANT_SEARCH_SETTING || {};
10671
10740
  const isNoneFacetSelected = Boolean(!((_a2 = handleDataClickedFacets()) == null ? void 0 : _a2.length));
10672
10741
  const isFirstTimeOrOnSearch = handleSearchResultFirstTime && initStatesFirstTime || onSearch;
@@ -11408,7 +11477,7 @@ const ResultCategory = React__default.memo((props) => {
11408
11477
  const handleSearchResultData = (props2) => {
11409
11478
  var _a;
11410
11479
  const { isReplaceData = false, result: resultProp, onSearch } = props2;
11411
- const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
11480
+ const INSTANT_SEARCH_SETTING = JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
11412
11481
  const handleSearchResultFirstTime = isFirstLoading;
11413
11482
  const isFirstTimeOrOnSearch = handleSearchResultFirstTime && initStatesFirstTime || onSearch;
11414
11483
  const resultData = isFirstTimeOrOnSearch ? resultProp == null ? void 0 : resultProp.results : resultProp;
@@ -11713,13 +11782,13 @@ const SearchWidget = (props) => {
11713
11782
  await handleMultiSearch(response);
11714
11783
  };
11715
11784
  useEffectOnChange(() => {
11716
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
11785
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
11717
11786
  }, [previewSettings]);
11718
11787
  React__default.useEffect(() => {
11719
11788
  var _a2, _b2;
11720
11789
  if (!isRenderAppInstantSearch)
11721
11790
  return;
11722
- handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
11791
+ handleSettings(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
11723
11792
  if (typeof window !== "undefined") {
11724
11793
  if ((_b2 = (_a2 = window == null ? void 0 : window.sledge) == null ? void 0 : _a2.instantSearch) == null ? void 0 : _b2.searchWidget)
11725
11794
  window.sledge.instantSearch.searchWidget.search = (keyword2 = "") => {
@@ -11732,7 +11801,7 @@ const SearchWidget = (props) => {
11732
11801
  }
11733
11802
  }, [isRenderAppInstantSearch]);
11734
11803
  useEffectOnChange(() => {
11735
- const INSTANT_SEARCH_SETTING = instantSearchPreviewSettings || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
11804
+ const INSTANT_SEARCH_SETTING = instantSearchPreviewSettings || JSON.parse(safeGetItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
11736
11805
  setShowSearchResult(keyword ? true : false);
11737
11806
  if (INSTANT_SEARCH_SETTING)
11738
11807
  handleMultiSearch(INSTANT_SEARCH_SETTING, true);