@estiva-app/ui 0.118.0 → 0.120.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2021,7 +2021,7 @@ function MoveDialog({
2021
2021
  description,
2022
2022
  from,
2023
2023
  folders,
2024
- places: places2,
2024
+ places: places3,
2025
2025
  placesIn,
2026
2026
  startAtTop = false,
2027
2027
  topLabel,
@@ -2039,9 +2039,9 @@ function MoveDialog({
2039
2039
  const offered = (id) => !!id && !!destinations?.some((candidate) => candidate.id === id);
2040
2040
  const [pickedFolder, setPickedFolder] = useState5();
2041
2041
  const folder = pickedFolder ?? [startIn, from].find(offered) ?? "";
2042
- const [read, setRead] = useState5(() => places2 ? { [from]: places2 } : {});
2042
+ const [read, setRead] = useState5(() => places3 ? { [from]: places3 } : {});
2043
2043
  const [picked, setPicked] = useState5();
2044
- const requested = useRef7(new Set(places2 ? [from] : []));
2044
+ const requested = useRef7(new Set(places3 ? [from] : []));
2045
2045
  const readPlaces = (id) => {
2046
2046
  if (!placesIn || requested.current.has(id)) return;
2047
2047
  requested.current.add(id);
@@ -4464,10 +4464,116 @@ function NavItem({
4464
4464
  }
4465
4465
 
4466
4466
  // src/NavTree.tsx
4467
- import { createContext as createContext8, useContext as useContext8, useEffect as useEffect10, useRef as useRef16, useState as useState18 } from "react";
4467
+ import { createContext as createContext9, useContext as useContext9, useEffect as useEffect11, useRef as useRef17, useState as useState18 } from "react";
4468
+
4469
+ // src/revealCurrentRow.ts
4470
+ import { createContext as createContext8, useContext as useContext8, useEffect as useEffect10, useLayoutEffect as useLayoutEffect5, useMemo as useMemo4, useRef as useRef16 } from "react";
4471
+ var REVEAL_MS = 200;
4472
+ function scrollToRow(row) {
4473
+ let box = row.parentElement;
4474
+ while (box && !(/(auto|scroll)/.test(getComputedStyle(box).overflowY) && box.scrollHeight > box.clientHeight)) box = box.parentElement;
4475
+ if (!box || box === document.documentElement || box === document.body) return;
4476
+ scrollRowInto(box, row);
4477
+ }
4478
+ function scrollRowInto(box, row) {
4479
+ const at = row.getBoundingClientRect();
4480
+ const view = box.getBoundingClientRect();
4481
+ if (at.top < view.top) box.scrollTop -= view.top - at.top;
4482
+ else if (at.bottom > view.bottom) box.scrollTop += Math.min(at.bottom - view.bottom, at.top - view.top);
4483
+ }
4484
+ var keyOf = (row, current) => current ?? row.getAttribute("href") ?? row.textContent ?? "";
4485
+ var places = /* @__PURE__ */ new Map();
4486
+ var RESTORE_MS = 2e3;
4487
+ var ListPlaceContext = createContext8(null);
4488
+ function useListPlace(box, name) {
4489
+ const restoring = useRef16(false);
4490
+ useLayoutEffect5(() => {
4491
+ const el = box.current;
4492
+ if (!el || !name) return;
4493
+ const want = places.get(name)?.top ?? 0;
4494
+ restoring.current = want > 0;
4495
+ let set = el.scrollTop;
4496
+ const keep = () => places.set(name, { ...places.get(name), top: el.scrollTop });
4497
+ const finish = () => {
4498
+ restoring.current = false;
4499
+ };
4500
+ const restore = () => {
4501
+ if (!restoring.current) return;
4502
+ el.scrollTop = want;
4503
+ set = el.scrollTop;
4504
+ if (Math.abs(el.scrollTop - want) < 1) finish();
4505
+ };
4506
+ restore();
4507
+ const open = el.querySelector('[aria-current="page"]');
4508
+ const key = open && open.getBoundingClientRect().height > 0 ? keyOf(open) : void 0;
4509
+ if (open && key !== void 0 && key !== places.get(name)?.shown) {
4510
+ finish();
4511
+ places.set(name, { ...places.get(name), shown: key });
4512
+ scrollRowInto(el, open);
4513
+ set = el.scrollTop;
4514
+ }
4515
+ const grows = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(restore);
4516
+ if (el.firstElementChild) grows?.observe(el.firstElementChild);
4517
+ const until = setTimeout(finish, RESTORE_MS);
4518
+ const took = () => finish();
4519
+ const scrolled = () => {
4520
+ if (restoring.current && Math.abs(el.scrollTop - set) > 1) finish();
4521
+ if (!restoring.current) keep();
4522
+ };
4523
+ const takes = ["wheel", "touchstart", "pointerdown", "keydown"];
4524
+ el.addEventListener("scroll", scrolled, { passive: true });
4525
+ for (const type of takes) el.addEventListener(type, took, { passive: true });
4526
+ return () => {
4527
+ el.removeEventListener("scroll", scrolled);
4528
+ for (const type of takes) el.removeEventListener(type, took);
4529
+ grows?.disconnect();
4530
+ clearTimeout(until);
4531
+ if (!restoring.current) keep();
4532
+ restoring.current = false;
4533
+ };
4534
+ }, [box, name]);
4535
+ return useMemo4(() => ({ name, restoring }), [name]);
4536
+ }
4537
+ function useRevealCurrentRow(box, current, place) {
4538
+ const shown2 = useRef16(void 0);
4539
+ const within = useContext8(ListPlaceContext);
4540
+ const deferred = !place && within !== null;
4541
+ useEffect10(() => {
4542
+ const root = box.current;
4543
+ if (!root || deferred) return;
4544
+ const was = () => place?.name ? places.get(place.name)?.shown : shown2.current;
4545
+ const showing = (key) => {
4546
+ if (place?.name) places.set(place.name, { ...places.get(place.name), shown: key });
4547
+ else shown2.current = key;
4548
+ };
4549
+ let timer;
4550
+ const look = () => {
4551
+ timer = void 0;
4552
+ const row = root.querySelector('[aria-current="page"]');
4553
+ if (!row) return;
4554
+ const key = keyOf(row, current);
4555
+ if (was() === key) return;
4556
+ if (row.getBoundingClientRect().height === 0) return;
4557
+ if (place) place.restoring.current = false;
4558
+ showing(key);
4559
+ scrollToRow(row);
4560
+ };
4561
+ const soon = () => {
4562
+ if (timer === void 0) timer = setTimeout(look, REVEAL_MS);
4563
+ };
4564
+ const watch = typeof MutationObserver === "undefined" ? void 0 : new MutationObserver(soon);
4565
+ watch?.observe(root, { subtree: true, childList: true, attributes: true, attributeFilter: ["aria-current", "hidden"] });
4566
+ soon();
4567
+ return () => {
4568
+ watch?.disconnect();
4569
+ if (timer !== void 0) clearTimeout(timer);
4570
+ };
4571
+ }, [box, current, place, deferred]);
4572
+ }
4573
+
4574
+ // src/NavTree.tsx
4468
4575
  import { jsx as jsx59, jsxs as jsxs43 } from "react/jsx-runtime";
4469
4576
  var NAV_TREE_INTENT_MS = 150;
4470
- var NAV_TREE_REVEAL_MS = 200;
4471
4577
  var NAV_TREE_PENDING_MS = 2e3;
4472
4578
  function holds(nodes, id) {
4473
4579
  return !!nodes && id !== void 0 && nodes.some((node) => node.id === id || holds(node.children ?? null, id));
@@ -4492,19 +4598,10 @@ function openingFor(groups, selected, selectedParent) {
4492
4598
  }
4493
4599
  return null;
4494
4600
  }
4495
- function scrollToRow(row) {
4496
- let box = row.parentElement;
4497
- while (box && !(/(auto|scroll)/.test(getComputedStyle(box).overflowY) && box.scrollHeight > box.clientHeight)) box = box.parentElement;
4498
- if (!box || box === document.documentElement || box === document.body) return;
4499
- const at = row.getBoundingClientRect();
4500
- const view = box.getBoundingClientRect();
4501
- if (at.top < view.top) box.scrollTop -= view.top - at.top;
4502
- else if (at.bottom > view.bottom) box.scrollTop += Math.min(at.bottom - view.bottom, at.top - view.top);
4503
- }
4504
4601
  function Line({ message }) {
4505
4602
  return /* @__PURE__ */ jsx59(EmptyState, { scope: "rows", message });
4506
4603
  }
4507
- var groupLinked = createContext8(void 0);
4604
+ var groupLinked = createContext9(void 0);
4508
4605
  function groupBox(box, id) {
4509
4606
  const group = [...box?.querySelectorAll("[data-nav-group]") ?? []].find((one) => one.dataset.navGroup === id);
4510
4607
  return group && group.getBoundingClientRect().height > 0 ? group : void 0;
@@ -4558,17 +4655,17 @@ function Group({ group, selected, onSelect, opening, storageKey }) {
4558
4655
  );
4559
4656
  }
4560
4657
  function NavTreeSection({ id, title, message, loading = false, pending = false, trailing, count, actions, menu, menuLabel, icon, defaultOpen = true, open, onOpenChange, storageKey, openFor, onIntent, children }) {
4561
- const timer = useRef16(void 0);
4562
- useEffect10(() => () => clearTimeout(timer.current), []);
4658
+ const timer = useRef17(void 0);
4659
+ useEffect11(() => () => clearTimeout(timer.current), []);
4563
4660
  const [slow, setSlow] = useState18(false);
4564
4661
  if (!pending && slow) setSlow(false);
4565
- useEffect10(() => {
4662
+ useEffect11(() => {
4566
4663
  if (!pending) return;
4567
4664
  const wait = setTimeout(() => setSlow(true), NAV_TREE_PENDING_MS);
4568
4665
  return () => clearTimeout(wait);
4569
4666
  }, [pending]);
4570
4667
  const intent = onIntent;
4571
- const linkedTo = useContext8(groupLinked);
4668
+ const linkedTo = useContext9(groupLinked);
4572
4669
  const linked = id !== void 0 && linkedTo === id ? id : void 0;
4573
4670
  return /* @__PURE__ */ jsx59(
4574
4671
  "div",
@@ -4608,24 +4705,10 @@ function NavTreeSection({ id, title, message, loading = false, pending = false,
4608
4705
  }
4609
4706
  function NavTree({ title, titleActions, groups, children, selected, selectedParent, selectedGroup, onSelect, emptyMessage = "", storageKey }) {
4610
4707
  const opening = groups ? openingFor(groups, selected, selectedParent) : null;
4611
- const box = useRef16(null);
4612
- const scrolled = useRef16(void 0);
4613
- const waiting = useRef16(void 0);
4614
- const latest = useRef16(selected);
4615
- latest.current = selected;
4616
- useEffect10(() => {
4617
- if (selected === void 0 || scrolled.current === selected || waiting.current !== void 0) return;
4618
- waiting.current = setTimeout(() => {
4619
- waiting.current = void 0;
4620
- const row = box.current?.querySelector('[aria-current="page"]');
4621
- if (!row || row.getBoundingClientRect().height === 0) return;
4622
- scrolled.current = latest.current;
4623
- scrollToRow(row);
4624
- }, NAV_TREE_REVEAL_MS);
4625
- });
4626
- useEffect10(() => () => clearTimeout(waiting.current), []);
4627
- const groupScrolled = useRef16(void 0);
4628
- useEffect10(() => {
4708
+ const box = useRef17(null);
4709
+ useRevealCurrentRow(box, selected);
4710
+ const groupScrolled = useRef17(void 0);
4711
+ useEffect11(() => {
4629
4712
  if (selectedGroup === void 0) {
4630
4713
  groupScrolled.current = void 0;
4631
4714
  return;
@@ -4649,13 +4732,13 @@ function NavTree({ title, titleActions, groups, children, selected, selectedPare
4649
4732
  }
4650
4733
 
4651
4734
  // src/Popover.tsx
4652
- import { useMemo as useMemo4 } from "react";
4735
+ import { useMemo as useMemo5 } from "react";
4653
4736
  import { Popover as BasePopover } from "@base-ui/react/popover";
4654
4737
  import { jsx as jsx60, jsxs as jsxs44 } from "react/jsx-runtime";
4655
4738
  var GAP6 = 4;
4656
4739
  var VIEWPORT_PAD6 = 8;
4657
4740
  function Popover({ trigger, anchor, align = "left", side = "bottom", open, onOpenChange, finalFocus, actionsRef, ariaLabel, children, className, contentClassName, maxHeight }) {
4658
- const anchorTarget = useMemo4(() => {
4741
+ const anchorTarget = useMemo5(() => {
4659
4742
  if (!anchor) return void 0;
4660
4743
  if (anchor instanceof Element || "getBoundingClientRect" in anchor) return anchor;
4661
4744
  return { getBoundingClientRect: () => anchor };
@@ -4704,11 +4787,11 @@ function Popover({ trigger, anchor, align = "left", side = "bottom", open, onOpe
4704
4787
  }
4705
4788
 
4706
4789
  // src/SuggestionMenu.tsx
4707
- import { useCallback as useCallback5, useEffect as useEffect11, useId as useId5, useImperativeHandle, useMemo as useMemo5, useRef as useRef17, useState as useState19 } from "react";
4790
+ import { useCallback as useCallback5, useEffect as useEffect12, useId as useId5, useImperativeHandle, useMemo as useMemo6, useRef as useRef18, useState as useState19 } from "react";
4708
4791
  import { jsx as jsx61, jsxs as jsxs45 } from "react/jsx-runtime";
4709
4792
  function SuggestionMenu({ rect, editorElement, ariaLabel, width, maxHeight, sections, itemKey, row, onSelect, handle }) {
4710
- const last = useRef17(null);
4711
- const anchor = useMemo5(() => {
4793
+ const last = useRef18(null);
4794
+ const anchor = useMemo6(() => {
4712
4795
  if (typeof rect !== "function") return rect;
4713
4796
  return {
4714
4797
  getBoundingClientRect: () => {
@@ -4718,15 +4801,15 @@ function SuggestionMenu({ rect, editorElement, ariaLabel, width, maxHeight, sect
4718
4801
  contextElement: editorElement ?? void 0
4719
4802
  };
4720
4803
  }, [rect, editorElement]);
4721
- const shown2 = useMemo5(() => sections.filter((section) => section.items.length > 0), [sections]);
4722
- const items = useMemo5(() => shown2.flatMap((section) => section.items), [shown2]);
4804
+ const shown2 = useMemo6(() => sections.filter((section) => section.items.length > 0), [sections]);
4805
+ const items = useMemo6(() => shown2.flatMap((section) => section.items), [shown2]);
4723
4806
  const keys = items.map(itemKey).join("\n");
4724
4807
  const [highlight, setHighlight] = useState19(0);
4725
4808
  const base = useId5();
4726
4809
  const listboxId = `${base}-list`;
4727
- const chosen = useRef17(null);
4728
- useEffect11(() => void (chosen.current = highlight > 0 ? keys.split("\n")[highlight] ?? null : null), [highlight]);
4729
- useEffect11(() => {
4810
+ const chosen = useRef18(null);
4811
+ useEffect12(() => void (chosen.current = highlight > 0 ? keys.split("\n")[highlight] ?? null : null), [highlight]);
4812
+ useEffect12(() => {
4730
4813
  const at = chosen.current ? keys.split("\n").indexOf(chosen.current) : -1;
4731
4814
  setHighlight(at > 0 ? at : 0);
4732
4815
  }, [keys]);
@@ -4751,7 +4834,7 @@ function SuggestionMenu({ rect, editorElement, ariaLabel, width, maxHeight, sect
4751
4834
  }
4752
4835
  }), [items, highlight, onSelect]);
4753
4836
  const open = rect !== null && items.length > 0;
4754
- useEffect11(() => {
4837
+ useEffect12(() => {
4755
4838
  if (!editorElement || !open) return;
4756
4839
  editorElement.setAttribute("aria-autocomplete", "list");
4757
4840
  editorElement.setAttribute("aria-haspopup", "listbox");
@@ -4760,7 +4843,7 @@ function SuggestionMenu({ rect, editorElement, ariaLabel, width, maxHeight, sect
4760
4843
  for (const name of ["aria-autocomplete", "aria-haspopup", "aria-controls", "aria-activedescendant"]) editorElement.removeAttribute(name);
4761
4844
  };
4762
4845
  }, [editorElement, open, listboxId]);
4763
- useEffect11(() => {
4846
+ useEffect12(() => {
4764
4847
  if (!editorElement || !open) return;
4765
4848
  editorElement.setAttribute("aria-activedescendant", `${base}-${highlight}`);
4766
4849
  }, [editorElement, open, base, highlight]);
@@ -4817,15 +4900,15 @@ function SuggestionMenu({ rect, editorElement, ariaLabel, width, maxHeight, sect
4817
4900
  }
4818
4901
 
4819
4902
  // src/ShowMore.tsx
4820
- import { useLayoutEffect as useLayoutEffect5, useRef as useRef18, useState as useState20 } from "react";
4903
+ import { useLayoutEffect as useLayoutEffect6, useRef as useRef19, useState as useState20 } from "react";
4821
4904
  import { IconChevronDown as IconChevronDown4, IconChevronUp } from "@tabler/icons-react";
4822
4905
  import { jsx as jsx62, jsxs as jsxs46 } from "react/jsx-runtime";
4823
4906
  var FADE = "linear-gradient(to top, transparent, black 40px)";
4824
4907
  function ShowMore({ children, maxHeight = 96, contentClassName, className }) {
4825
- const box = useRef18(null);
4908
+ const box = useRef19(null);
4826
4909
  const [open, setOpen] = useState20(false);
4827
4910
  const [overflows, setOverflows] = useState20(false);
4828
- useLayoutEffect5(() => {
4911
+ useLayoutEffect6(() => {
4829
4912
  const el = box.current;
4830
4913
  if (!el) return;
4831
4914
  const measure = () => setOverflows(el.scrollHeight > maxHeight + 1);
@@ -4929,8 +5012,8 @@ function ReactionPicker({ options, onSelect, "aria-label": ariaLabel = "Reaction
4929
5012
  }
4930
5013
 
4931
5014
  // src/linked.ts
4932
- import { createContext as createContext9 } from "react";
4933
- var inTheBox = createContext9(false);
5015
+ import { createContext as createContext10 } from "react";
5016
+ var inTheBox = createContext10(false);
4934
5017
  function chosenOf(picker) {
4935
5018
  return picker?.value === void 0 ? void 0 : picker.options.find((option) => option.value === picker.value);
4936
5019
  }
@@ -5154,7 +5237,7 @@ function titleOf(object) {
5154
5237
  function idOf(object) {
5155
5238
  return object.address ?? object.eventId ?? object.ref;
5156
5239
  }
5157
- function keyOf(object) {
5240
+ function keyOf2(object) {
5158
5241
  return object.meta.find((slot) => (slot.field === "ref" || slot.field === "key") && !slot.isPubkey && slot.value)?.value;
5159
5242
  }
5160
5243
  function ownerSlotOf(object) {
@@ -5173,7 +5256,7 @@ function childrenOf(object, options) {
5173
5256
  const status = child.slots.status;
5174
5257
  const owner = ownerSlotOf(child);
5175
5258
  const person = owner ? child.people?.[owner.value] : void 0;
5176
- const key = keyOf(child);
5259
+ const key = keyOf2(child);
5177
5260
  return {
5178
5261
  id: idOf(child),
5179
5262
  title: titleOf(child),
@@ -5258,7 +5341,7 @@ function linkedFrom(object, options) {
5258
5341
  };
5259
5342
  }
5260
5343
  const onAct = object.archived ? void 0 : options.onAct;
5261
- const key = keyOf(object);
5344
+ const key = keyOf2(object);
5262
5345
  const noun = nounOf(object);
5263
5346
  const status = statusOf(object, onAct);
5264
5347
  const owner = ownerOf(object, options, onAct);
@@ -5306,7 +5389,7 @@ function linkStateFrom(object, unread, options) {
5306
5389
  }
5307
5390
 
5308
5391
  // src/LinkParts.tsx
5309
- import { useContext as useContext9 } from "react";
5392
+ import { useContext as useContext10 } from "react";
5310
5393
  import { IconCircleCheck, IconCircleDashed as IconCircleDashed3, IconCircleHalf2, IconCircleX, IconFileText, IconMessage2 as IconMessage22 } from "@tabler/icons-react";
5311
5394
  import { jsx as jsx65, jsxs as jsxs47 } from "react/jsx-runtime";
5312
5395
  var STATUS_ICON = {
@@ -5363,7 +5446,7 @@ function countWords(count, noun) {
5363
5446
  }
5364
5447
  function CommentCount({ conversation, noun = "comments" }) {
5365
5448
  const { count, href, unread = false } = conversation;
5366
- const boxed = useContext9(inTheBox);
5449
+ const boxed = useContext10(inTheBox);
5367
5450
  const said = countWords(count, noun);
5368
5451
  if (boxed || !href) {
5369
5452
  return /* @__PURE__ */ jsxs47("span", { className: cn("inline-flex h-6 shrink-0 items-center gap-1 px-1.5 text-small tabular-nums", unread ? "font-medium text-text-primary" : "text-text-secondary"), children: [
@@ -5443,10 +5526,10 @@ function LinkPickers({ status, owner, ownerLabel = "Owner", readOnly = false, di
5443
5526
  import { useSyncExternalStore } from "react";
5444
5527
 
5445
5528
  // src/LinkCard.tsx
5446
- import { useContext as useContext11 } from "react";
5529
+ import { useContext as useContext12 } from "react";
5447
5530
 
5448
5531
  // src/LinkRow.tsx
5449
- import { useContext as useContext10 } from "react";
5532
+ import { useContext as useContext11 } from "react";
5450
5533
  import { jsx as jsx66, jsxs as jsxs48 } from "react/jsx-runtime";
5451
5534
  var ROW_CLASSES2 = "flex items-center gap-3 p-1.5 pr-3";
5452
5535
  function LinkUnavailable({ kind, noun, named: named2 = false, card = false, deleted = false, failed = false }) {
@@ -5457,7 +5540,7 @@ function unavailableWords(noun, { named: named2 = false, deleted = false, failed
5457
5540
  return deleted ? `${named2 ? `File in ${noun}` : noun} deleted` : failed ? `Couldn't load this ${word}` : `You can't open this ${word}`;
5458
5541
  }
5459
5542
  function UnavailableRow({ kind, words, href, card = false }) {
5460
- const wide = useContext10(inTheBox);
5543
+ const wide = useContext11(inTheBox);
5461
5544
  return /* @__PURE__ */ jsxs48(Card, { fill: wide ? "elevated" : "inset", className: cn(card ? "flex items-center gap-3 p-3" : ROW_CLASSES2, "max-w-[480px]"), children: [
5462
5545
  /* @__PURE__ */ jsx66("span", { className: TYPE_TILE_CLASSES, children: /* @__PURE__ */ jsx66(LinkedIcon, { kind }) }),
5463
5546
  /* @__PURE__ */ jsx66("span", { className: "min-w-0 flex-1 truncate text-body-2 text-text-muted", children: href && !wide ? /* @__PURE__ */ jsx66(Link, { href, variant: "quiet", children: words }) : words })
@@ -5519,12 +5602,12 @@ function LinkRow({ link, preview = true }) {
5519
5602
  import { Fragment as Fragment17, jsx as jsx67, jsxs as jsxs49 } from "react/jsx-runtime";
5520
5603
  var CARD_CLASSES = "flex flex-col gap-3 p-3";
5521
5604
  function CardLink({ href, truncate = false, className, children }) {
5522
- const boxed = useContext11(inTheBox);
5605
+ const boxed = useContext12(inTheBox);
5523
5606
  if (boxed || !href) return /* @__PURE__ */ jsx67("span", { className: cn(truncate && "truncate", className), children });
5524
5607
  return /* @__PURE__ */ jsx67(Link, { href, variant: "quiet", truncate, className, children });
5525
5608
  }
5526
5609
  function LinkCard({ link, readOnly = false, bare = false }) {
5527
- const boxed = useContext11(inTheBox);
5610
+ const boxed = useContext12(inTheBox);
5528
5611
  if (link.state === "loading") return /* @__PURE__ */ jsx67(LinkCardLoading, { kind: link.kind, shape: link.shape });
5529
5612
  if (link.state === "unavailable") {
5530
5613
  if (link.url) return /* @__PURE__ */ jsx67(WrittenUrl, { url: link.url, block: true });
@@ -5536,7 +5619,7 @@ function LinkCard({ link, readOnly = false, bare = false }) {
5536
5619
  return /* @__PURE__ */ jsx67(Card, { fill: boxed ? "elevated" : "inset", className: cn(CARD_CLASSES, "max-w-[480px]"), children: body });
5537
5620
  }
5538
5621
  function CardBody({ linked, readOnly }) {
5539
- const boxed = useContext11(inTheBox);
5622
+ const boxed = useContext12(inTheBox);
5540
5623
  const on = boxed ? "elevated" : "inset";
5541
5624
  const meta = linkMetaOf(linked);
5542
5625
  const footed = Boolean(linked.status || linked.owner || linked.authors || linked.updated);
@@ -5610,7 +5693,7 @@ var KIND_SHAPE = {
5610
5693
  };
5611
5694
  function LinkCardLoading({ kind, shape }) {
5612
5695
  const { subtitle = false, summary = true, rows = 0, latest = false, ring = false, footer = "line" } = shape ?? KIND_SHAPE[kind];
5613
- const boxed = useContext11(inTheBox);
5696
+ const boxed = useContext12(inTheBox);
5614
5697
  return /* @__PURE__ */ jsx67("div", { className: "animate-skeleton-in", "aria-busy": true, children: /* @__PURE__ */ jsxs49(Card, { fill: boxed ? "elevated" : "inset", "aria-hidden": true, className: cn(CARD_CLASSES, "max-w-[480px]"), children: [
5615
5698
  /* @__PURE__ */ jsxs49("div", { className: "flex items-center gap-3", children: [
5616
5699
  /* @__PURE__ */ jsx67("span", { className: TYPE_TILE_CLASSES, children: /* @__PURE__ */ jsx67(LinkedIcon, { kind }) }),
@@ -5700,16 +5783,16 @@ function LinkChip({ link, preview = true }) {
5700
5783
  }
5701
5784
 
5702
5785
  // src/AttachedCard.tsx
5703
- import { createContext as createContext10, useContext as useContext12, useEffect as useEffect12, useRef as useRef19 } from "react";
5786
+ import { createContext as createContext11, useContext as useContext13, useEffect as useEffect13, useRef as useRef20 } from "react";
5704
5787
  import { Fragment as Fragment19, jsx as jsx70, jsxs as jsxs51 } from "react/jsx-runtime";
5705
- var Attached = createContext10(false);
5788
+ var Attached = createContext11(false);
5706
5789
  function useRememberedHeight(link, remember, box) {
5707
5790
  const memory = remember?.memory;
5708
5791
  const id = remember?.id;
5709
5792
  const kept = memory && id && link?.state === "loading" ? memory.of(id, link.kind) : void 0;
5710
5793
  const shapeKey = memory && id && link?.state === "ready" ? JSON.stringify(loadingShapeOf(link.linked)) : void 0;
5711
5794
  const kind = link?.state === "ready" ? link.linked.kind : link?.kind;
5712
- useEffect12(() => {
5795
+ useEffect13(() => {
5713
5796
  const card = box.current;
5714
5797
  if (!memory || !id || !kind || !shapeKey || !card) return;
5715
5798
  const drawn = JSON.parse(shapeKey);
@@ -5733,11 +5816,11 @@ function useRememberedHeight(link, remember, box) {
5733
5816
  return { kept, held: kept?.height ? { minHeight: kept.height } : void 0 };
5734
5817
  }
5735
5818
  function AttachedCard({ link, children, onRemove, remember }) {
5736
- const box = useRef19(null);
5819
+ const box = useRef20(null);
5737
5820
  const { kept, held } = useRememberedHeight(link, remember, box);
5738
5821
  const shown2 = link?.state === "loading" && !link.shape && kept ? { ...link, shape: kept } : link;
5739
5822
  const card = shown2 ? /* @__PURE__ */ jsx70(LinkCard, { link: shown2 }) : children;
5740
- const inside = useContext12(Attached);
5823
+ const inside = useContext13(Attached);
5741
5824
  if (inside) {
5742
5825
  return remember ? /* @__PURE__ */ jsx70("div", { ref: box, style: held, children: card }) : /* @__PURE__ */ jsx70(Fragment19, { children: card });
5743
5826
  }
@@ -5798,11 +5881,11 @@ function CornerMenu({ children, menu }) {
5798
5881
  }
5799
5882
 
5800
5883
  // src/PartCard.tsx
5801
- import { useContext as useContext13 } from "react";
5884
+ import { useContext as useContext14 } from "react";
5802
5885
  import { jsx as jsx72, jsxs as jsxs53 } from "react/jsx-runtime";
5803
5886
  function PartCard({ state = "ready", kind, heading, href, partKey, noun, children, maxHeight }) {
5804
5887
  const word = noun ?? kindNounOf({ kind }) ?? "File";
5805
- const boxed = useContext13(inTheBox);
5888
+ const boxed = useContext14(inTheBox);
5806
5889
  if (state === "loading") return /* @__PURE__ */ jsx72(LinkCardLoading, { kind, shape: { summary: true, rows: 0, footer: "none" } });
5807
5890
  if (state === "unavailable" || state === "deleted") {
5808
5891
  return /* @__PURE__ */ jsx72(LinkUnavailable, { kind, noun: state === "deleted" ? `A part of this ${word.toLowerCase()}` : word, deleted: state === "deleted", card: true });
@@ -6020,7 +6103,7 @@ function ConversationActions({ options, onReact, onReply, resolved = false, onRe
6020
6103
  }
6021
6104
 
6022
6105
  // src/ConversationCard.tsx
6023
- import { useContext as useContext14, useLayoutEffect as useLayoutEffect7, useRef as useRef20, useState as useState26 } from "react";
6106
+ import { useContext as useContext15, useLayoutEffect as useLayoutEffect8, useRef as useRef21, useState as useState26 } from "react";
6024
6107
  import { IconArrowNarrowRight, IconCircleCheck as IconCircleCheck4, IconDotsVertical as IconDotsVertical5 } from "@tabler/icons-react";
6025
6108
 
6026
6109
  // src/ConversationMenu.tsx
@@ -6056,11 +6139,16 @@ function ConversationMenu({ resolved = false, onResolve, onReopen, resolveHint,
6056
6139
  }
6057
6140
 
6058
6141
  // src/conversationScroll.ts
6059
- import { createContext as createContext11, useEffect as useEffect13, useState as useState22 } from "react";
6142
+ import { createContext as createContext12, useEffect as useEffect14, useState as useState22 } from "react";
6060
6143
  var NEAR_BOTTOM_PX = 80;
6061
6144
  function isNearBottom(el) {
6062
6145
  return el.scrollHeight - el.scrollTop - el.clientHeight <= NEAR_BOTTOM_PX;
6063
6146
  }
6147
+ function landOn(el, item) {
6148
+ const box = el.getBoundingClientRect();
6149
+ const at = item.getBoundingClientRect();
6150
+ el.scrollTop += at.top - box.top - (el.clientHeight - at.height) / 2;
6151
+ }
6064
6152
  function anchorIn(el) {
6065
6153
  if (typeof document.elementFromPoint !== "function") return void 0;
6066
6154
  const box = el.getBoundingClientRect();
@@ -6075,7 +6163,7 @@ var cardIn = (el, id) => el.querySelector(`[data-conversation-item="${CSS.escape
6075
6163
  function useSteadyScroll(scrollRef, atBottom, ready, key, enabled) {
6076
6164
  const [handle] = useState22(() => ({ rebase: () => {
6077
6165
  } }));
6078
- useEffect13(() => {
6166
+ useEffect14(() => {
6079
6167
  const el = scrollRef.current;
6080
6168
  if (!enabled || !el || typeof ResizeObserver === "undefined") return;
6081
6169
  let fromBottom = 0;
@@ -6126,20 +6214,20 @@ function useSteadyScroll(scrollRef, atBottom, ready, key, enabled) {
6126
6214
  }, [scrollRef, atBottom, ready, key, enabled, handle]);
6127
6215
  return handle;
6128
6216
  }
6129
- var places = /* @__PURE__ */ new Map();
6217
+ var places2 = /* @__PURE__ */ new Map();
6130
6218
  function useLeftAt(key) {
6131
6219
  const [taken, setTaken] = useState22();
6132
6220
  if (!key && taken) setTaken(void 0);
6133
6221
  if (key && taken?.key !== key) {
6134
- const left = places.get(key);
6222
+ const left = places2.get(key);
6135
6223
  const at = left && !left.atBottom ? left.leftAt : null;
6136
6224
  setTaken({ key, at });
6137
6225
  return at;
6138
6226
  }
6139
6227
  return key && taken?.key === key ? taken.at : null;
6140
6228
  }
6141
- var sendsInLayout = createContext11(null);
6142
- var repliesDrawn = createContext11(null);
6229
+ var sendsInLayout = createContext12(null);
6230
+ var repliesDrawn = createContext12(null);
6143
6231
 
6144
6232
  // src/EditedMarker.tsx
6145
6233
  import { jsx as jsx81 } from "react/jsx-runtime";
@@ -6279,18 +6367,18 @@ function ResolveDialog({ onResolve, onCancel, refused }) {
6279
6367
  }
6280
6368
 
6281
6369
  // src/threadCard.ts
6282
- import { createContext as createContext12, useLayoutEffect as useLayoutEffect6, useState as useState25 } from "react";
6283
- var InThreadCard = createContext12(false);
6284
- var InConversationItem = createContext12(null);
6285
- var caretOnOpen = createContext12(0);
6286
- var LineByLayout = createContext12(false);
6370
+ import { createContext as createContext13, useLayoutEffect as useLayoutEffect7, useState as useState25 } from "react";
6371
+ var InThreadCard = createContext13(false);
6372
+ var InConversationItem = createContext13(null);
6373
+ var caretOnOpen = createContext13(0);
6374
+ var LineByLayout = createContext13(false);
6287
6375
  var exactTime = (at) => new Date(at).toLocaleString(void 0, { dateStyle: "long", timeStyle: "short" });
6288
6376
  var momentOf = (at) => at !== void 0 && Number.isFinite(at) ? at : void 0;
6289
6377
  var SHOWN_CLASSES = "data-[shown]:animate-shown data-[shown]:rounded-lg motion-reduce:data-[shown]:animate-none motion-reduce:data-[shown]:bg-accent-wash";
6290
6378
  var FACE_GAP = 4;
6291
6379
  function useFaceLine(root, active, toDot = false) {
6292
6380
  const [line, setLine] = useState25(null);
6293
- useLayoutEffect6(() => {
6381
+ useLayoutEffect7(() => {
6294
6382
  const el = root.current;
6295
6383
  if (!active || !el) {
6296
6384
  setLine(null);
@@ -6350,7 +6438,7 @@ function When({ time, at: given, timeHref, timeLabel = "Link to this" }) {
6350
6438
  var fadeBefore = (end) => `linear-gradient(to right, black ${end - 16}px, transparent ${end}px)`;
6351
6439
  function useClearOfStrip(root, strip, shown2) {
6352
6440
  const [end, setEnd] = useState26();
6353
- useLayoutEffect7(() => {
6441
+ useLayoutEffect8(() => {
6354
6442
  const words = root.current?.querySelector("[data-head]");
6355
6443
  if (!shown2 || !words || !strip.current) {
6356
6444
  setEnd(void 0);
@@ -6406,7 +6494,7 @@ function Words({ children }) {
6406
6494
  }
6407
6495
  function useReactionRefusal(reactions) {
6408
6496
  const [refused, setRefused] = useState26();
6409
- const latest = useRef20(0);
6497
+ const latest = useRef21(0);
6410
6498
  const toggle = reactions?.onToggle;
6411
6499
  if (!reactions || !toggle) return { row: reactions, refused };
6412
6500
  const onToggle = (emoji) => {
@@ -6503,8 +6591,8 @@ function ConversationCard(props) {
6503
6591
  const { author, about, files, reactions, isNew = false, urgent = false, own = false, editor, heading, deleted: isDeleted = false, unseen = false, replies, onReply, resolved, noun = "comment", onResolve, resolveHint, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, deleteRefused, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = "More actions", className, children } = props;
6504
6592
  const deleted = isDeleted || unseen;
6505
6593
  const readOnly = (props.readOnly ?? false) || deleted;
6506
- const inThreadCard = useContext14(InThreadCard);
6507
- const item = useContext14(InConversationItem);
6594
+ const inThreadCard = useContext15(InThreadCard);
6595
+ const item = useContext15(InConversationItem);
6508
6596
  const [hovered, setHovered] = useState26(false);
6509
6597
  const [menuOpen, setMenuOpen] = useState26(false);
6510
6598
  const [picking, setPicking] = useState26(false);
@@ -6516,12 +6604,12 @@ function ConversationCard(props) {
6516
6604
  const resolves = resolved ? onReopen : onResolve;
6517
6605
  const lined = inThreadCard;
6518
6606
  const toDot = !lined && !!resolved?.note && !isEditing;
6519
- const root = useRef20(null);
6607
+ const root = useRef21(null);
6520
6608
  const dotLine = useFaceLine(root, toDot, true);
6521
6609
  const settle = () => requestAnimationFrame(() => setHovered(stillHere(root.current)));
6522
6610
  const offersMenu = !!resolves || !!menu || !!menuAfter || own && (!!editor || !!onDelete);
6523
6611
  const showStrip = hovered && !isEditing && !readOnly;
6524
- const strip = useRef20(null);
6612
+ const strip = useRef21(null);
6525
6613
  const wordsEnd = useClearOfStrip(root, strip, showStrip);
6526
6614
  const { row: reactionRow, refused: reactionRefused } = useReactionRefusal(reactions);
6527
6615
  const react = reactionRow?.onToggle;
@@ -6654,12 +6742,12 @@ function ReplyCard(props) {
6654
6742
  const isEditing = editing && !readOnly && !!editor;
6655
6743
  const offersMenu = !!menu || !!menuAfter || own && (!!editor || !!onDelete);
6656
6744
  const showStrip = hovered && !isEditing && !readOnly && (offersMenu || !!reactions?.onToggle);
6657
- const root = useRef20(null);
6658
- const strip = useRef20(null);
6745
+ const root = useRef21(null);
6746
+ const strip = useRef21(null);
6659
6747
  const wordsEnd = useClearOfStrip(root, strip, showStrip);
6660
6748
  const settle = () => requestAnimationFrame(() => setHovered(stillHere(root.current)));
6661
- const drawn = useContext14(repliesDrawn);
6662
- useLayoutEffect7(() => {
6749
+ const drawn = useContext15(repliesDrawn);
6750
+ useLayoutEffect8(() => {
6663
6751
  if (drawn) drawn.added += 1;
6664
6752
  }, [drawn]);
6665
6753
  return /* @__PURE__ */ jsxs64(Fragment23, { children: [
@@ -6731,7 +6819,7 @@ function ReplyCard(props) {
6731
6819
  }
6732
6820
 
6733
6821
  // src/ConversationLayout.tsx
6734
- import { Fragment as Fragment24, useCallback as useCallback6, useEffect as useEffect15, useLayoutEffect as useLayoutEffect8, useRef as useRef21, useState as useState28 } from "react";
6822
+ import { Fragment as Fragment24, useCallback as useCallback6, useEffect as useEffect16, useLayoutEffect as useLayoutEffect9, useRef as useRef22, useState as useState28 } from "react";
6735
6823
 
6736
6824
  // src/Panel.tsx
6737
6825
  import { jsx as jsx87, jsxs as jsxs65 } from "react/jsx-runtime";
@@ -6759,8 +6847,55 @@ function Panel(props) {
6759
6847
  );
6760
6848
  }
6761
6849
 
6850
+ // src/showInConversation.ts
6851
+ var SHOWN_MS = 1800;
6852
+ var WAIT_MS = 3e3;
6853
+ var POLL_MS = 50;
6854
+ var owed = /* @__PURE__ */ new WeakMap();
6855
+ var asked = 0;
6856
+ function find(id, { comments = false }) {
6857
+ const quoted = CSS.escape(id);
6858
+ return document.querySelector(`[data-reply-id="${quoted}"], [data-thread-start="${quoted}"]`) ?? (comments ? document.querySelector(`[data-conversation-item="${quoted}"]`) : null);
6859
+ }
6860
+ function showInConversation(id, options = {}) {
6861
+ asked += 1;
6862
+ return show(id, options);
6863
+ }
6864
+ function show(id, options) {
6865
+ const el = find(id, options);
6866
+ if (!el) return false;
6867
+ el.scrollIntoView({ behavior: "smooth", block: "center" });
6868
+ markShown(el);
6869
+ return true;
6870
+ }
6871
+ function markShown(el) {
6872
+ const previous = owed.get(el);
6873
+ if (previous !== void 0) window.clearTimeout(previous);
6874
+ el.dataset.shown = "true";
6875
+ owed.set(
6876
+ el,
6877
+ window.setTimeout(() => {
6878
+ delete el.dataset.shown;
6879
+ owed.delete(el);
6880
+ }, SHOWN_MS)
6881
+ );
6882
+ }
6883
+ function showInConversationWhenDrawn(id, { wait = WAIT_MS, ...options } = {}) {
6884
+ const mine = ++asked;
6885
+ return new Promise((resolve) => {
6886
+ const deadline = Date.now() + wait;
6887
+ const attempt = () => {
6888
+ if (mine !== asked) return resolve(false);
6889
+ if (show(id, options)) return resolve(true);
6890
+ if (Date.now() >= deadline) return resolve(false);
6891
+ window.setTimeout(attempt, POLL_MS);
6892
+ };
6893
+ attempt();
6894
+ });
6895
+ }
6896
+
6762
6897
  // src/seenOnScreen.ts
6763
- import { useEffect as useEffect14, useMemo as useMemo6, useState as useState27 } from "react";
6898
+ import { useEffect as useEffect15, useMemo as useMemo7, useState as useState27 } from "react";
6764
6899
  var NONE = /* @__PURE__ */ new Set();
6765
6900
  var DWELL_MS = 1500;
6766
6901
  var TALL_ENOUGH_PX = 120;
@@ -6769,7 +6904,7 @@ var watchers = /* @__PURE__ */ new WeakMap();
6769
6904
  function useSeenOnScreen(key) {
6770
6905
  const [seen, setSeen] = useState27({ key: null, ids: NONE });
6771
6906
  const [watcher] = useState27(() => ({ roots: /* @__PURE__ */ new Map(), watch: { current: null } }));
6772
- useEffect14(() => {
6907
+ useEffect15(() => {
6773
6908
  if (!key) return;
6774
6909
  const timers = /* @__PURE__ */ new Map();
6775
6910
  const showing = /* @__PURE__ */ new Set();
@@ -6837,14 +6972,14 @@ function useSeenOnScreen(key) {
6837
6972
  };
6838
6973
  }, [key, watcher]);
6839
6974
  const ids = seen.key === key ? seen.ids : NONE;
6840
- return useMemo6(() => {
6975
+ return useMemo7(() => {
6841
6976
  const handle = { ids };
6842
6977
  watchers.set(handle, watcher);
6843
6978
  return handle;
6844
6979
  }, [ids, watcher]);
6845
6980
  }
6846
6981
  function useWatchSeen(seen, root, attribute) {
6847
- useEffect14(() => {
6982
+ useEffect15(() => {
6848
6983
  const watcher = seen && watchers.get(seen);
6849
6984
  const el = root.current;
6850
6985
  if (!watcher || !el) return;
@@ -6924,7 +7059,7 @@ function List({ items, open, under, above, loading, empty, change, caret }) {
6924
7059
  ] });
6925
7060
  }
6926
7061
  function UnderItem({ item, isOpen, state, caret }) {
6927
- const root = useRef21(null);
7062
+ const root = useRef22(null);
6928
7063
  const line = useFaceLine(root, isOpen);
6929
7064
  return /* @__PURE__ */ jsxs66(
6930
7065
  Card,
@@ -6972,7 +7107,7 @@ function ConversationLayout({
6972
7107
  className
6973
7108
  }) {
6974
7109
  const beside = threads === "beside";
6975
- const body = useRef21(null);
7110
+ const body = useRef22(null);
6976
7111
  const setBody = useCallback6(
6977
7112
  (el) => {
6978
7113
  body.current = el;
@@ -6982,7 +7117,8 @@ function ConversationLayout({
6982
7117
  [bodyRef]
6983
7118
  );
6984
7119
  useWatchSeen(seen, body, "data-conversation-item");
6985
- const pressed = useRef21(null);
7120
+ const pressed = useRef22(null);
7121
+ const byPress = useRef22(false);
6986
7122
  const itemAt = (id) => body.current?.querySelector(`[data-conversation-item="${CSS.escape(id)}"]`) ?? null;
6987
7123
  const [caret, setCaret] = useState28(0);
6988
7124
  const change = onOpenChange ? (id, next, reply = false) => {
@@ -6992,9 +7128,10 @@ function ConversationLayout({
6992
7128
  }
6993
7129
  const item = threads === "under" ? itemAt(id) : null;
6994
7130
  pressed.current = item ? { id, top: item.getBoundingClientRect().top } : null;
7131
+ byPress.current = true;
6995
7132
  onOpenChange(next);
6996
7133
  } : void 0;
6997
- useLayoutEffect8(() => {
7134
+ useLayoutEffect9(() => {
6998
7135
  const at = pressed.current;
6999
7136
  pressed.current = null;
7000
7137
  const item = at && itemAt(at.id);
@@ -7002,23 +7139,23 @@ function ConversationLayout({
7002
7139
  const moved = item.getBoundingClientRect().top - at.top;
7003
7140
  if (moved !== 0) body.current.scrollTop += moved;
7004
7141
  }, [open]);
7005
- const was = useRef21(open);
7006
- useEffect15(() => {
7142
+ const was = useRef22(open);
7143
+ useEffect16(() => {
7007
7144
  if (open !== void 0 && open !== was.current) setCaret((n) => n + 1);
7008
7145
  was.current = open;
7009
7146
  }, [open]);
7010
- const nearBottom = useRef21(true);
7011
- const placedFor = useRef21(null);
7147
+ const nearBottom = useRef22(true);
7148
+ const placedFor = useRef22(null);
7012
7149
  const placeKey = rememberAs ?? FRESH;
7013
7150
  const scrolled = (event) => {
7014
7151
  const el = body.current;
7015
7152
  if (beside && el) {
7016
7153
  nearBottom.current = isNearBottom(el);
7017
- if (rememberAs && placedFor.current === rememberAs) places.set(rememberAs, { atBottom: nearBottom.current, offset: el.scrollTop, anchor: anchorIn(el), leftAt: Date.now() });
7154
+ if (rememberAs && placedFor.current === rememberAs) places2.set(rememberAs, { atBottom: nearBottom.current, offset: el.scrollTop, anchor: anchorIn(el), leftAt: Date.now() });
7018
7155
  }
7019
7156
  onBodyScroll?.(event);
7020
7157
  };
7021
- useLayoutEffect8(() => {
7158
+ useLayoutEffect9(() => {
7022
7159
  if (!beside) return;
7023
7160
  if (loading) {
7024
7161
  placedFor.current = null;
@@ -7027,8 +7164,14 @@ function ConversationLayout({
7027
7164
  if (placedFor.current === placeKey) return;
7028
7165
  const el = body.current;
7029
7166
  if (!el) return;
7030
- const left = rememberAs ? places.get(rememberAs) : void 0;
7031
- if (left && !left.atBottom) {
7167
+ const left = rememberAs ? places2.get(rememberAs) : void 0;
7168
+ const opened2 = open !== void 0 ? itemAt(open) : null;
7169
+ if (opened2) {
7170
+ landOn(el, opened2);
7171
+ markShown(opened2);
7172
+ nearBottom.current = isNearBottom(el);
7173
+ if (rememberAs) places2.set(rememberAs, { atBottom: nearBottom.current, offset: el.scrollTop, anchor: anchorIn(el), leftAt: Date.now() });
7174
+ } else if (left && !left.atBottom) {
7032
7175
  el.scrollTop = left.offset;
7033
7176
  const card = left.anchor && cardIn(el, left.anchor.id);
7034
7177
  if (card && left.anchor) el.scrollTop += card.getBoundingClientRect().top - el.getBoundingClientRect().top - left.anchor.top;
@@ -7036,20 +7179,31 @@ function ConversationLayout({
7036
7179
  } else {
7037
7180
  el.scrollTop = el.scrollHeight;
7038
7181
  nearBottom.current = true;
7039
- if (rememberAs) places.set(rememberAs, { atBottom: true, offset: el.scrollTop, leftAt: Date.now() });
7182
+ if (rememberAs) places2.set(rememberAs, { atBottom: true, offset: el.scrollTop, leftAt: Date.now() });
7040
7183
  }
7041
7184
  placedFor.current = placeKey;
7042
7185
  }, [beside, placeKey, rememberAs, loading]);
7186
+ useLayoutEffect9(() => {
7187
+ const pressedIt = byPress.current;
7188
+ byPress.current = false;
7189
+ if (!beside || pressedIt || open === void 0 || placedFor.current !== placeKey) return;
7190
+ const el = body.current;
7191
+ const item = itemAt(open);
7192
+ if (!el || !item) return;
7193
+ landOn(el, item);
7194
+ markShown(item);
7195
+ nearBottom.current = isNearBottom(el);
7196
+ }, [open]);
7043
7197
  const placed = useCallback6(() => placedFor.current === placeKey, [placeKey]);
7044
7198
  useSteadyScroll(body, nearBottom, placed, loading, beside);
7045
- useEffect15(() => {
7199
+ useEffect16(() => {
7046
7200
  if (!beside || !rememberAs) return;
7047
7201
  return () => {
7048
- const left = places.get(rememberAs);
7049
- if (left) places.set(rememberAs, { ...left, leftAt: Date.now() });
7202
+ const left = places2.get(rememberAs);
7203
+ if (left) places2.set(rememberAs, { ...left, leftAt: Date.now() });
7050
7204
  };
7051
7205
  }, [beside, rememberAs]);
7052
- useLayoutEffect8(() => {
7206
+ useLayoutEffect9(() => {
7053
7207
  if (!beside || loading || !nearBottom.current) return;
7054
7208
  const el = body.current;
7055
7209
  if (el) el.scrollTop = el.scrollHeight;
@@ -7272,7 +7426,7 @@ function NoAccessNotice({ what }) {
7272
7426
  }
7273
7427
 
7274
7428
  // src/Thread.tsx
7275
- import { Children, useCallback as useCallback7, useContext as useContext15, useLayoutEffect as useLayoutEffect9, useRef as useRef22, useState as useState32 } from "react";
7429
+ import { Children, useCallback as useCallback7, useContext as useContext16, useLayoutEffect as useLayoutEffect10, useRef as useRef23, useState as useState32 } from "react";
7276
7430
  import { IconX as IconX6 } from "@tabler/icons-react";
7277
7431
  import { Fragment as Fragment27, jsx as jsx97, jsxs as jsxs74 } from "react/jsx-runtime";
7278
7432
  var always = () => true;
@@ -7299,7 +7453,7 @@ function Thread({
7299
7453
  seen,
7300
7454
  className
7301
7455
  }) {
7302
- const body = useRef22(null);
7456
+ const body = useRef23(null);
7303
7457
  const setBody = useCallback7(
7304
7458
  (el) => {
7305
7459
  body.current = el;
@@ -7308,12 +7462,12 @@ function Thread({
7308
7462
  },
7309
7463
  [bodyRef]
7310
7464
  );
7311
- const under = useRef22(null);
7465
+ const under = useRef23(null);
7312
7466
  useWatchSeen(seen, place === "under" ? under : body, "data-reply-id");
7313
7467
  const [drawn] = useState32(() => ({ added: 0 }));
7314
- const last = useRef22(null);
7468
+ const last = useRef23(null);
7315
7469
  const steady = useSteadyScroll(body, void 0, always, start?.id, place === "beside");
7316
- useLayoutEffect9(() => {
7470
+ useLayoutEffect10(() => {
7317
7471
  const el = body.current;
7318
7472
  if (place !== "beside" || !el) return;
7319
7473
  const now = { added: drawn.added, start: start?.id };
@@ -7323,7 +7477,7 @@ function Thread({
7323
7477
  steady.rebase();
7324
7478
  });
7325
7479
  const foot = notice ?? box;
7326
- const layoutLine = useContext15(LineByLayout);
7480
+ const layoutLine = useContext16(LineByLayout);
7327
7481
  if (place === "under") {
7328
7482
  return /* @__PURE__ */ jsxs74("div", { ref: under, "data-thread": "under", className: cn("flex flex-col", className), children: [
7329
7483
  (loading || anyIn(children)) && // The replies hang from a line under the comment's face (20px in: its 8px and half its 24px), one step in (Ship's way).
@@ -7360,50 +7514,6 @@ function Thread({
7360
7514
  );
7361
7515
  }
7362
7516
 
7363
- // src/showInConversation.ts
7364
- var SHOWN_MS = 1800;
7365
- var WAIT_MS = 3e3;
7366
- var POLL_MS = 50;
7367
- var owed = /* @__PURE__ */ new WeakMap();
7368
- var asked = 0;
7369
- function find(id, { comments = false }) {
7370
- const quoted = CSS.escape(id);
7371
- return document.querySelector(`[data-reply-id="${quoted}"], [data-thread-start="${quoted}"]`) ?? (comments ? document.querySelector(`[data-conversation-item="${quoted}"]`) : null);
7372
- }
7373
- function showInConversation(id, options = {}) {
7374
- asked += 1;
7375
- return show(id, options);
7376
- }
7377
- function show(id, options) {
7378
- const el = find(id, options);
7379
- if (!el) return false;
7380
- el.scrollIntoView({ behavior: "smooth", block: "center" });
7381
- const previous = owed.get(el);
7382
- if (previous !== void 0) window.clearTimeout(previous);
7383
- el.dataset.shown = "true";
7384
- owed.set(
7385
- el,
7386
- window.setTimeout(() => {
7387
- delete el.dataset.shown;
7388
- owed.delete(el);
7389
- }, SHOWN_MS)
7390
- );
7391
- return true;
7392
- }
7393
- function showInConversationWhenDrawn(id, { wait = WAIT_MS, ...options } = {}) {
7394
- const mine = ++asked;
7395
- return new Promise((resolve) => {
7396
- const deadline = Date.now() + wait;
7397
- const attempt = () => {
7398
- if (mine !== asked) return resolve(false);
7399
- if (show(id, options)) return resolve(true);
7400
- if (Date.now() >= deadline) return resolve(false);
7401
- window.setTimeout(attempt, POLL_MS);
7402
- };
7403
- attempt();
7404
- });
7405
- }
7406
-
7407
7517
  // src/SearchInput.tsx
7408
7518
  import "react";
7409
7519
  import { Input as Input3 } from "@base-ui/react/input";
@@ -7468,8 +7578,12 @@ function PageHeader({ title, leading, private: locked = false, after, meta, time
7468
7578
  }
7469
7579
 
7470
7580
  // src/ListColumn.tsx
7581
+ import { useRef as useRef24 } from "react";
7471
7582
  import { jsx as jsx100, jsxs as jsxs77 } from "react/jsx-runtime";
7472
- function Column({ title, chevron = false, titleMenu, actions, above, collapsed = false, children, className, broken = false }) {
7583
+ function Column({ title, chevron = false, titleMenu, actions, above, collapsed = false, children, rememberAs, className, broken = false }) {
7584
+ const rows = useRef24(null);
7585
+ const place = useListPlace(rows, broken ? void 0 : rememberAs);
7586
+ useRevealCurrentRow(rows, void 0, place);
7473
7587
  return /* @__PURE__ */ jsxs77(
7474
7588
  "div",
7475
7589
  {
@@ -7488,7 +7602,7 @@ function Column({ title, chevron = false, titleMenu, actions, above, collapsed =
7488
7602
  broken ? (
7489
7603
  // The message takes the room the list had and centres itself in it (Katerina, 19 September).
7490
7604
  /* @__PURE__ */ jsx100("div", { className: "flex min-h-0 flex-1 flex-col px-3", children })
7491
- ) : /* @__PURE__ */ jsx100(ScrollArea, { className: "flex-1", contentClassName: "flex flex-col gap-0.5 px-3 pt-4 pb-3", children })
7605
+ ) : /* @__PURE__ */ jsx100(ScrollArea, { className: "flex-1", viewportRef: rows, contentClassName: "flex flex-col gap-0.5 px-3 pt-4 pb-3", children: /* @__PURE__ */ jsx100(ListPlaceContext.Provider, { value: place, children }) })
7492
7606
  ]
7493
7607
  }
7494
7608
  );
@@ -7508,7 +7622,7 @@ function ListColumn(props) {
7508
7622
  }
7509
7623
 
7510
7624
  // src/ListTable.tsx
7511
- import { createContext as createContext13, useCallback as useCallback8, useContext as useContext16, useLayoutEffect as useLayoutEffect10, useRef as useRef23, useState as useState33 } from "react";
7625
+ import { createContext as createContext14, useCallback as useCallback8, useContext as useContext17, useLayoutEffect as useLayoutEffect11, useRef as useRef25, useState as useState33 } from "react";
7512
7626
  import { jsx as jsx101, jsxs as jsxs78 } from "react/jsx-runtime";
7513
7627
  var WIDTH_PX = { small: 80, medium: 96, large: 112 };
7514
7628
  var WIDTH_CLASSES = { small: "w-20", medium: "w-24", large: "w-28" };
@@ -7518,11 +7632,11 @@ var sizeOf = (column) => column.width ?? DEFAULT_WIDTH;
7518
7632
  var ROW_FRAME_PX = 24 + 16 + 12;
7519
7633
  var GAP_PX = 12;
7520
7634
  var END_PX = 64;
7521
- var ListTableContext = createContext13(null);
7635
+ var ListTableContext = createContext14(null);
7522
7636
  var showsColumn = (column, shown2) => shown2 === "all" || shown2 === "high" && (column.keep ?? "high") === "high";
7523
7637
  var widthOf = (columns, end) => ROW_FRAME_PX + NAME_LEAST_PX + columns.reduce((sum, column) => sum + GAP_PX + WIDTH_PX[sizeOf(column)], 0) + (end ? GAP_PX + END_PX : 0);
7524
7638
  function ListTable({ "aria-label": label, nameLabel = "Name", columns, end = false, headings = true, children, className }) {
7525
- const box = useRef23(null);
7639
+ const box = useRef25(null);
7526
7640
  const [shown2, setShown] = useState33("all");
7527
7641
  const measure = useCallback8(() => {
7528
7642
  const width = box.current?.getBoundingClientRect().width ?? 0;
@@ -7530,7 +7644,7 @@ function ListTable({ "aria-label": label, nameLabel = "Name", columns, end = fal
7530
7644
  const high = columns.filter((column) => (column.keep ?? "high") === "high");
7531
7645
  setShown(width >= widthOf(columns, end) ? "all" : width >= widthOf(high, end) ? "high" : "none");
7532
7646
  }, [columns, end]);
7533
- useLayoutEffect10(() => {
7647
+ useLayoutEffect11(() => {
7534
7648
  measure();
7535
7649
  const list = box.current;
7536
7650
  if (!list || typeof ResizeObserver === "undefined") return;
@@ -7551,7 +7665,7 @@ function ListTable({ "aria-label": label, nameLabel = "Name", columns, end = fal
7551
7665
  ] }) });
7552
7666
  }
7553
7667
  function ListTableRow({ href, label, description, icon, cells, end, onClick, ...rest }) {
7554
- const table = useContext16(ListTableContext);
7668
+ const table = useContext17(ListTableContext);
7555
7669
  if (!table) throw new Error("ListTableRow is a row of a ListTable: put it inside one.");
7556
7670
  return (
7557
7671
  // A row's look in every list: 8px corners, the fill under the pointer and no edge.
@@ -7628,7 +7742,7 @@ function Tabs({ tabs, active, onChange, size = "default", className, ...aria })
7628
7742
  }
7629
7743
 
7630
7744
  // src/Toast.tsx
7631
- import { createContext as createContext14, useContext as useContext17, useMemo as useMemo7 } from "react";
7745
+ import { createContext as createContext15, useContext as useContext18, useMemo as useMemo8 } from "react";
7632
7746
  import { Toast as BaseToast } from "@base-ui/react/toast";
7633
7747
  import { IconAlertCircle as IconAlertCircle2, IconCircleCheck as IconCircleCheck5, IconCircleX as IconCircleX2 } from "@tabler/icons-react";
7634
7748
  import { jsx as jsx103, jsxs as jsxs80 } from "react/jsx-runtime";
@@ -7679,11 +7793,11 @@ function Toast({ label, type = "neutral", leadingIcon = true, actionLabel, onAct
7679
7793
  hasAction && /* @__PURE__ */ jsx103(Button, { variant: "outlined", size: "small", onClick: onAction, children: actionLabel })
7680
7794
  ] });
7681
7795
  }
7682
- var ToastContext = createContext14(null);
7796
+ var ToastContext = createContext15(null);
7683
7797
  var VISIBLE_TOASTS = 3;
7684
7798
  function ToastProvider({ children }) {
7685
- const manager = useMemo7(() => BaseToast.createToastManager(), []);
7686
- const value = useMemo7(
7799
+ const manager = useMemo8(() => BaseToast.createToastManager(), []);
7800
+ const value = useMemo8(
7687
7801
  () => ({
7688
7802
  showToast: ({ label, type = "neutral", leadingIcon = true, actionLabel, onAction, durationMs = 5e3, onClose }) => manager.add({
7689
7803
  title: label,
@@ -7736,7 +7850,7 @@ function ToastList() {
7736
7850
  });
7737
7851
  }
7738
7852
  function useToast() {
7739
- const ctx = useContext17(ToastContext);
7853
+ const ctx = useContext18(ToastContext);
7740
7854
  if (!ctx) throw new Error("useToast must be used within ToastProvider");
7741
7855
  return ctx;
7742
7856
  }