@bitcobblers/wod-wiki-ui 0.62.2261 → 0.62.2263

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.
@@ -850,6 +850,15 @@ function formatMMSS(ms) {
850
850
  const s = totalSec % 60;
851
851
  return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
852
852
  }
853
+ function formatOffsetMMSS(deltaMs) {
854
+ if (!Number.isFinite(deltaMs)) return "+00:00";
855
+ if (deltaMs < 0) {
856
+ const absSec = Math.floor(-deltaMs / 1e3);
857
+ if (absSec === 0) return "+00:00";
858
+ return `-${formatMMSS(-deltaMs)}`;
859
+ }
860
+ return `+${formatMMSS(deltaMs)}`;
861
+ }
853
862
  function formatClockTime(d) {
854
863
  return d.toLocaleTimeString("en-US", {
855
864
  hour12: false,
@@ -944,10 +953,146 @@ function formatOutputTypeLabel(outputType) {
944
953
  if (!raw) return "System";
945
954
  return OUTPUT_TYPE_LABEL[raw] ?? raw.charAt(0).toUpperCase() + raw.slice(1);
946
955
  }
947
- function formatOutputRowTitle(outputType, elapsedStr) {
948
- const label = formatOutputTypeLabel(outputType);
956
+ var ACRONYMS = {
957
+ c2b: "C2B",
958
+ t2b: "T2B",
959
+ ghd: "GHD",
960
+ hspu: "HSPU",
961
+ amrap: "AMRAP",
962
+ emom: "EMOM",
963
+ rft: "RFT"
964
+ };
965
+ function humanizeSlug(slug) {
966
+ return slug.trim().split(/[-_\s]+/).filter(Boolean).map((word) => {
967
+ const lower = word.toLowerCase();
968
+ return ACRONYMS[lower] ?? word.charAt(0).toUpperCase() + word.slice(1);
969
+ }).join(" ");
970
+ }
971
+ var GENERIC_LABELS = /* @__PURE__ */ new Set(["segment", "statement", "completed", "system"]);
972
+ function resolveOutputRowLabel(out) {
973
+ const explicitLabel = out.label?.trim();
974
+ if (explicitLabel && !GENERIC_LABELS.has(explicitLabel.toLowerCase())) {
975
+ return explicitLabel;
976
+ }
977
+ const all = out.metrics ? Array.from(out.metrics) : [];
978
+ for (const m of all) {
979
+ const t = String(m.type ?? "").toLowerCase();
980
+ if (t === "effort" || t === "action" || t === "label" || t === "text") {
981
+ const rawText = typeof m.image === "string" && m.image.trim() || typeof m.value === "string" && m.value.trim() || "";
982
+ if (!rawText) continue;
983
+ const lower = rawText.toLowerCase();
984
+ if (lower === "ready to start") return "Start";
985
+ if (lower === "session" || lower === "session completed") return "Session";
986
+ if (!GENERIC_LABELS.has(lower)) return rawText;
987
+ }
988
+ }
989
+ if (out.effortSlug && out.effortSlug.trim()) {
990
+ return humanizeSlug(out.effortSlug);
991
+ }
992
+ const rawStatement = (out.statement ?? out.text ?? "").trim();
993
+ if (rawStatement) {
994
+ const firstLine = rawStatement.split("\n")[0]?.trim() ?? "";
995
+ if (firstLine && !GENERIC_LABELS.has(firstLine.toLowerCase())) {
996
+ return firstLine;
997
+ }
998
+ }
999
+ for (const m of all) {
1000
+ const t = String(m.type ?? "").toLowerCase();
1001
+ if (t === "current-round" || t === "rounds") {
1002
+ const img = typeof m.image === "string" ? m.image.trim() : "";
1003
+ if (/^completed\b/i.test(img)) return img;
1004
+ const n = typeof m.value === "number" ? m.value : Number(m.value);
1005
+ if (Number.isFinite(n) && n > 0) {
1006
+ return t === "current-round" ? `Round ${n}` : `${n} ${n === 1 ? "Round" : "Rounds"}`;
1007
+ }
1008
+ }
1009
+ }
1010
+ const blockKey = String(out.sourceBlockKey ?? "").trim().toLowerCase();
1011
+ if (blockKey.startsWith("waiting-to-start")) return "Start";
1012
+ if (blockKey.startsWith("session-root") || blockKey === "root") return "Session";
1013
+ if (blockKey.startsWith("rest")) return "Rest";
1014
+ const roundMatch = /^round[-_:\s]*(\d+)/i.exec(blockKey);
1015
+ if (roundMatch) return `Round ${roundMatch[1]}`;
1016
+ if (blockKey.startsWith("rounds")) return "Rounds";
1017
+ if (String(out.outputType ?? "").toLowerCase() === "analytics" && all.length > 0) {
1018
+ const first = all[0];
1019
+ const meta = first.metadata;
1020
+ const summaryName = typeof meta?.originalKey === "string" && meta.originalKey || typeof meta?.canonicalKey === "string" && meta.canonicalKey || String(first.type ?? "");
1021
+ if (summaryName) return summaryName;
1022
+ }
1023
+ return formatOutputTypeLabel(out.outputType);
1024
+ }
1025
+ function resolveOutputTypeBadgeLabel(out) {
1026
+ const rawType = String(out.outputType ?? "system").trim().toLowerCase();
1027
+ if (rawType !== "segment") return formatOutputTypeLabel(out.outputType);
1028
+ const blockKey = String(out.sourceBlockKey ?? "").trim().toLowerCase();
1029
+ if (blockKey.startsWith("waiting-to-start")) return "Start";
1030
+ if (blockKey.startsWith("session-root") || blockKey === "root") return "Session";
1031
+ if (blockKey.startsWith("rest")) return "Rest";
1032
+ const all = out.metrics ? Array.from(out.metrics) : [];
1033
+ const hasEffort = Boolean(out.effortSlug) || all.some((m) => String(m.type ?? "").toLowerCase() === "effort");
1034
+ if (!hasEffort) {
1035
+ const hasRoundMetric = all.some((m) => {
1036
+ const t = String(m.type ?? "").toLowerCase();
1037
+ return t === "rounds" || t === "current-round";
1038
+ });
1039
+ if (hasRoundMetric || blockKey.startsWith("round")) return "Rounds";
1040
+ }
1041
+ return "Segment";
1042
+ }
1043
+ function formatOutputRowTitle(out, elapsedStr) {
1044
+ const label = resolveOutputRowLabel(out);
949
1045
  return elapsedStr ? `${label} (${elapsedStr})` : label;
950
1046
  }
1047
+ function resolveTimeOrigin(outputs, timeOrigin) {
1048
+ let minStarted;
1049
+ let maxStarted;
1050
+ for (const o of outputs) {
1051
+ const s = o.timeSpan?.started;
1052
+ if (typeof s !== "number" || !Number.isFinite(s)) continue;
1053
+ minStarted = minStarted === void 0 ? s : Math.min(minStarted, s);
1054
+ maxStarted = maxStarted === void 0 ? s : Math.max(maxStarted, s);
1055
+ }
1056
+ if (typeof timeOrigin === "number" && Number.isFinite(timeOrigin)) {
1057
+ if (minStarted !== void 0 && timeOrigin > minStarted && (maxStarted === void 0 || timeOrigin >= maxStarted)) {
1058
+ return minStarted;
1059
+ }
1060
+ return timeOrigin;
1061
+ }
1062
+ return minStarted;
1063
+ }
1064
+ function metricDurationToMs(m) {
1065
+ const rawVal = typeof m.value === "number" ? m.value : Number(m.value);
1066
+ if (!Number.isFinite(rawVal) || rawVal <= 0) return void 0;
1067
+ const unit = "unit" in m && typeof m.unit === "string" ? m.unit.trim().toLowerCase() : "";
1068
+ if (unit === "s" || unit === "sec" || unit === "secs" || unit === "second" || unit === "seconds") {
1069
+ return rawVal * 1e3;
1070
+ }
1071
+ if (unit === "min" || unit === "mins" || unit === "minute" || unit === "minutes") {
1072
+ return rawVal * 6e4;
1073
+ }
1074
+ return rawVal;
1075
+ }
1076
+ function resolveRowDurationMs(out) {
1077
+ const started = out.timeSpan?.started;
1078
+ const ended = out.timeSpan?.ended;
1079
+ if (started !== void 0 && ended !== void 0 && ended > started) {
1080
+ return ended - started;
1081
+ }
1082
+ if (out.metrics) {
1083
+ for (const m of out.metrics) {
1084
+ const t = String(m.type ?? "").toLowerCase();
1085
+ if (t === "elapsed" || t === "duration") {
1086
+ const ms = metricDurationToMs(m);
1087
+ if (ms !== void 0 && ms > 0) return ms;
1088
+ }
1089
+ }
1090
+ }
1091
+ if (started !== void 0 && ended !== void 0) {
1092
+ return Math.max(0, ended - started);
1093
+ }
1094
+ return void 0;
1095
+ }
951
1096
  var EFFORT_TYPES = /* @__PURE__ */ new Set(["effort", "text", "action", "label"]);
952
1097
  var LOAD_TYPES = /* @__PURE__ */ new Set([
953
1098
  "resistance",
@@ -1153,13 +1298,11 @@ function extractMetricsForColumn(out, col, dynamicLowerTypes) {
1153
1298
  case "effort": {
1154
1299
  const explicitEfforts = all.filter((m) => EFFORT_TYPES.has(String(m.type).toLowerCase()));
1155
1300
  if (explicitEfforts.length > 0) return explicitEfforts;
1156
- if (String(out.outputType ?? "").toLowerCase() === "analytics" && all.length > 0) {
1157
- const first = all[0];
1158
- const meta = first.metadata;
1159
- const summaryName = typeof meta?.originalKey === "string" && meta.originalKey || typeof meta?.canonicalKey === "string" && meta.canonicalKey || String(first.type ?? "");
1160
- if (summaryName) {
1161
- return [{ type: "label", value: summaryName, image: summaryName, origin: first.origin }];
1162
- }
1301
+ const resolved = resolveOutputRowLabel(out);
1302
+ const genericType = formatOutputTypeLabel(out.outputType);
1303
+ if (resolved && resolved !== genericType) {
1304
+ const origin = all[0]?.origin ?? "runtime";
1305
+ return [{ type: "label", value: resolved, image: resolved, origin }];
1163
1306
  }
1164
1307
  return [];
1165
1308
  }
@@ -1279,13 +1422,20 @@ function StatementCards({
1279
1422
  }
1280
1423
  return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex flex-col", "data-testid": "output-statements-cards", children: rows.map((out, idx) => {
1281
1424
  const cats = extractMetricsByCategory(out.metrics);
1425
+ if (cats.efforts.length === 0) {
1426
+ const resolved = resolveOutputRowLabel(out);
1427
+ const genericType = formatOutputTypeLabel(out.outputType);
1428
+ if (resolved && resolved !== genericType) {
1429
+ cats.efforts.push({ type: "label", value: resolved, image: resolved, origin: "runtime" });
1430
+ }
1431
+ }
1282
1432
  const started = out.timeSpan?.started;
1283
- const ended = out.timeSpan?.ended;
1284
- const elapsedStr = ended !== void 0 && started !== void 0 ? formatMMSS(ended - started) : "running";
1285
- const offsetStr = started !== void 0 && t0 !== void 0 ? `+${formatMMSS(started - t0)}` : "+00:00";
1433
+ const durationMs = resolveRowDurationMs(out);
1434
+ const elapsedStr = durationMs !== void 0 ? formatMMSS(durationMs) : "running";
1435
+ const offsetStr = started !== void 0 && t0 !== void 0 ? formatOffsetMMSS(started - t0) : "+00:00";
1286
1436
  const typeKey = String(out.outputType);
1287
- const typeLabel = formatOutputTypeLabel(out.outputType);
1288
- const rowTitle = formatOutputRowTitle(out.outputType, elapsedStr);
1437
+ const typeLabel = resolveOutputTypeBadgeLabel(out);
1438
+ const rowTitle = formatOutputRowTitle(out, elapsedStr);
1289
1439
  const pr = lookupPrHighlight(out, prHighlights);
1290
1440
  const bodyMetrics = [...cats.reps, ...cats.loads, ...cats.rounds, ...cats.durations, ...cats.distances];
1291
1441
  const hasBody = bodyMetrics.length > 0;
@@ -1406,7 +1556,7 @@ function OutputStatementsTable({
1406
1556
  onEditMetric,
1407
1557
  prHighlights
1408
1558
  }) {
1409
- const t0 = timeOrigin ?? (outputs.length > 0 ? outputs[0].timeSpan?.started : void 0);
1559
+ const t0 = React2.useMemo(() => resolveTimeOrigin(outputs, timeOrigin), [outputs, timeOrigin]);
1410
1560
  const [internalSort, setInternalSort] = React2.useState(
1411
1561
  controlledSort ? [...controlledSort] : []
1412
1562
  );
@@ -1573,11 +1723,12 @@ function OutputStatementsTable({
1573
1723
  /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-border/40", children: rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: activeColumns.length, className: "p-8 text-center text-muted-foreground font-sans text-xs", children: outputs.length === 0 ? "No output statements recorded for this run." : "No output statements match the current filter." }) }) : rows.map((out, idx) => {
1574
1724
  const started = out.timeSpan?.started;
1575
1725
  const ended = out.timeSpan?.ended;
1576
- const elapsedStr = ended !== void 0 && started !== void 0 ? formatMMSS(ended - started) : "running";
1577
- const wallTimeStr = formatClockTime(new Date(ended ?? started ?? 0));
1578
- const offsetStr = started !== void 0 && t0 !== void 0 ? `+${formatMMSS(started - t0)}` : "+00:00";
1579
- const typeLabel = formatOutputTypeLabel(out.outputType);
1580
- const rowTitle = formatOutputRowTitle(out.outputType, elapsedStr);
1726
+ const durationMs = resolveRowDurationMs(out);
1727
+ const elapsedStr = durationMs !== void 0 ? formatMMSS(durationMs) : "running";
1728
+ const wallTimeStr = ended !== void 0 || started !== void 0 ? formatClockTime(new Date(ended ?? started ?? 0)) : "\u2014";
1729
+ const offsetStr = started !== void 0 && t0 !== void 0 ? formatOffsetMMSS(started - t0) : "+00:00";
1730
+ const typeLabel = resolveOutputTypeBadgeLabel(out);
1731
+ const rowTitle = formatOutputRowTitle(out, elapsedStr);
1581
1732
  const rowKey = String(out.id ?? `${out.sourceBlockKey ?? "row"}-${idx}`);
1582
1733
  const pr = lookupPrHighlight(out, prHighlights);
1583
1734
  const canInlineEditRow = Boolean(onEditMetric) && String(out.outputType ?? "").toLowerCase() === "segment" && Boolean(out.sourceBlockKey);
@@ -3588,7 +3739,18 @@ function formatPaceMMSS(secPerKm) {
3588
3739
  const secs = rounded % 60;
3589
3740
  return `${mins}:${String(secs).padStart(2, "0")} /km`;
3590
3741
  }
3591
- function humanizeSlug(slug) {
3742
+ function normalizePaceToSecPerKm(value, unit) {
3743
+ if (!Number.isFinite(value) || value <= 0) return null;
3744
+ const u = (unit ?? "").trim().toLowerCase();
3745
+ if (!u || u === "sec/km" || u === "s/km") return value;
3746
+ if (u === "min/km") return value * 60;
3747
+ if (u === "min/mi") return value * 60 / 1.609344;
3748
+ if (u === "sec/mi" || u === "s/mi") return value / 1.609344;
3749
+ if (u === "m/s") return 1e3 / value;
3750
+ if (u === "km/h" || u === "kph") return 3600 / value;
3751
+ return null;
3752
+ }
3753
+ function humanizeSlug2(slug) {
3592
3754
  return slug.split(/[-_\s]+/).filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
3593
3755
  }
3594
3756
  function normalizePrLookup(prHighlights) {
@@ -3640,25 +3802,7 @@ function extractVisibleMetrics(row) {
3640
3802
  }
3641
3803
  function buildSpreadsheetRows(run, prHighlights) {
3642
3804
  const prMap = normalizePrLookup(prHighlights);
3643
- const rawSegments = (run.events ?? []).filter((e) => {
3644
- if (e.outputType !== "segment") return false;
3645
- const key = String(e.sourceBlockKey ?? "").toLowerCase();
3646
- return !key.startsWith("waiting-to-start") && key !== "session-root" && key !== "root";
3647
- });
3648
- const maxStackLevel = rawSegments.reduce((max, e) => Math.max(max, e.stackLevel ?? 0), 0);
3649
- const hasEffortLeaves = rawSegments.some((e) => {
3650
- const metrics = extractVisibleMetrics(e);
3651
- return Boolean(e.effortSlug) || metrics.some((m) => String(m.type ?? "").toLowerCase() === "effort");
3652
- });
3653
- const segmentEvents = hasEffortLeaves ? rawSegments.filter((e) => {
3654
- if ((e.stackLevel ?? 0) >= maxStackLevel) return true;
3655
- const metrics = extractVisibleMetrics(e);
3656
- const hasMovement = Boolean(e.effortSlug) || metrics.some((m) => {
3657
- const t = String(m.type ?? "").toLowerCase();
3658
- return t === "effort" || t === "rep" || t === "reps" || t === "distance";
3659
- });
3660
- return hasMovement;
3661
- }) : rawSegments;
3805
+ const segmentEvents = wodWikiWql.selectSplitSegmentEvents(run.events ?? []);
3662
3806
  const sessionStart = segmentEvents.reduce(
3663
3807
  (min, e) => e.timeSpan?.started !== void 0 ? Math.min(min, e.timeSpan.started) : min,
3664
3808
  run.timestamp
@@ -3697,7 +3841,7 @@ function buildSpreadsheetRows(run, prHighlights) {
3697
3841
  if (lower === "effort" || canon === "effort") {
3698
3842
  const slugVal = typeof m.metadata?.effortSlug === "string" ? String(m.metadata.effortSlug) : typeof m.value === "string" ? m.value : "";
3699
3843
  if (!effortSlug && slugVal) effortSlug = slugVal;
3700
- movement = String(m.image ?? (slugVal ? humanizeSlug(slugVal) : m.value ?? "")).trim();
3844
+ movement = String(m.image ?? (slugVal ? humanizeSlug2(slugVal) : m.value ?? "")).trim();
3701
3845
  continue;
3702
3846
  }
3703
3847
  if (typeof m.value !== "number" || !Number.isFinite(m.value)) continue;
@@ -3747,13 +3891,20 @@ function buildSpreadsheetRows(run, prHighlights) {
3747
3891
  power = m.value;
3748
3892
  if (m.unit) powerUnit = m.unit;
3749
3893
  } else if (canon === "pace") {
3750
- paceSecPerKm = m.value;
3894
+ const normalized = normalizePaceToSecPerKm(m.value, m.unit);
3895
+ if (normalized !== null) {
3896
+ const u = (m.unit ?? "").trim().toLowerCase();
3897
+ const isExplicitPace = !u || u === "min/km" || u === "sec/km" || u === "s/km" || u === "min/mi" || u === "sec/mi" || u === "s/mi";
3898
+ if (paceSecPerKm === null || isExplicitPace || isUser) {
3899
+ paceSecPerKm = normalized;
3900
+ }
3901
+ }
3751
3902
  } else if (canon === "rounds" || canon === "currentround" || lower === "current-round") {
3752
3903
  round = Math.round(m.value);
3753
3904
  } else if (!KNOWN_CANONICAL_KEYS.has(canon) && !KNOWN_CANONICAL_KEYS.has(lower)) {
3754
3905
  const key = canon || lower;
3755
3906
  custom[key] = {
3756
- label: humanizeSlug(mType),
3907
+ label: humanizeSlug2(mType),
3757
3908
  value: m.value,
3758
3909
  ...m.unit ? { unit: m.unit } : {},
3759
3910
  modified: isUser
@@ -3761,7 +3912,7 @@ function buildSpreadsheetRows(run, prHighlights) {
3761
3912
  }
3762
3913
  }
3763
3914
  if (!movement) {
3764
- movement = effortSlug ? humanizeSlug(effortSlug) : `Split ${index + 1}`;
3915
+ movement = effortSlug ? humanizeSlug2(effortSlug) : `Split ${index + 1}`;
3765
3916
  }
3766
3917
  if (splitSec === null && ev.timeSpan?.started !== void 0 && ev.timeSpan?.ended !== void 0) {
3767
3918
  splitSec = Math.max(0, (ev.timeSpan.ended - ev.timeSpan.started) / 1e3);
@@ -4904,27 +5055,42 @@ function ResultsSpreadsheetGrid({
4904
5055
  );
4905
5056
  }) })
4906
5057
  ] }) }),
4907
- activeTab === "raw" && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "results-tab-panel-raw", className: "space-y-2.5", children: [
4908
- /* @__PURE__ */ jsxRuntime.jsx(
4909
- OutputFilterPills,
4910
- {
4911
- presets: DEFAULT_OUTPUT_FILTERS.map(normalizeOutputFilter),
4912
- filter: rawFilter,
4913
- onChange: setRawFilter
5058
+ activeTab === "raw" && (() => {
5059
+ const events = run.events ?? [];
5060
+ let activeMinStart;
5061
+ let anyMinStart;
5062
+ for (const e of events) {
5063
+ const s = e.timeSpan?.started;
5064
+ if (typeof s !== "number" || !Number.isFinite(s)) continue;
5065
+ anyMinStart = anyMinStart === void 0 ? s : Math.min(anyMinStart, s);
5066
+ const key = String(e.sourceBlockKey ?? "").toLowerCase();
5067
+ if (e.outputType === "segment" && !key.startsWith("waiting-to-start")) {
5068
+ activeMinStart = activeMinStart === void 0 ? s : Math.min(activeMinStart, s);
4914
5069
  }
4915
- ),
4916
- /* @__PURE__ */ jsxRuntime.jsx(
4917
- OutputStatementsTable,
4918
- {
4919
- outputs: run.events,
4920
- filter: rawFilter,
4921
- timeOrigin: run.timestamp,
4922
- onClearFilter: () => setRawFilter(""),
4923
- onEditMetric: onEditMetric ? (p) => onEditMetric(run.resultId, p) : void 0,
4924
- prHighlights
4925
- }
4926
- )
4927
- ] }),
5070
+ }
5071
+ const rawTimeOrigin = activeMinStart ?? anyMinStart ?? run.timestamp;
5072
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "results-tab-panel-raw", className: "space-y-2.5", children: [
5073
+ /* @__PURE__ */ jsxRuntime.jsx(
5074
+ OutputFilterPills,
5075
+ {
5076
+ presets: DEFAULT_OUTPUT_FILTERS.map(normalizeOutputFilter),
5077
+ filter: rawFilter,
5078
+ onChange: setRawFilter
5079
+ }
5080
+ ),
5081
+ /* @__PURE__ */ jsxRuntime.jsx(
5082
+ OutputStatementsTable,
5083
+ {
5084
+ outputs: events,
5085
+ filter: rawFilter,
5086
+ timeOrigin: rawTimeOrigin,
5087
+ onClearFilter: () => setRawFilter(""),
5088
+ onEditMetric: onEditMetric ? (p) => onEditMetric(run.resultId, p) : void 0,
5089
+ prHighlights
5090
+ }
5091
+ )
5092
+ ] });
5093
+ })(),
4928
5094
  /* @__PURE__ */ jsxRuntime.jsx(
4929
5095
  EditorDialog,
4930
5096
  {
@@ -12661,6 +12827,26 @@ function createCloseIcon(size = "md") {
12661
12827
  function isAliasProperty(key) {
12662
12828
  return ["alias", "aliases"].includes(key.trim().toLowerCase());
12663
12829
  }
12830
+ function isSelfReferenceHref(docKind, meta, matchSlug, href, referenceProvider) {
12831
+ const normMatch = matchSlug.trim().toLowerCase();
12832
+ if (meta) {
12833
+ const metaSlug = typeof meta.slug === "string" ? meta.slug.trim().toLowerCase() : "";
12834
+ if (metaSlug && metaSlug === normMatch) return true;
12835
+ if (docKind === "effort" || docKind === "equipment") {
12836
+ const ownName = typeof meta.label === "string" && meta.label.trim() || typeof meta.title === "string" && meta.title.trim() || "";
12837
+ if (ownName) {
12838
+ const ownMatch = docKind === "effort" ? referenceProvider.resolveEffort(ownName) : referenceProvider.resolveEquipment(ownName);
12839
+ if (ownMatch && ownMatch.slug.trim().toLowerCase() === normMatch) return true;
12840
+ }
12841
+ }
12842
+ }
12843
+ if (typeof window !== "undefined" && window.location?.pathname) {
12844
+ const currentPath = window.location.pathname.replace(/\/+$/, "");
12845
+ const targetPath = href.split(/[?#]/)[0].replace(/\/+$/, "");
12846
+ if (currentPath && targetPath && currentPath === targetPath) return true;
12847
+ }
12848
+ return false;
12849
+ }
12664
12850
  function createSummaryPill(value, hash2, href) {
12665
12851
  const pill = document.createElement("span");
12666
12852
  pill.className = "inline-flex max-w-full items-center rounded-md border border-border/60 bg-muted/40 px-2 py-0.5 text-xs text-foreground";
@@ -12679,7 +12865,7 @@ function createSummaryPill(value, hash2, href) {
12679
12865
  pill.appendChild(label);
12680
12866
  return pill;
12681
12867
  }
12682
- function createFrontmatterSummary(entries, onShowDetails, docKind, referenceProvider) {
12868
+ function createFrontmatterSummary(entries, onShowDetails, docKind, referenceProvider, meta) {
12683
12869
  const summary = document.createElement("div");
12684
12870
  summary.dataset.frontmatterSummary = "true";
12685
12871
  summary.className = "divide-y divide-border/60";
@@ -12705,10 +12891,11 @@ function createFrontmatterSummary(entries, onShowDetails, docKind, referenceProv
12705
12891
  const lower = val.toLowerCase();
12706
12892
  if (seenTags.has(lower)) continue;
12707
12893
  seenTags.add(lower);
12894
+ const match = referenceProvider?.resolveTag?.(val, normKey) ?? null;
12708
12895
  tagItems.push({
12709
12896
  text: val,
12710
12897
  hash: true,
12711
- href: referenceProvider?.openHref("tag", val, normKey)
12898
+ href: match && referenceProvider ? referenceProvider.openHref("tag", match.slug, match.type ?? normKey) : void 0
12712
12899
  });
12713
12900
  }
12714
12901
  }
@@ -12758,7 +12945,12 @@ function createFrontmatterSummary(entries, onShowDetails, docKind, referenceProv
12758
12945
  let href;
12759
12946
  if (referenceProvider && (docKind === "effort" || docKind === "equipment")) {
12760
12947
  const match = docKind === "effort" ? referenceProvider.resolveEffort(val) : referenceProvider.resolveEquipment(val);
12761
- if (match) href = referenceProvider.openHref(docKind, match.slug);
12948
+ if (match) {
12949
+ const candidateHref = referenceProvider.openHref(docKind, match.slug);
12950
+ if (!isSelfReferenceHref(docKind, meta, match.slug, candidateHref, referenceProvider)) {
12951
+ href = candidateHref;
12952
+ }
12953
+ }
12762
12954
  }
12763
12955
  aliasItems.push({ text: val, hash: false, href });
12764
12956
  }
@@ -12886,7 +13078,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
12886
13078
  persistedDetailed.set(view.dom, true);
12887
13079
  view.dispatch({ effects: setFrontmatterDetailed.of(true) });
12888
13080
  view.dom.querySelector('[aria-label="Show property summary"]')?.focus();
12889
- }, docKind, referenceProvider));
13081
+ }, docKind, referenceProvider, meta));
12890
13082
  } else {
12891
13083
  box.appendChild(createColumnHeader());
12892
13084
  if (entries.length === 0) {
@@ -13043,9 +13235,11 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
13043
13235
  const pill = document.createElement("span");
13044
13236
  pill.className = match ? "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-muted/50 text-foreground border border-border/60" : chipIsReference ? "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-destructive/10 text-destructive border border-destructive/30" : "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-muted/40 text-foreground/90 border border-border/60";
13045
13237
  const pillText = document.createElement("span");
13046
- if (isAliasRow && match && referenceProvider) {
13238
+ const aliasHref = isAliasRow && match && referenceProvider ? referenceProvider.openHref(valueKind, match.slug) : void 0;
13239
+ const isSelfAlias = isAliasRow && match && referenceProvider && aliasHref ? isSelfReferenceHref(docKind, meta, match.slug, aliasHref, referenceProvider) : false;
13240
+ if (isAliasRow && match && referenceProvider && aliasHref && !isSelfAlias) {
13047
13241
  const aliasLink = document.createElement("a");
13048
- aliasLink.href = referenceProvider.openHref(valueKind, match.slug);
13242
+ aliasLink.href = aliasHref;
13049
13243
  aliasLink.textContent = chip;
13050
13244
  aliasLink.className = "hover:underline cursor-pointer";
13051
13245
  pillText.appendChild(aliasLink);
@@ -13053,7 +13247,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
13053
13247
  pillText.textContent = isAliasRow ? chip : match ? match.label : chip;
13054
13248
  }
13055
13249
  pill.appendChild(pillText);
13056
- if (match && referenceProvider && (!isAliasRow || idx === 0)) {
13250
+ if (match && referenceProvider && (!isAliasRow || idx === 0 && !isSelfAlias)) {
13057
13251
  const openLink = document.createElement("a");
13058
13252
  openLink.href = referenceProvider.openHref(valueKind, match.slug);
13059
13253
  openLink.title = `Open ${match.label} page`;