@yoast/ai-insights-client 1.4.81 → 1.4.83

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.
@@ -4716,15 +4716,12 @@ function _regeneratorDefine2$8(e, r, n, t) {
4716
4716
  i = 0;
4717
4717
  }
4718
4718
  _regeneratorDefine2$8 = function _regeneratorDefine(e2, r2, n2, t2) {
4719
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
4720
- else {
4721
- var o = function o2(r3, n3) {
4722
- _regeneratorDefine2$8(e2, r3, function(e3) {
4723
- return this._invoke(r3, n3, e3);
4724
- });
4725
- };
4726
- o("next", 0), o("throw", 1), o("return", 2);
4719
+ function o(r3, n3) {
4720
+ _regeneratorDefine2$8(e2, r3, function(e3) {
4721
+ return this._invoke(r3, n3, e3);
4722
+ });
4727
4723
  }
4724
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
4728
4725
  }, _regeneratorDefine2$8(e, r, n, t);
4729
4726
  }
4730
4727
  function ownKeys$a(e, r) {
@@ -6224,7 +6221,7 @@ function _objectWithoutPropertiesLoose$5(r, e) {
6224
6221
  }
6225
6222
  var SkipLink = function SkipLink2(_ref) {
6226
6223
  var className = _ref.className, _ref$href = _ref.href, href = _ref$href === void 0 ? "#content" : _ref$href, props = _objectWithoutProperties$5(_ref, _excluded$5);
6227
- return /* @__PURE__ */ jsx("a", { href, className: cx("yst-absolute yst-left-[10px] yst-z-[100000] yst-block yst-h-12 yst-min-w-[150px] yst-px-[15px] yst-text-[14px] yst-leading-[48px] yst-bg-[var(--bg-color-white)] yst-rounded yst-shadow-md yst-underline yst-text-center yst-outline-none; yst--top-[1000em] focus:yst-top-[10px] focus:yst-text-[var(--text-color-blue)]", className), ...props, children: "Skip to main content" });
6224
+ return /* @__PURE__ */ jsx("a", { href, className: cx("yst-outline-none yst-absolute yst--top-[1000em] yst-left-[10px] yst-z-[100000] yst-block yst-h-12 yst-min-w-[150px] yst-rounded yst-bg-[var(--bg-color-white)] yst-px-[15px] yst-text-center yst-text-[14px] yst-leading-[48px] yst-underline yst-shadow-md focus:yst-top-[10px] focus:yst-text-[var(--text-color-blue)]", className), ...props, children: "Skip to main content" });
6228
6225
  };
6229
6226
  function Layout(_ref) {
6230
6227
  var children = _ref.children, _ref$disable = _ref.disable, disable = _ref$disable === void 0 ? false : _ref$disable, _ref$hideNav = _ref.hideNav, hideNav = _ref$hideNav === void 0 ? false : _ref$hideNav, DebugInfo = _ref.DebugInfo;
@@ -6317,15 +6314,12 @@ function _regeneratorDefine2$7(e, r, n, t) {
6317
6314
  i = 0;
6318
6315
  }
6319
6316
  _regeneratorDefine2$7 = function _regeneratorDefine(e2, r2, n2, t2) {
6320
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
6321
- else {
6322
- var o = function o2(r3, n3) {
6323
- _regeneratorDefine2$7(e2, r3, function(e3) {
6324
- return this._invoke(r3, n3, e3);
6325
- });
6326
- };
6327
- o("next", 0), o("throw", 1), o("return", 2);
6317
+ function o(r3, n3) {
6318
+ _regeneratorDefine2$7(e2, r3, function(e3) {
6319
+ return this._invoke(r3, n3, e3);
6320
+ });
6328
6321
  }
6322
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
6329
6323
  }, _regeneratorDefine2$7(e, r, n, t);
6330
6324
  }
6331
6325
  function asyncGeneratorStep$7(n, t, e, r, o, a, c) {
@@ -9626,6 +9620,77 @@ function isToday(date, options) {
9626
9620
  function subMonths(date, amount, options) {
9627
9621
  return addMonths(date, -1, options);
9628
9622
  }
9623
+ function getMillisecondsUntilNextAnalysis(nextScheduledAnalysis) {
9624
+ if (nextScheduledAnalysis === void 0 || nextScheduledAnalysis === null) {
9625
+ return void 0;
9626
+ }
9627
+ if (typeof nextScheduledAnalysis === "number") {
9628
+ var EPOCH_MS_THRESHOLD = 1e12;
9629
+ if (nextScheduledAnalysis > EPOCH_MS_THRESHOLD) {
9630
+ return nextScheduledAnalysis - Date.now();
9631
+ } else {
9632
+ return nextScheduledAnalysis;
9633
+ }
9634
+ }
9635
+ var parsed = Date.parse(nextScheduledAnalysis);
9636
+ if (!Number.isNaN(parsed)) {
9637
+ return parsed - Date.now();
9638
+ }
9639
+ return void 0;
9640
+ }
9641
+ function isAnalysisScheduledMoreThanMinutesAway(nextScheduledAnalysis, minutes) {
9642
+ var msUntilNext = getMillisecondsUntilNextAnalysis(nextScheduledAnalysis);
9643
+ return msUntilNext !== void 0 && msUntilNext > minutes * 60 * 1e3;
9644
+ }
9645
+ var ANALYSIS_SCHEDULE_WARNING_MINUTES = 2;
9646
+ function isAnalysisScheduledWithinMinutes(nextScheduledAnalysis) {
9647
+ var minutes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ANALYSIS_SCHEDULE_WARNING_MINUTES;
9648
+ var msUntilNext = getMillisecondsUntilNextAnalysis(nextScheduledAnalysis);
9649
+ return msUntilNext !== void 0 && msUntilNext <= minutes * 60 * 1e3;
9650
+ }
9651
+ function formatScheduledAnalysisDate(nextScheduledAnalysis) {
9652
+ if (nextScheduledAnalysis === void 0 || nextScheduledAnalysis === null) {
9653
+ return "a future date";
9654
+ }
9655
+ var timestamp;
9656
+ if (typeof nextScheduledAnalysis === "number") {
9657
+ var EPOCH_MS_THRESHOLD = 1e12;
9658
+ if (nextScheduledAnalysis > EPOCH_MS_THRESHOLD) {
9659
+ timestamp = nextScheduledAnalysis;
9660
+ } else {
9661
+ timestamp = Date.now() + nextScheduledAnalysis;
9662
+ }
9663
+ } else {
9664
+ var parsed = Date.parse(nextScheduledAnalysis);
9665
+ if (!Number.isNaN(parsed)) {
9666
+ timestamp = parsed;
9667
+ }
9668
+ }
9669
+ if (timestamp === void 0) {
9670
+ return "a future date";
9671
+ }
9672
+ var date = new Date(timestamp);
9673
+ var dateOptions = {
9674
+ month: "long",
9675
+ day: "numeric"
9676
+ };
9677
+ var timeOptions = {
9678
+ hour: "numeric",
9679
+ minute: "2-digit",
9680
+ hour12: true
9681
+ };
9682
+ var datePart = date.toLocaleDateString("en-US", dateOptions);
9683
+ var timePart = date.toLocaleTimeString("en-US", timeOptions);
9684
+ return "".concat(datePart, " at ").concat(timePart);
9685
+ }
9686
+ function getLocalDateFromUTCTimestamp(utcTimestamp) {
9687
+ if (!utcTimestamp) return null;
9688
+ var utcDate = new Date(utcTimestamp);
9689
+ if (isNaN(utcDate.getTime())) {
9690
+ return null;
9691
+ }
9692
+ return utcDate;
9693
+ }
9629
9694
  function _typeof$8(o) {
9630
9695
  "@babel/helpers - typeof";
9631
9696
  return _typeof$8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
@@ -9674,10 +9739,8 @@ function _iterableToArrayLimit$g(r, l) {
9674
9739
  if (null != t) {
9675
9740
  var e, n, i, u, a = [], f = true, o = false;
9676
9741
  try {
9677
- if (i = (t = t.call(r)).next, 0 === l) {
9678
- if (Object(t) !== t) return;
9679
- f = false;
9680
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
9742
+ if (i = (t = t.call(r)).next, 0 === l) ;
9743
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
9681
9744
  } catch (r2) {
9682
9745
  o = true, n = r2;
9683
9746
  } finally {
@@ -9718,22 +9781,10 @@ var CALENDAR_COLORS = {
9718
9781
  var AnalysisCalendarPicker = function AnalysisCalendarPicker2(_ref) {
9719
9782
  var analyses = _ref.analyses, selectedAnalysisId = _ref.selectedAnalysisId, onAnalysisSelect = _ref.onAnalysisSelect, _ref$isLoading = _ref.isLoading, isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading, _ref$isOpen = _ref.isOpen, isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen, onClose = _ref.onClose;
9720
9783
  var _useState = useState(/* @__PURE__ */ new Date()), _useState2 = _slicedToArray$g(_useState, 2), currentMonth = _useState2[0], setCurrentMonth = _useState2[1];
9721
- var getLocalDateFromCreatedAt = function getLocalDateFromCreatedAt2(createdAt) {
9722
- if (!createdAt) return null;
9723
- var ymd = createdAt.slice(0, 10);
9724
- var _ymd$split = ymd.split("-"), _ymd$split2 = _slicedToArray$g(_ymd$split, 3), yearStr = _ymd$split2[0], monthStr = _ymd$split2[1], dayStr = _ymd$split2[2];
9725
- var year = Number(yearStr);
9726
- var month = Number(monthStr);
9727
- var day = Number(dayStr);
9728
- if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(day) || month < 1 || month > 12 || day < 1 || day > 31) {
9729
- return null;
9730
- }
9731
- return new Date(year, month - 1, day);
9732
- };
9733
9784
  var analysisMap = useMemo(function() {
9734
9785
  var map = /* @__PURE__ */ new Map();
9735
9786
  analyses.forEach(function(analysis) {
9736
- var localDate = getLocalDateFromCreatedAt(analysis.createdAt);
9787
+ var localDate = getLocalDateFromUTCTimestamp(analysis.createdAt);
9737
9788
  var dateKey = localDate ? format(localDate, "yyyy-MM-dd") : "";
9738
9789
  if (!dateKey) return;
9739
9790
  if (!map.has(dateKey)) {
@@ -9749,14 +9800,14 @@ var AnalysisCalendarPicker = function AnalysisCalendarPicker2(_ref) {
9749
9800
  return a.id === selectedAnalysisId;
9750
9801
  });
9751
9802
  if (selectedAnalysis) {
9752
- var localDate = getLocalDateFromCreatedAt(selectedAnalysis.createdAt);
9803
+ var localDate = getLocalDateFromUTCTimestamp(selectedAnalysis.createdAt);
9753
9804
  if (localDate) setCurrentMonth(localDate);
9754
9805
  }
9755
9806
  } else if (isOpen && analyses.length > 0) {
9756
9807
  var mostRecent = analyses.reduce(function(latest, analysis) {
9757
9808
  return new Date(analysis.createdAt) > new Date(latest.createdAt) ? analysis : latest;
9758
9809
  });
9759
- var _localDate = getLocalDateFromCreatedAt(mostRecent.createdAt);
9810
+ var _localDate = getLocalDateFromUTCTimestamp(mostRecent.createdAt);
9760
9811
  if (_localDate) setCurrentMonth(_localDate);
9761
9812
  }
9762
9813
  }, [isOpen, selectedAnalysisId, analyses]);
@@ -9768,13 +9819,13 @@ var AnalysisCalendarPicker = function AnalysisCalendarPicker2(_ref) {
9768
9819
  }, [analyses]);
9769
9820
  var handleShowLatestAnalysis = function handleShowLatestAnalysis2() {
9770
9821
  if (mostRecentAnalysis) {
9771
- var localDate = getLocalDateFromCreatedAt(mostRecentAnalysis.createdAt);
9822
+ var localDate = getLocalDateFromUTCTimestamp(mostRecentAnalysis.createdAt);
9772
9823
  if (localDate) setCurrentMonth(localDate);
9773
9824
  }
9774
9825
  };
9775
9826
  var isLatestAnalysisInCurrentMonth = useMemo(function() {
9776
9827
  if (!mostRecentAnalysis) return false;
9777
- var localDate = getLocalDateFromCreatedAt(mostRecentAnalysis.createdAt);
9828
+ var localDate = getLocalDateFromUTCTimestamp(mostRecentAnalysis.createdAt);
9778
9829
  return localDate ? isSameMonth(localDate, currentMonth) : false;
9779
9830
  }, [mostRecentAnalysis, currentMonth]);
9780
9831
  var calendarDays = useMemo(function() {
@@ -9928,10 +9979,8 @@ function _iterableToArrayLimit$f(r, l) {
9928
9979
  if (null != t) {
9929
9980
  var e, n, i, u, a = [], f = true, o = false;
9930
9981
  try {
9931
- if (i = (t = t.call(r)).next, 0 === l) {
9932
- if (Object(t) !== t) return;
9933
- f = false;
9934
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
9982
+ if (i = (t = t.call(r)).next, 0 === l) ;
9983
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
9935
9984
  } catch (r2) {
9936
9985
  o = true, n = r2;
9937
9986
  } finally {
@@ -9952,22 +10001,10 @@ var AnalysisDateSelect = function AnalysisDateSelect2(_ref) {
9952
10001
  var _useState = useState(false), _useState2 = _slicedToArray$f(_useState, 2), isCalendarOpen = _useState2[0], setIsCalendarOpen = _useState2[1];
9953
10002
  var _useState3 = useState("latest"), _useState4 = _slicedToArray$f(_useState3, 2), localSelectedId = _useState4[0], setLocalSelectedId = _useState4[1];
9954
10003
  var selectRef = useRef(null);
9955
- var getLocalDateFromCreatedAt = function getLocalDateFromCreatedAt2(createdAt) {
9956
- if (!createdAt) return null;
9957
- var ymd = createdAt.slice(0, 10);
9958
- var _ymd$split = ymd.split("-"), _ymd$split2 = _slicedToArray$f(_ymd$split, 3), yearStr = _ymd$split2[0], monthStr = _ymd$split2[1], dayStr = _ymd$split2[2];
9959
- var year = Number(yearStr);
9960
- var month = Number(monthStr);
9961
- var day = Number(dayStr);
9962
- if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(day) || month < 1 || month > 12 || day < 1 || day > 31) {
9963
- return null;
9964
- }
9965
- return new Date(year, month - 1, day);
9966
- };
9967
- var getAnalysisTimestamp = function getAnalysisTimestamp2(analysis) {
9968
- var d = getLocalDateFromCreatedAt(analysis.createdAt);
10004
+ var getAnalysisTimestamp = useCallback(function(analysis) {
10005
+ var d = getLocalDateFromUTCTimestamp(analysis.createdAt);
9969
10006
  return d ? d.getTime() : -Infinity;
9970
- };
10007
+ }, []);
9971
10008
  useEffect(function() {
9972
10009
  if ((selectedAnalysisId === "latest" || !selectedAnalysisId) && analyses.length > 0 && !isLoading) {
9973
10010
  var mostRecentAnalysis = analyses.reduce(function(latest, analysis) {
@@ -9975,7 +10012,7 @@ var AnalysisDateSelect = function AnalysisDateSelect2(_ref) {
9975
10012
  });
9976
10013
  onAnalysisSelect(mostRecentAnalysis.id);
9977
10014
  }
9978
- }, [analyses, selectedAnalysisId, onAnalysisSelect, isLoading]);
10015
+ }, [analyses, selectedAnalysisId, onAnalysisSelect, isLoading, getAnalysisTimestamp]);
9979
10016
  var effectiveSelectedId = useMemo(function() {
9980
10017
  if (selectedAnalysisId === "latest" || !selectedAnalysisId) {
9981
10018
  if (analyses.length > 0) {
@@ -9999,7 +10036,7 @@ var AnalysisDateSelect = function AnalysisDateSelect2(_ref) {
9999
10036
  }).id) : "";
10000
10037
  var selectedLabel = function() {
10001
10038
  if (selectedAnalysis) {
10002
- var localDate = getLocalDateFromCreatedAt(selectedAnalysis.createdAt);
10039
+ var localDate = getLocalDateFromUTCTimestamp(selectedAnalysis.createdAt);
10003
10040
  var dateLabel = localDate ? format(localDate, "MMMM d, yyyy") : (
10004
10041
  // Fallback if parsing fails
10005
10042
  selectedAnalysis.createdAt ? selectedAnalysis.createdAt.slice(0, 10) : "Unknown date"
@@ -10075,69 +10112,6 @@ var AnalysisDateSelect = function AnalysisDateSelect2(_ref) {
10075
10112
  /* @__PURE__ */ jsx(AnalysisCalendarPicker, { analyses, selectedAnalysisId: localSelectedId, onAnalysisSelect: handleAnalysisSelect, isLoading, isOpen: isCalendarOpen, onClose: handleCalendarClose })
10076
10113
  ] });
10077
10114
  };
10078
- function getMillisecondsUntilNextAnalysis(nextScheduledAnalysis) {
10079
- if (nextScheduledAnalysis === void 0 || nextScheduledAnalysis === null) {
10080
- return void 0;
10081
- }
10082
- if (typeof nextScheduledAnalysis === "number") {
10083
- var EPOCH_MS_THRESHOLD = 1e12;
10084
- if (nextScheduledAnalysis > EPOCH_MS_THRESHOLD) {
10085
- return nextScheduledAnalysis - Date.now();
10086
- } else {
10087
- return nextScheduledAnalysis;
10088
- }
10089
- }
10090
- var parsed = Date.parse(nextScheduledAnalysis);
10091
- if (!Number.isNaN(parsed)) {
10092
- return parsed - Date.now();
10093
- }
10094
- return void 0;
10095
- }
10096
- function isAnalysisScheduledMoreThanMinutesAway(nextScheduledAnalysis, minutes) {
10097
- var msUntilNext = getMillisecondsUntilNextAnalysis(nextScheduledAnalysis);
10098
- return msUntilNext !== void 0 && msUntilNext > minutes * 60 * 1e3;
10099
- }
10100
- var ANALYSIS_SCHEDULE_WARNING_MINUTES = 2;
10101
- function isAnalysisScheduledWithinMinutes(nextScheduledAnalysis) {
10102
- var minutes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ANALYSIS_SCHEDULE_WARNING_MINUTES;
10103
- var msUntilNext = getMillisecondsUntilNextAnalysis(nextScheduledAnalysis);
10104
- return msUntilNext !== void 0 && msUntilNext <= minutes * 60 * 1e3;
10105
- }
10106
- function formatScheduledAnalysisDate(nextScheduledAnalysis) {
10107
- if (nextScheduledAnalysis === void 0 || nextScheduledAnalysis === null) {
10108
- return "a future date";
10109
- }
10110
- var timestamp;
10111
- if (typeof nextScheduledAnalysis === "number") {
10112
- var EPOCH_MS_THRESHOLD = 1e12;
10113
- if (nextScheduledAnalysis > EPOCH_MS_THRESHOLD) {
10114
- timestamp = nextScheduledAnalysis;
10115
- } else {
10116
- timestamp = Date.now() + nextScheduledAnalysis;
10117
- }
10118
- } else {
10119
- var parsed = Date.parse(nextScheduledAnalysis);
10120
- if (!Number.isNaN(parsed)) {
10121
- timestamp = parsed;
10122
- }
10123
- }
10124
- if (timestamp === void 0) {
10125
- return "a future date";
10126
- }
10127
- var date = new Date(timestamp);
10128
- var dateOptions = {
10129
- month: "long",
10130
- day: "numeric"
10131
- };
10132
- var timeOptions = {
10133
- hour: "numeric",
10134
- minute: "2-digit",
10135
- hour12: true
10136
- };
10137
- var datePart = date.toLocaleDateString("en-US", dateOptions);
10138
- var timePart = date.toLocaleTimeString("en-US", timeOptions);
10139
- return "".concat(datePart, " at ").concat(timePart);
10140
- }
10141
10115
  function _typeof$7(o) {
10142
10116
  "@babel/helpers - typeof";
10143
10117
  return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
@@ -10274,15 +10248,12 @@ function _regeneratorDefine2$6(e, r, n, t) {
10274
10248
  i = 0;
10275
10249
  }
10276
10250
  _regeneratorDefine2$6 = function _regeneratorDefine(e2, r2, n2, t2) {
10277
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
10278
- else {
10279
- var o = function o2(r3, n3) {
10280
- _regeneratorDefine2$6(e2, r3, function(e3) {
10281
- return this._invoke(r3, n3, e3);
10282
- });
10283
- };
10284
- o("next", 0), o("throw", 1), o("return", 2);
10251
+ function o(r3, n3) {
10252
+ _regeneratorDefine2$6(e2, r3, function(e3) {
10253
+ return this._invoke(r3, n3, e3);
10254
+ });
10285
10255
  }
10256
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
10286
10257
  }, _regeneratorDefine2$6(e, r, n, t);
10287
10258
  }
10288
10259
  function asyncGeneratorStep$6(n, t, e, r, o, a, c) {
@@ -11721,15 +11692,12 @@ function _regeneratorDefine2$5(e, r, n, t) {
11721
11692
  i = 0;
11722
11693
  }
11723
11694
  _regeneratorDefine2$5 = function _regeneratorDefine(e2, r2, n2, t2) {
11724
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
11725
- else {
11726
- var o = function o2(r3, n3) {
11727
- _regeneratorDefine2$5(e2, r3, function(e3) {
11728
- return this._invoke(r3, n3, e3);
11729
- });
11730
- };
11731
- o("next", 0), o("throw", 1), o("return", 2);
11695
+ function o(r3, n3) {
11696
+ _regeneratorDefine2$5(e2, r3, function(e3) {
11697
+ return this._invoke(r3, n3, e3);
11698
+ });
11732
11699
  }
11700
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
11733
11701
  }, _regeneratorDefine2$5(e, r, n, t);
11734
11702
  }
11735
11703
  function asyncGeneratorStep$5(n, t, e, r, o, a, c) {
@@ -12064,15 +12032,12 @@ function _regeneratorDefine2$4(e, r, n, t) {
12064
12032
  i = 0;
12065
12033
  }
12066
12034
  _regeneratorDefine2$4 = function _regeneratorDefine(e2, r2, n2, t2) {
12067
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
12068
- else {
12069
- var o = function o2(r3, n3) {
12070
- _regeneratorDefine2$4(e2, r3, function(e3) {
12071
- return this._invoke(r3, n3, e3);
12072
- });
12073
- };
12074
- o("next", 0), o("throw", 1), o("return", 2);
12035
+ function o(r3, n3) {
12036
+ _regeneratorDefine2$4(e2, r3, function(e3) {
12037
+ return this._invoke(r3, n3, e3);
12038
+ });
12075
12039
  }
12040
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
12076
12041
  }, _regeneratorDefine2$4(e, r, n, t);
12077
12042
  }
12078
12043
  function asyncGeneratorStep$4(n, t, e, r, o, a, c) {
@@ -12636,6 +12601,47 @@ const BrandList$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
12636
12601
  __proto__: null,
12637
12602
  default: BrandList
12638
12603
  }, Symbol.toStringTag, { value: "Module" }));
12604
+ var useRouterBasename = function useRouterBasename2() {
12605
+ var location = useLocation();
12606
+ var basename = useMemo(function() {
12607
+ var fullPathname = window.location.pathname;
12608
+ var routerPathname = location.pathname;
12609
+ if (fullPathname === routerPathname) {
12610
+ return "";
12611
+ }
12612
+ if (!fullPathname.endsWith(routerPathname)) {
12613
+ return "";
12614
+ }
12615
+ var extractedBasename = fullPathname.slice(0, fullPathname.length - routerPathname.length);
12616
+ return extractedBasename.endsWith("/") ? extractedBasename.slice(0, -1) : extractedBasename;
12617
+ }, [location.pathname]);
12618
+ var stripBasename2 = useCallback(function(absolutePath) {
12619
+ if (basename && absolutePath.startsWith(basename)) {
12620
+ var stripped = absolutePath.slice(basename.length);
12621
+ return stripped === "" ? "/" : stripped;
12622
+ }
12623
+ return absolutePath;
12624
+ }, [basename]);
12625
+ var addBasename = useCallback(function(relativePath) {
12626
+ if (!basename) {
12627
+ return relativePath;
12628
+ }
12629
+ var normalizedPath = relativePath.startsWith("/") ? relativePath : "/".concat(relativePath);
12630
+ return "".concat(basename).concat(normalizedPath);
12631
+ }, [basename]);
12632
+ var isWithinBasename = useCallback(function(path) {
12633
+ if (!basename) {
12634
+ return path.startsWith("/") && !path.startsWith("//");
12635
+ }
12636
+ return path.startsWith(basename);
12637
+ }, [basename]);
12638
+ return {
12639
+ basename,
12640
+ stripBasename: stripBasename2,
12641
+ addBasename,
12642
+ isWithinBasename
12643
+ };
12644
+ };
12639
12645
  function _slicedToArray$7(r, e) {
12640
12646
  return _arrayWithHoles$7(r) || _iterableToArrayLimit$7(r, e) || _unsupportedIterableToArray$7(r, e) || _nonIterableRest$7();
12641
12647
  }
@@ -12679,6 +12685,7 @@ function _arrayWithHoles$7(r) {
12679
12685
  var useNavigationBlocker = function useNavigationBlocker2() {
12680
12686
  var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$shouldBlock = _ref.shouldBlock, shouldBlock = _ref$shouldBlock === void 0 ? true : _ref$shouldBlock, onConfirmLeave = _ref.onConfirmLeave, onCancelLeave = _ref.onCancelLeave;
12681
12687
  var navigate = useNavigate();
12688
+ var _useRouterBasename = useRouterBasename(), stripBasename2 = _useRouterBasename.stripBasename;
12682
12689
  var _useState = useState(false), _useState2 = _slicedToArray$7(_useState, 2), showModal = _useState2[0], setShowModal = _useState2[1];
12683
12690
  var _useState3 = useState(null), _useState4 = _slicedToArray$7(_useState3, 2), pendingNavigation = _useState4[0], setPendingNavigation = _useState4[1];
12684
12691
  useEffect(function() {
@@ -12693,7 +12700,8 @@ var useNavigationBlocker = function useNavigationBlocker2() {
12693
12700
  if (href !== currentPath) {
12694
12701
  e.preventDefault();
12695
12702
  e.stopPropagation();
12696
- setPendingNavigation(href);
12703
+ var routerRelativePath = stripBasename2(href);
12704
+ setPendingNavigation(routerRelativePath);
12697
12705
  setShowModal(true);
12698
12706
  }
12699
12707
  }
@@ -12702,7 +12710,7 @@ var useNavigationBlocker = function useNavigationBlocker2() {
12702
12710
  return function() {
12703
12711
  return document.removeEventListener("click", handleClick, true);
12704
12712
  };
12705
- }, [shouldBlock]);
12713
+ }, [shouldBlock, stripBasename2]);
12706
12714
  useEffect(function() {
12707
12715
  if (!shouldBlock) return;
12708
12716
  window.history.pushState(null, "", window.location.href);
@@ -12727,20 +12735,23 @@ var useNavigationBlocker = function useNavigationBlocker2() {
12727
12735
  return window.removeEventListener("beforeunload", handleBeforeUnload);
12728
12736
  };
12729
12737
  }, [shouldBlock]);
12738
+ var performNavigation = useCallback(function(destination) {
12739
+ if (typeof destination === "number") {
12740
+ navigate(destination);
12741
+ } else {
12742
+ navigate(stripBasename2(destination));
12743
+ }
12744
+ }, [navigate, stripBasename2]);
12730
12745
  var confirmLeave = useCallback(function() {
12731
12746
  if (pendingNavigation !== null) {
12732
12747
  setShowModal(false);
12733
12748
  onConfirmLeave === null || onConfirmLeave === void 0 || onConfirmLeave();
12734
12749
  setTimeout(function() {
12735
- if (typeof pendingNavigation === "number") {
12736
- navigate(pendingNavigation);
12737
- } else {
12738
- navigate(pendingNavigation);
12739
- }
12750
+ performNavigation(pendingNavigation);
12740
12751
  setPendingNavigation(null);
12741
12752
  }, 0);
12742
12753
  }
12743
- }, [pendingNavigation, navigate, onConfirmLeave]);
12754
+ }, [pendingNavigation, performNavigation, onConfirmLeave]);
12744
12755
  var cancelLeave = useCallback(function() {
12745
12756
  setShowModal(false);
12746
12757
  setPendingNavigation(null);
@@ -12748,16 +12759,13 @@ var useNavigationBlocker = function useNavigationBlocker2() {
12748
12759
  }, [onCancelLeave]);
12749
12760
  var navigateAway = useCallback(function(destination) {
12750
12761
  if (shouldBlock) {
12751
- setPendingNavigation(destination);
12762
+ var routerDestination = typeof destination === "string" ? stripBasename2(destination) : destination;
12763
+ setPendingNavigation(routerDestination);
12752
12764
  setShowModal(true);
12753
12765
  } else {
12754
- if (typeof destination === "number") {
12755
- navigate(destination);
12756
- } else {
12757
- navigate(destination);
12758
- }
12766
+ performNavigation(destination);
12759
12767
  }
12760
- }, [shouldBlock, navigate]);
12768
+ }, [shouldBlock, performNavigation, stripBasename2]);
12761
12769
  return {
12762
12770
  showModal,
12763
12771
  pendingNavigation,
@@ -12916,15 +12924,12 @@ function _regeneratorDefine2$3(e, r, n, t) {
12916
12924
  i = 0;
12917
12925
  }
12918
12926
  _regeneratorDefine2$3 = function _regeneratorDefine(e2, r2, n2, t2) {
12919
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
12920
- else {
12921
- var o = function o2(r3, n3) {
12922
- _regeneratorDefine2$3(e2, r3, function(e3) {
12923
- return this._invoke(r3, n3, e3);
12924
- });
12925
- };
12926
- o("next", 0), o("throw", 1), o("return", 2);
12927
+ function o(r3, n3) {
12928
+ _regeneratorDefine2$3(e2, r3, function(e3) {
12929
+ return this._invoke(r3, n3, e3);
12930
+ });
12927
12931
  }
12932
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
12928
12933
  }, _regeneratorDefine2$3(e, r, n, t);
12929
12934
  }
12930
12935
  function asyncGeneratorStep$3(n, t, e, r, o, a, c) {
@@ -13131,15 +13136,12 @@ function _regeneratorDefine2$2(e, r, n, t) {
13131
13136
  i = 0;
13132
13137
  }
13133
13138
  _regeneratorDefine2$2 = function _regeneratorDefine(e2, r2, n2, t2) {
13134
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
13135
- else {
13136
- var o = function o2(r3, n3) {
13137
- _regeneratorDefine2$2(e2, r3, function(e3) {
13138
- return this._invoke(r3, n3, e3);
13139
- });
13140
- };
13141
- o("next", 0), o("throw", 1), o("return", 2);
13139
+ function o(r3, n3) {
13140
+ _regeneratorDefine2$2(e2, r3, function(e3) {
13141
+ return this._invoke(r3, n3, e3);
13142
+ });
13142
13143
  }
13144
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
13143
13145
  }, _regeneratorDefine2$2(e, r, n, t);
13144
13146
  }
13145
13147
  function ownKeys$2(e, r) {
@@ -14754,15 +14756,12 @@ function _regeneratorDefine2$1(e, r, n, t) {
14754
14756
  i = 0;
14755
14757
  }
14756
14758
  _regeneratorDefine2$1 = function _regeneratorDefine(e2, r2, n2, t2) {
14757
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
14758
- else {
14759
- var o = function o2(r3, n3) {
14760
- _regeneratorDefine2$1(e2, r3, function(e3) {
14761
- return this._invoke(r3, n3, e3);
14762
- });
14763
- };
14764
- o("next", 0), o("throw", 1), o("return", 2);
14759
+ function o(r3, n3) {
14760
+ _regeneratorDefine2$1(e2, r3, function(e3) {
14761
+ return this._invoke(r3, n3, e3);
14762
+ });
14765
14763
  }
14764
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
14766
14765
  }, _regeneratorDefine2$1(e, r, n, t);
14767
14766
  }
14768
14767
  function asyncGeneratorStep$1(n, t, e, r, o, a, c) {
@@ -15197,15 +15196,12 @@ function _regeneratorDefine2(e, r, n, t) {
15197
15196
  i = 0;
15198
15197
  }
15199
15198
  _regeneratorDefine2 = function _regeneratorDefine(e2, r2, n2, t2) {
15200
- if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
15201
- else {
15202
- var o = function o2(r3, n3) {
15203
- _regeneratorDefine2(e2, r3, function(e3) {
15204
- return this._invoke(r3, n3, e3);
15205
- });
15206
- };
15207
- o("next", 0), o("throw", 1), o("return", 2);
15199
+ function o(r3, n3) {
15200
+ _regeneratorDefine2(e2, r3, function(e3) {
15201
+ return this._invoke(r3, n3, e3);
15202
+ });
15208
15203
  }
15204
+ r2 ? i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2 : (o("next", 0), o("throw", 1), o("return", 2));
15209
15205
  }, _regeneratorDefine2(e, r, n, t);
15210
15206
  }
15211
15207
  function asyncGeneratorStep(n, t, e, r, o, a, c) {