dsh-claude-slides 2.5.0 → 2.6.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.
@@ -8,7 +8,7 @@
8
8
  <script id="appifact-mode">(function(){var h=document.documentElement;function s(){var t=h.getAttribute('data-theme');if(t==='light'||t==='dark'){h.setAttribute('data-mode',t)}else{h.removeAttribute('data-mode')}}s();if(typeof MutationObserver==='function'){new MutationObserver(s).observe(h,{attributes:true,attributeFilter:['data-theme']})}})();</script>
9
9
  <script id="appifact-flags">(function(){var values={slides_theme_tab:true,appifact_icon_set:true,appifact_extra_export_formats:window.parent===window};function kind(v){return v===null?"null":Array.isArray(v)?"array":typeof v}function copy(v){return JSON.parse(JSON.stringify(v))}globalThis.__appifact_flags={version:"appifact-flags:v1",ready:function(){return Promise.resolve(true)},get:function(key,fallback){if(!Object.prototype.hasOwnProperty.call(values,key)||kind(values[key])!==kind(fallback))return fallback;return copy(values[key])},all:function(){return copy(values)}};})();</script>
10
10
  <title>Slides</title>
11
- <script type="module" crossorigin src="./assets/index-DULUou9H.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-ExkfOJag.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="./assets/index-DooSdFer.css">
13
13
  </head>
14
14
  <body>
@@ -82464,10 +82464,28 @@ function installUiAvatars(runtime2) {
82464
82464
  className: "size-full object-cover",
82465
82465
  draggable: false,
82466
82466
  onError: () => value4(true)
82467
- }) : variant === "claude" ? jsxForUiAvatars2.jsx(Spark, {
82468
- size: "60%",
82469
- color: "currentColor"
82470
- }) : memo4
82467
+ }) : variant === "claude" ? (
82468
+ // BaoCut: the agent's avatar is a robot head (the comments layer's RobotGlyph), not Claude's spark.
82469
+ jsxForUiAvatars2.jsxs("svg", {
82470
+ viewBox: "0 0 16 16",
82471
+ width: "60%",
82472
+ height: "60%",
82473
+ fill: "none",
82474
+ stroke: "currentColor",
82475
+ strokeWidth: 1.4,
82476
+ strokeLinecap: "round",
82477
+ strokeLinejoin: "round",
82478
+ "aria-hidden": true,
82479
+ children: [
82480
+ jsxForUiAvatars2.jsx("rect", { x: 3, y: 5.5, width: 10, height: 7.5, rx: 2 }),
82481
+ jsxForUiAvatars2.jsx("path", { d: "M8 5.5V3.3" }),
82482
+ jsxForUiAvatars2.jsx("circle", { cx: 8, cy: 2.6, r: 0.7, fill: "currentColor", stroke: "none" }),
82483
+ jsxForUiAvatars2.jsx("circle", { cx: 6.1, cy: 8.9, r: 1, fill: "currentColor", stroke: "none" }),
82484
+ jsxForUiAvatars2.jsx("circle", { cx: 9.9, cy: 8.9, r: 1, fill: "currentColor", stroke: "none" }),
82485
+ jsxForUiAvatars2.jsx("path", { d: "M6.6 11.1h2.8M1.5 8.5v2M14.5 8.5v2" })
82486
+ ]
82487
+ })
82488
+ ) : memo4
82471
82489
  });
82472
82490
  }
82473
82491
  );
@@ -207136,7 +207154,8 @@ function installCollaborationSlidePresence(runtime2) {
207136
207154
  key: value4,
207137
207155
  by: value.by,
207138
207156
  name: typeof value3.n === "string" ? truncatePresenceName(value3.n) : "",
207139
- color: (0, runtime2.peerColor)(value3.c, value.by ?? value.peer)
207157
+ color: (0, runtime2.peerColor)(value3.c, value.by ?? value.peer),
207158
+ ...value.agent ? { agent: true } : {}
207140
207159
  }
207141
207160
  ]);
207142
207161
  }
@@ -207282,6 +207301,7 @@ function installCollaborationSlidePresence(runtime2) {
207282
207301
  tip: input.name,
207283
207302
  children: SlidePresenceJsx.jsx(runtime2.Avatar, {
207284
207303
  name: input.name,
207304
+ ...input.agent ? { variant: "claude" } : {},
207285
207305
  style: {
207286
207306
  backgroundColor: input.color,
207287
207307
  color: (0, runtime2.peerInkColor)(input.color)
@@ -255281,7 +255301,7 @@ function installEditorApp(runtime2) {
255281
255301
  ]
255282
255302
  }),
255283
255303
  // BaoCut: a seat for the comments button, right of Download. A page opened on its own (not in BaoCut's
255284
- // iframe) draws claude.ai's comments button into it (@baoyu-design/comments, ui/toolbar.tsx); elsewhere
255304
+ // iframe) draws claude.ai's comments button into it (the shared comments toolbar); elsewhere
255285
255305
  // it stays empty.
255286
255306
  SlidesAppJsx.jsx("span", {
255287
255307
  "data-baoyu-comments-seat": "",
@@ -257384,7 +257404,7 @@ function installEditorApp(runtime2) {
257384
257404
  });
257385
257405
  isLocalEmbeddableResource = (url) => (0, runtime2.isStoredBlobReference)(url) || runtime2.designSystemImagePathPattern.test(url);
257386
257406
  AGENT_CURSOR_OFFSET = { left: 48, top: 48 };
257387
- AGENT_CURSOR_LABEL = { kind: "name", text: (0, runtime2.literalMessage)("the agent") };
257407
+ AGENT_CURSOR_LABEL = { kind: "name", text: (0, runtime2.literalMessage)("Agent") };
257388
257408
  DEFAULT_TEXT_INSERT_WIDTH = 800;
257389
257409
  MIN_TEXT_INSERT_WIDTH = (0, runtime2.minimumNodeResizeSize)({
257390
257410
  kind: "text",
@@ -269210,7 +269230,7 @@ function installFilesSlidesDocument(runtime2) {
269210
269230
  {
269211
269231
  notesInFiles: notesStoredInFiles
269212
269232
  }
269213
- ), liveSlideFiles = /* @__PURE__ */ new Map(), knownSlideShas = /* @__PURE__ */ new Map(), localSlideOverrides = /* @__PURE__ */ new Map(), heldRemoteSlideBases = /* @__PURE__ */ new Map(), dirtySlidePaths = /* @__PURE__ */ new Set(), inFlightSlidePaths = /* @__PURE__ */ new Set(), slideConflicts = /* @__PURE__ */ new Map(), slideLocalRevisions = /* @__PURE__ */ new Map(), deckLocalRevision = 0, getSlideLocalRevision = (input) => deckLocalRevision * 1e6 + (slideLocalRevisions.get(input) ?? 0), reportedStaleSlideRevisions = /* @__PURE__ */ new Map(), bumpSlideLocalRevision = (input) => {
269233
+ ), liveSlideFiles = /* @__PURE__ */ new Map(), slideTextsBySha = /* @__PURE__ */ new Map(), knownSlideShas = /* @__PURE__ */ new Map(), localSlideOverrides = /* @__PURE__ */ new Map(), heldRemoteSlideBases = /* @__PURE__ */ new Map(), dirtySlidePaths = /* @__PURE__ */ new Set(), inFlightSlidePaths = /* @__PURE__ */ new Set(), slideConflicts = /* @__PURE__ */ new Map(), askedClashes = /* @__PURE__ */ new Set(), askedClashesKey = "", slideLocalRevisions = /* @__PURE__ */ new Map(), deckLocalRevision = 0, getSlideLocalRevision = (input) => deckLocalRevision * 1e6 + (slideLocalRevisions.get(input) ?? 0), reportedStaleSlideRevisions = /* @__PURE__ */ new Map(), bumpSlideLocalRevision = (input) => {
269214
269234
  let value = (0, runtime2.slideIdFromFilePath)(input);
269215
269235
  if (value !== void 0) {
269216
269236
  slideLocalRevisions.set(
@@ -269299,6 +269319,7 @@ function installFilesSlidesDocument(runtime2) {
269299
269319
  text: value3,
269300
269320
  sha: value4
269301
269321
  });
269322
+ rememberSlideText(value4, value3);
269302
269323
  knownSlideShas.set(value2, value4);
269303
269324
  if (localSlideOverrides.get(value2) === value3 && !dirtySlidePaths.has(value2)) {
269304
269325
  localSlideOverrides.delete(value2);
@@ -269740,6 +269761,7 @@ function installFilesSlidesDocument(runtime2) {
269740
269761
  }
269741
269762
  let lastSaveAnnouncementKey = "";
269742
269763
  function notifySaveSubscribers() {
269764
+ syncAskedClashes();
269743
269765
  let value = getSaveState();
269744
269766
  if (unsendableFiles !== void 0 && !unsendableNoticeShown && canReportUnsendable()) {
269745
269767
  unsendableNoticeShown = true;
@@ -270655,6 +270677,30 @@ function installFilesSlidesDocument(runtime2) {
270655
270677
  }
270656
270678
  }
270657
270679
  let rebasedSlideShas = /* @__PURE__ */ new Map();
270680
+ function syncAskedClashes() {
270681
+ if (options.onClashes === void 0 && askedClashes.size === 0) {
270682
+ return;
270683
+ }
270684
+ for (let value of [...askedClashes])
270685
+ if (!slideConflicts.has(value)) {
270686
+ askedClashes.delete(value);
270687
+ }
270688
+ let items = [...askedClashes].map((input) => {
270689
+ let entry = slideConflicts.get(input);
270690
+ return {
270691
+ ...entry,
270692
+ slideNo: getSlideNumber(entry.slideId)
270693
+ };
270694
+ }), value2 = JSON.stringify(items);
270695
+ if (value2 === askedClashesKey) {
270696
+ return;
270697
+ }
270698
+ askedClashesKey = value2;
270699
+ try {
270700
+ options.onClashes?.(items);
270701
+ } catch {
270702
+ }
270703
+ }
270658
270704
  function retryDirtySlide(input) {
270659
270705
  if (disposed || !slideConflicts.has(input)) {
270660
270706
  return;
@@ -270670,6 +270716,22 @@ function installFilesSlidesDocument(runtime2) {
270670
270716
  if (inFlightSlidePaths.has(input) && !saveQueue.unsendable().has(input) && !(stuckSave !== void 0 && !stuckSave.retryable)) {
270671
270717
  return;
270672
270718
  }
270719
+ let merged = mergeClashingSlide(input, entry);
270720
+ if (merged !== null) {
270721
+ if (value !== void 0 && (options.holdRemote?.(value) === true || options.inSlide?.(value) === true)) {
270722
+ return;
270723
+ }
270724
+ applyMergedSlide(input, entry, merged);
270725
+ return;
270726
+ }
270727
+ if (askedClashes.has(input) || options.askClash?.(entry) === true) {
270728
+ if (!askedClashes.has(input)) {
270729
+ askedClashes.add(input);
270730
+ emitEvent("clash-asked", entry);
270731
+ }
270732
+ syncAskedClashes();
270733
+ return;
270734
+ }
270673
270735
  if (LOCAL_SLIDE_RECOVERY_ORIGIN === "mine") {
270674
270736
  let value3 = entry.theirsSha === null && typeof localSlideOverrides.get(input) === "string";
270675
270737
  if (value3) {
@@ -270691,6 +270753,61 @@ function installFilesSlidesDocument(runtime2) {
270691
270753
  (value2 > 0 ? "Slide " + String(value2) : "A slide") + (entry.theirsSha === null ? " deleted remotely" : " changed remotely")
270692
270754
  );
270693
270755
  }
270756
+ function rememberSlideText(sha, text) {
270757
+ slideTextsBySha.delete(sha);
270758
+ slideTextsBySha.set(sha, text);
270759
+ if (slideTextsBySha.size <= 2 * liveSlideFiles.size + 32) {
270760
+ return;
270761
+ }
270762
+ let values = /* @__PURE__ */ new Set([
270763
+ ...knownSlideShas.values(),
270764
+ ...[...liveSlideFiles.values()].map((input) => input.sha)
270765
+ ]);
270766
+ for (let value of [...slideTextsBySha.keys()]) {
270767
+ if (slideTextsBySha.size <= liveSlideFiles.size + 16) {
270768
+ break;
270769
+ }
270770
+ if (!values.has(value)) {
270771
+ slideTextsBySha.delete(value);
270772
+ }
270773
+ }
270774
+ }
270775
+ function mergeClashingSlide(input, entry) {
270776
+ if (options.mergeText === void 0 || entry.kind !== "edited" || entry.theirsSha === null) {
270777
+ return null;
270778
+ }
270779
+ let value = localSlideOverrides.get(input), entry2 = liveSlideFiles.get(input), value2 = knownSlideShas.get(input), value3 = value2 === void 0 ? void 0 : slideTextsBySha.get(value2);
270780
+ if (typeof value !== "string" || entry2 === void 0 || entry2.sha !== entry.theirsSha || value3 === void 0 || value2 === entry2.sha) {
270781
+ return null;
270782
+ }
270783
+ try {
270784
+ return options.mergeText(value3, value, entry2.text);
270785
+ } catch {
270786
+ return null;
270787
+ }
270788
+ }
270789
+ function applyMergedSlide(input, entry, merged) {
270790
+ emitEvent("clash-merged", {
270791
+ path: input,
270792
+ slide: entry.slideId,
270793
+ theirs: entry.theirsSha
270794
+ });
270795
+ if (merged === liveSlideFiles.get(input)?.text) {
270796
+ resolveSlideConflict(input, "theirs", true);
270797
+ syncAskedClashes();
270798
+ return;
270799
+ }
270800
+ localSlideOverrides.set(input, merged);
270801
+ stashLocalSlideEdit(input, merged, indexStore.get().order);
270802
+ bumpSlideLocalRevision(input);
270803
+ recomposeFromFiles(true);
270804
+ try {
270805
+ options.onMerged?.(input, entry.theirsSha);
270806
+ } catch {
270807
+ }
270808
+ resolveSlideConflict(input, "mine", true);
270809
+ syncAskedClashes();
270810
+ }
270694
270811
  function clashLocalSlide(input) {
270695
270812
  let value = (0, runtime2.slideFilePath)(input);
270696
270813
  if (decompositionPending) {
@@ -271030,6 +271147,7 @@ function installFilesSlidesDocument(runtime2) {
271030
271147
  liveSlideFiles.delete(value3);
271031
271148
  } else {
271032
271149
  liveSlideFiles.set(value3, value4);
271150
+ rememberSlideText(value4.sha, value4.text);
271033
271151
  }
271034
271152
  rebasedSlideShas.delete(value3);
271035
271153
  if (entry === void 0 && value4 !== null || entry !== void 0 && value4 === null) {
@@ -271565,6 +271683,7 @@ function installFilesSlidesDocument(runtime2) {
271565
271683
  text: value8.text,
271566
271684
  sha: value8.sha256
271567
271685
  });
271686
+ rememberSlideText(value8.sha256, value8.text);
271568
271687
  knownSlideShas.set(value7, value8.sha256);
271569
271688
  }
271570
271689
  bootRetryAttempt = 0;
@@ -271837,7 +271956,10 @@ function installFilesSlidesDocument(runtime2) {
271837
271956
  mayEdit: canWrite
271838
271957
  } : void 0,
271839
271958
  conflicts: () => [...slideConflicts.values()],
271840
- resolveConflict: (input, options2) => resolveSlideConflict(input, options2),
271959
+ resolveConflict: (input, options2) => {
271960
+ resolveSlideConflict(input, options2);
271961
+ syncAskedClashes();
271962
+ },
271841
271963
  stashOffers: getStashOffers,
271842
271964
  restoreStashed: restoreStashedSlide,
271843
271965
  discardStashed: discardStashedSlide,
@@ -272361,6 +272483,24 @@ function installBootstrap(runtime2) {
272361
272483
  (0, runtime2.showToast)(input);
272362
272484
  },
272363
272485
  onStashOffer: (input) => showStashedSlideRecovery(value2, input),
272486
+ // BaoCut: someone else saved a slide this tab has unsaved edits on; the host asks the person which to keep.
272487
+ ...globalThis.slidesHost?.clashes !== void 0 ? {
272488
+ askClash: (input) => input.kind === "edited" && input.theirsSha !== null,
272489
+ onClashes: (input) => globalThis.slidesHost?.clashes?.show(
272490
+ input.map((input2) => ({
272491
+ path: input2.path,
272492
+ slideId: input2.slideId,
272493
+ slideNo: input2.slideNo,
272494
+ theirsSha: input2.theirsSha
272495
+ })),
272496
+ (input2, options2) => value2.resolveConflict(input2, options2)
272497
+ )
272498
+ } : {},
272499
+ // BaoCut: both changed different lines of that slide: merged by line, saved as a merge (not an overwrite).
272500
+ ...typeof globalThis.slidesHost?.mergeText === "function" ? {
272501
+ mergeText: (base, mine, theirs) => globalThis.slidesHost?.mergeText?.(base, mine, theirs) ?? null,
272502
+ onMerged: (path, theirsSha) => globalThis.slidesHost?.saveMerged?.(path, theirsSha)
272503
+ } : {},
272364
272504
  ...stash !== void 0 ? {
272365
272505
  stash
272366
272506
  } : {},
@@ -1,4 +1,4 @@
1
- var x=window.__baoyuShare??{},k=x.role==="owner",y=x.noun??{en:"artifact",zh:"\u5185\u5BB9",zhThis:"\u8FD9\u4EFD\u5185\u5BB9"},M=["editor","commenter","viewer"],N=/^zh\b/i.test(navigator.language),t=N?{share:"\u5206\u4EAB",title:`\u5206\u4EAB${y.zhThis}`,close:"\u5173\u95ED",peopleWithAccess:"\u6709\u6743\u8BBF\u95EE\u7684\u4EBA",joinedPeople:"\u52A0\u5165\u7684\u4EBA",generalAccess:"\u4E00\u822C\u8BBF\u95EE\u6743\u9650",inviteLinks:"\u9080\u8BF7\u94FE\u63A5",you:"\uFF08\u4F60\uFF09",thisComputer:"\u8FD9\u53F0\u7535\u8111",owner:"\u6240\u6709\u8005",roleNames:{editor:"\u7F16\u8F91\u8005",commenter:"\u8BC4\u8BBA\u8005",viewer:"\u67E5\u770B\u8005"},linkTitles:{editor:"\u53EF\u7F16\u8F91",commenter:"\u53EF\u8BC4\u8BBA",viewer:"\u4EC5\u67E5\u770B"},roleNotes:{editor:"\u7F16\u8F91\u548C\u8BC4\u8BBA",commenter:x.reactions?"\u8BC4\u8BBA\u548C\u8868\u60C5\u56DE\u5E94\uFF0C\u4E0D\u80FD\u7F16\u8F91":"\u8BC4\u8BBA\uFF0C\u4E0D\u80FD\u7F16\u8F91",viewer:"\u53EA\u80FD\u770B"},changeRole:a=>`\u66F4\u6539\u300C${a}\u300D\u7684\u89D2\u8272`,linkOff:"\u94FE\u63A5\u5DF2\u5173\u95ED",online:"\u5728\u7EBF",seen:a=>`${a}\u6765\u8FC7`,paused:"\u94FE\u63A5\u5DF2\u5173\u95ED\uFF0C\u6682\u65F6\u65E0\u6CD5\u8BBF\u95EE",none:"\u8FD8\u6CA1\u6709\u4EBA\u52A0\u5165\u3002\u628A\u4E0B\u9762\u7684\u94FE\u63A5\u53D1\u7ED9\u5BF9\u65B9\u3002",remove:"\u79FB\u51FA",removeTitle:a=>`\u79FB\u51FA\u300C${a}\u300D\uFF1F`,removeText:`\u5BF9\u65B9\u5C06\u65E0\u6CD5\u518D\u8BBF\u95EE${y.zhThis}\uFF0C\u4E4B\u540E\u4ECD\u53EF\u4EE5\u7528\u94FE\u63A5\u91CD\u65B0\u52A0\u5165\u3002`,onlyHere:"\u4EC5\u8FD9\u53F0\u7535\u8111",onlyHereNote:"\u522B\u4EBA\u6253\u4E0D\u5F00\u8FD9\u4E9B\u94FE\u63A5\u3002",onLan:"\u540C\u4E00\u7F51\u7EDC\u91CC\u6709\u94FE\u63A5\u7684\u4EBA",onLanNote:"\u540C\u4E00 Wi-Fi \u6216\u5C40\u57DF\u7F51\u91CC\u7684\u4EBA\u7528\u94FE\u63A5\u6253\u5F00\uFF0C\u62FF\u5230\u54EA\u4E2A\u94FE\u63A5\u5C31\u662F\u54EA\u4E2A\u89D2\u8272\u3002",whereOff:"\u53EA\u6709\u8FD9\u53F0\u7535\u8111\u80FD\u6253\u5F00\u8FD9\u4E9B\u94FE\u63A5\u3002",whereOn:a=>`\u5C40\u57DF\u7F51\u5730\u5740\uFF1A${a}`,noAddress:"\u8FD9\u53F0\u7535\u8111\u6CA1\u6709\u5C40\u57DF\u7F51\u5730\u5740\u3002",copyLink:"\u590D\u5236\u94FE\u63A5",onlyAccess:"\u53EA\u6709\u6709\u6743\u8BBF\u95EE\u7684\u4EBA\u624D\u80FD\u6253\u5F00\u8FD9\u4E2A\u94FE\u63A5",guestInviteNote:"\u540C\u4E00\u7F51\u7EDC\u91CC\u7684\u4EBA\u6253\u5F00\u94FE\u63A5\uFF0C\u5C31\u4EE5\u8FD9\u4E2A\u89D2\u8272\u52A0\u5165\u3002\u6240\u6709\u8005\u80FD\u770B\u5230\u8C01\u52A0\u5165\u4E86\uFF0C\u53EF\u4EE5\u6539\u89D2\u8272\u6216\u79FB\u51FA\u3002",copied:"\u5DF2\u590D\u5236",turnOn:"\u5F00\u542F",more:"\u66F4\u591A",linkOffNote:"\u5DF2\u5173\u95ED\uFF0C\u6CA1\u4EBA\u80FD\u7528\u5B83\u52A0\u5165",turnOnLink:"\u5F00\u542F\u94FE\u63A5",turnOffLink:"\u5173\u95ED\u94FE\u63A5",turnOffNote:"\u7528\u5B83\u52A0\u5165\u7684\u4EBA\u6682\u65F6\u65E0\u6CD5\u8BBF\u95EE",resetLink:"\u91CD\u7F6E\u94FE\u63A5",resetNote:"\u6362\u4E00\u4E2A\u65B0\u5730\u5740\uFF0C\u7528\u65E7\u94FE\u63A5\u52A0\u5165\u7684\u4EBA\u4F1A\u88AB\u79FB\u51FA",resetTitle:a=>`\u91CD\u7F6E\u300C${a}\u300D\u94FE\u63A5\uFF1F`,resetText:"\u65E7\u94FE\u63A5\u4F1A\u5931\u6548\uFF0C\u901A\u8FC7\u5B83\u52A0\u5165\u7684\u4EBA\u4E5F\u4F1A\u5931\u53BB\u8BBF\u95EE\u6743\u9650\u3002",cancel:"\u53D6\u6D88",failed:"\u6CA1\u80FD\u5B8C\u6210\uFF1A"}:{share:"Share",title:`Share this ${y.en}`,close:"Close",peopleWithAccess:"People with access",joinedPeople:"People who joined",generalAccess:"General access",inviteLinks:"Invite links",you:" (you)",thisComputer:"This computer",owner:"Owner",roleNames:{editor:"Editor",commenter:"Commenter",viewer:"Viewer"},linkTitles:{editor:"Can edit",commenter:"Can comment",viewer:"Can view"},roleNotes:{editor:"Edit and comment",commenter:x.reactions?"Comment and react, no edits":"Comment, no edits",viewer:"Read only"},changeRole:a=>`Change ${a}'s role`,linkOff:"Link off",online:"Online",seen:a=>`Seen ${a}`,paused:"Link off: no access until it is back on",none:"Nobody has joined yet. Send someone a link below.",remove:"Remove",removeTitle:a=>`Remove ${a}?`,removeText:`They lose access to this ${y.en}. They can join again with a link.`,onlyHere:"Only this computer",onlyHereNote:"Nobody else can open the links.",onLan:"Anyone on your network with a link",onLanNote:"People on the same Wi-Fi or LAN open it with a link; the link sets their role.",whereOff:"Only this computer can open these links.",whereOn:a=>`On this network at ${a}`,noAddress:"This computer has no local network address.",copyLink:"Copy link",onlyAccess:"Only people with access can open this link",guestInviteNote:"Whoever on your network opens one joins in that role. The owner sees who joined and can change or remove them.",copied:"Copied",turnOn:"Turn on",more:"More",linkOffNote:"Off: nobody can join with it",turnOnLink:"Turn on link",turnOffLink:"Turn off link",turnOffNote:"Whoever joined with it loses access until it is back on",resetLink:"Reset link",resetNote:"A new address; whoever joined with the old one is removed",resetTitle:a=>`Reset the "${a}" link?`,resetText:"The old link stops working and the people who joined with it lose access.",cancel:"Cancel",failed:"Could not do that: "},C=a=>{if(!a)return"";let e=Math.max(0,(Date.now()-Date.parse(a))/1e3),i=new Intl.RelativeTimeFormat(N?"zh-CN":"en",{numeric:"auto"});return e<60?i.format(0,"second"):e<3600?i.format(-Math.round(e/60),"minute"):e<86400?i.format(-Math.round(e/3600),"hour"):i.format(-Math.round(e/86400),"day")};function T(a){let e=a.trim();if(!e)return"?";if(/^[぀-ヿ㐀-鿿가-힯]/.test(e))return[...e][0];let i=e.split(/\s+/);return((i[0]?.[0]??"")+(i[1]?.[0]??"")).toUpperCase()||"?"}var E=["#3d7a6c","#56688f","#8f6249","#76598f","#857536","#995466","#45799a","#667a45"],$=a=>{let e=0;for(let i of a)e=e*31+i.charCodeAt(0)|0;return E[Math.abs(e)%E.length]},m=(a,e=16)=>`<svg viewBox="0 0 16 16" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${a}</svg>`,p={share:m('<circle cx="4" cy="8" r="2"/><circle cx="12" cy="3.5" r="2"/><circle cx="12" cy="12.5" r="2"/><path d="M5.8 7 10.2 4.5M5.8 9l4.4 2.5"/>',16),close:m('<path d="M4 4l8 8M12 4l-8 8"/>',18),chevron:m('<path d="M4.5 6.2 8 9.7l3.5-3.5"/>',14),check:m('<path d="M3 8.6 6.3 11.8 13 4.6"/>',18),trash:m('<path d="M2.6 4.2h10.8M6.3 4.2V2.7h3.4v1.5M4 4.2l.7 9.1h6.6l.7-9.1M6.7 6.7v4.2M9.3 6.7v4.2"/>',17),link:m('<path d="M6.8 9.2a2.5 2.5 0 0 0 3.5 0l2.3-2.3a2.5 2.5 0 0 0-3.5-3.5l-.8.8M9.2 6.8a2.5 2.5 0 0 0-3.5 0L3.4 9.1a2.5 2.5 0 0 0 3.5 3.5l.8-.8"/>',15),more:'<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><circle cx="3.5" cy="8" r="1.25"/><circle cx="8" cy="8" r="1.25"/><circle cx="12.5" cy="8" r="1.25"/></svg>',lock:m('<rect x="3.5" y="7" width="9" height="6.5" rx="1.6"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>',17),network:m('<path d="M1.8 6.3a9 9 0 0 1 12.4 0M4 8.7a5.8 5.8 0 0 1 8 0M6.3 11a2.5 2.5 0 0 1 3.4 0"/><circle cx="8" cy="13.2" r=".5" fill="currentColor"/>',17),editor:m('<path d="M10.4 2.9 13.1 5.6 5.9 12.8l-3.3.6.6-3.3z"/><path d="M9.1 4.2l2.7 2.7"/>',16),commenter:m('<path d="M3 3h10a1.2 1.2 0 0 1 1.2 1.2v5.6A1.2 1.2 0 0 1 13 11H7.2l-3.2 2.6V11H3a1.2 1.2 0 0 1-1.2-1.2V4.2A1.2 1.2 0 0 1 3 3z"/>',16),viewer:m('<path d="M1.5 8S3.9 3.6 8 3.6 14.5 8 14.5 8 12.1 12.4 8 12.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="2"/>',16)},O=`
1
+ var y=/^zh\b/i.test(navigator.language),K=n=>{if(!n)return"";let e=Math.max(0,(Date.now()-Date.parse(n))/1e3),t=new Intl.RelativeTimeFormat(y?"zh-CN":"en",{numeric:"auto"});return e<60?t.format(0,"second"):e<3600?t.format(-Math.round(e/60),"minute"):e<86400?t.format(-Math.round(e/3600),"hour"):t.format(-Math.round(e/86400),"day")};function T(n){let e=n.trim();if(!e)return"?";if(/^[぀-ヿ㐀-鿿가-힯]/.test(e))return[...e][0];let t=e.split(/\s+/);return((t[0]?.[0]??"")+(t[1]?.[0]??"")).toUpperCase()||"?"}var J=["#3d7a6c","#56688f","#8f6249","#76598f","#857536","#995466","#45799a","#667a45"],S=n=>{let e=0;for(let t of n)e=e*31+t.charCodeAt(0)|0;return J[Math.abs(e)%J.length]},j='<rect x="3" y="5.5" width="10" height="7.5" rx="2"/><path d="M8 5.5V3.3"/><circle cx="8" cy="2.6" r=".7" fill="currentColor" stroke="none"/><circle cx="6.1" cy="8.9" r="1" fill="currentColor" stroke="none"/><circle cx="9.9" cy="8.9" r="1" fill="currentColor" stroke="none"/><path d="M6.6 11.1h2.8M1.5 8.5v2M14.5 8.5v2"/>',w=(n,e=16)=>`<svg viewBox="0 0 16 16" width="${e}" height="${e}" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,E=`
2
2
  :host { all: initial; color: inherit; font-family: inherit; }
3
3
  * { box-sizing: border-box; }
4
4
  .wrap { --bg: #fff; --fg: #1a1915; --muted: #72706a; --faint: #a6a49d; --line: #e9e7e2; --soft: #f2f1ee; --hover: #e9e8e4;
@@ -80,4 +80,99 @@ h2 { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 600; letter
80
80
  .btn:hover { background: var(--hover); }
81
81
  .btn.danger { background: var(--danger); color: #fff; }
82
82
  .btn.danger:hover { filter: brightness(.94); }
83
- `;function n(a,e={},...i){let s=document.createElement(a);for(let[o,r]of Object.entries(e))o==="class"?s.className=r:o==="html"?s.innerHTML=r:s.setAttribute(o,r);return s.append(...i),s}function g(a,e,i,s,o){let r=n("button",{class:a,type:"button",...e});return i&&r.insertAdjacentHTML("beforeend",i),s!==void 0&&r.append(n("span",{},s)),o&&r.insertAdjacentHTML("beforeend",o),r}async function A(a){let e=await fetch("/__share",a?{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}:{cache:"no-store"}),i=await e.json();if(!e.ok)throw new Error(i?.message??`HTTP ${e.status}`);return i}async function S(a){try{await navigator.clipboard.writeText(a)}catch{let e=n("textarea",{style:"position:fixed;opacity:0"});e.value=a,document.body.append(e),e.select(),document.execCommand("copy"),e.remove()}}var L=class{host=n("span",{"data-baoyu-share":""});root=this.host.attachShadow({mode:"open"});wrap=n("div",{class:"wrap seat"});button=n("button",{class:"open float",type:"button","aria-haspopup":"dialog","aria-expanded":"false"});look="float";layer=n("div",{"data-baoyu-share-layer":""});layerRoot=this.layer.attachShadow({mode:"open"});layerWrap=n("div",{class:"wrap"});pop=null;caret=n("div",{class:"caret"});menu=null;menuAnchor=null;menuJustClosed=null;asking=null;view=null;invites=null;error="";timer;copied=null;constructor(){this.root.append(n("style",{},O),this.wrap),this.layerRoot.append(n("style",{},O),this.layerWrap),this.wrap.append(this.button),this.button.addEventListener("click",()=>this.pop?this.close():void this.open()),this.paintButton(),k&&A().then(e=>{this.view=e,this.paintButton()},()=>{})}mount(){let e=()=>{let i=H();if(!i){this.host.isConnected||(this.host.style.cssText="position:fixed;top:10px;right:120px;z-index:2147482000",document.body.append(this.host),this.setLook("float"));return}let[s,o,r]=i;s==="into"&&this.host.parentNode!==o&&o.append(this.host),s==="first"&&o.firstChild!==this.host&&o.prepend(this.host),s==="before"&&o.previousSibling!==this.host&&o.before(this.host),this.host.style.cssText="display:inline-flex;align-items:center",this.setLook(r),this.pop&&this.position()};e(),new MutationObserver(e).observe(document.body,{childList:!0,subtree:!0}),window.setInterval(e,1500)}setLook(e){e!==this.look&&(this.look=e,this.button.className=`open ${e}`,this.paintButton())}paintButton(){let e=k&&!!this.view?.lan;this.button.innerHTML=p.share,this.look==="tool"?(this.button.setAttribute("aria-label",t.share),this.button.title=e?`${t.share} \xB7 ${t.onLan}`:t.share):(this.button.removeAttribute("aria-label"),this.button.removeAttribute("title"),this.button.append(t.share)),e&&this.button.append(n("span",{class:"dot",title:t.onLan}))}async open(){if(this.pop)return;this.pop=n("div",{class:"pop",role:"dialog","aria-label":t.title}),this.layerWrap.append(this.pop,this.caret),document.body.append(this.layer),this.button.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",this.onPointer,!0),window.addEventListener("keydown",this.onKey,!0),window.addEventListener("resize",this.position),window.addEventListener("scroll",this.position,!0),this.position();let e=k?()=>this.refresh():()=>this.refreshInvites();k||this.paintGuest(),await e(),this.timer=window.setInterval(()=>void e(),4e3)}close(){window.clearInterval(this.timer),document.removeEventListener("mousedown",this.onPointer,!0),window.removeEventListener("keydown",this.onKey,!0),window.removeEventListener("resize",this.position),window.removeEventListener("scroll",this.position,!0),this.closeMenu(),this.asking=null,this.pop?.remove(),this.pop=null,this.caret.remove(),this.layer.remove(),this.button.setAttribute("aria-expanded","false"),this.button.focus()}position=()=>{if(!this.pop)return;let e=window.innerWidth,i=window.innerHeight,s=this.button.getBoundingClientRect(),o=s.width>0&&s.bottom>0&&s.top<i,r=Math.min(460,e-24),c=o?s.right:e-16,h=Math.max(12,Math.min(c-r,e-r-12)),d=o?s.bottom+10:56;if(Object.assign(this.pop.style,{left:`${h}px`,top:`${d}px`,width:`${r}px`,maxHeight:`${Math.max(240,i-d-12)}px`}),o){let v=Math.max(h+18,Math.min(s.left+s.width/2-7,h+r-32));Object.assign(this.caret.style,{display:"",left:`${v}px`,top:`${d-7}px`})}else this.caret.style.display="none";this.menu&&this.menuAnchor&&this.placeMenu(this.menu,this.menuAnchor)};onPointer=e=>{let i=e.composedPath();this.menu&&!i.includes(this.menu)&&(this.menuJustClosed=this.menuAnchor,this.closeMenu(),setTimeout(()=>this.menuJustClosed=null,0)),!(!this.pop||i.includes(this.pop)||i.includes(this.host)||this.menu&&i.includes(this.menu))&&this.close()};onKey=e=>{if(e.key==="Escape")if(e.stopPropagation(),e.preventDefault(),this.asking)this.asking();else if(this.menu){let i=this.menuAnchor;this.closeMenu(),i?.focus()}else this.close()};async refresh(e){let i=JSON.stringify([this.view,this.error]);try{this.view=await A(e),this.error=""}catch(s){this.error=t.failed+s.message}this.paintButton(),!(!e&&(this.menu||this.asking||this.pop?.firstChild&&JSON.stringify([this.view,this.error])===i))&&this.paint()}async refreshInvites(){let e=JSON.stringify([this.invites,this.error]);try{let i=await fetch("/__share/invite",{cache:"no-store"}),s=await i.json();if(!i.ok)throw new Error(s?.message??`HTTP ${i.status}`);this.invites=s.links,this.error=""}catch(i){this.error=t.failed+i.message}JSON.stringify([this.invites,this.error])!==e&&this.paintGuest()}openMenu(e,i){if(this.menuJustClosed===e)return;this.closeMenu();let s=n("div",{class:"menu",role:"menu"});for(let o of i){let r=n("button",{class:`item${o.danger?" danger":""}`,type:"button",role:o.checked===void 0?"menuitem":"menuitemradio"});o.checked!==void 0&&r.setAttribute("aria-checked",String(o.checked)),r.disabled=o.disabled===!0,r.append(n("span",{class:"who"},n("span",{class:"name"},o.label),...o.sub?[n("span",{class:"sub"},o.sub)]:[])),o.checked!==void 0&&r.append(n("span",{class:"tick",html:o.checked?p.check:""})),r.addEventListener("click",()=>{this.closeMenu(),e.focus({preventScroll:!0}),o.run()}),s.append(r)}s.addEventListener("keydown",o=>{let r=[...s.querySelectorAll("button:not(:disabled)")],c=r.indexOf(this.layerRoot.activeElement),h=d=>r[(d+r.length)%r.length]?.focus();if(o.key==="ArrowDown")h(c+1);else if(o.key==="ArrowUp")h(c-1);else if(o.key==="Home")h(0);else if(o.key==="End")h(-1);else if(o.key==="Tab")this.closeMenu();else return;o.preventDefault()}),this.menu=s,this.menuAnchor=e,e.setAttribute("aria-expanded","true"),this.layerWrap.append(s),this.placeMenu(s,e),(s.querySelector('[aria-checked="true"]:not(:disabled)')??s.querySelector("button:not(:disabled)"))?.focus({preventScroll:!0})}placeMenu(e,i){let s=i.getBoundingClientRect(),o=e.getBoundingClientRect(),r=window.innerWidth,c=window.innerHeight,d=i.classList.contains("wide")?s.left:s.right-o.width;d=Math.max(12,Math.min(d,r-o.width-12));let v=s.bottom+6;v+o.height>c-12&&s.top-o.height-6>12&&(v=s.top-o.height-6),Object.assign(e.style,{left:`${d}px`,top:`${v}px`})}closeMenu(){this.menu?.remove(),this.menuAnchor?.setAttribute("aria-expanded","false"),this.menu=null,this.menuAnchor=null}ask(e,i,s){return new Promise(o=>{if(!this.pop)return o(!1);this.closeMenu();let r=n("div",{class:"ask",role:"alertdialog","aria-modal":"true","aria-label":e}),c=g("btn",{},"",t.cancel),h=g("btn danger",{},"",s),d=v=>{this.asking=null,r.remove(),o(v)};c.addEventListener("click",()=>d(!1)),h.addEventListener("click",()=>d(!0)),r.addEventListener("mousedown",v=>v.target===r&&d(!1)),r.append(n("div",{class:"ask-card"},n("h3",{},e),n("p",{},i),n("div",{class:"ask-row"},c,h))),this.asking=()=>d(!1),this.pop.append(r),c.focus()})}paint(){if(!this.pop||!this.view)return;let e=this.view,i=this.layerRoot.activeElement?.getAttribute("data-key"),s=this.pop.querySelector(".body")?.scrollTop??0,o=n("div",{class:"body"}),r=g("icon muted",{"aria-label":t.close,title:t.close,"data-key":"close"},p.close);r.addEventListener("click",()=>this.close()),o.append(n("div",{class:"head"},n("h2",{},e.title||t.title),r)),o.append(n("div",{class:"label"},t.peopleWithAccess));let c=x.name??"";o.append(n("div",{class:"row"},n("div",{class:"avatar",style:`background:${$("local"+c)}`},T(c)),n("div",{class:"who"},n("div",{class:"name"},c,n("span",{class:"faint"},t.you)),n("div",{class:"sub"},t.thisComputer)),n("span",{class:"select static",html:`<span>${t.owner}</span>${p.chevron}`}))),o.append(n("div",{class:"label"},t.joinedPeople)),e.guests.length||o.append(n("div",{class:"empty"},t.none));for(let l of[...e.guests].sort((u,f)=>Number(f.online)-Number(u.online)||(f.seen??f.joined).localeCompare(u.seen??u.joined))){let u=l.online?t.online:l.active?t.seen(C(l.seen??l.joined)):t.paused,f=g("select",{"aria-haspopup":"menu","aria-expanded":"false","aria-label":t.changeRole(l.name),"data-key":`role-${l.id}`},"",t.roleNames[l.role],p.chevron);f.addEventListener("click",()=>this.openMenu(f,M.map(w=>({label:t.roleNames[w],sub:e.links[w].on?void 0:t.linkOff,checked:w===l.role,disabled:!e.links[w].on,run:()=>w!==l.role&&void this.refresh({action:"role",guest:l.id,role:w})}))));let b=g("icon muted",{"aria-label":`${t.remove} ${l.name}`,title:t.remove,"data-key":`rm-${l.id}`},p.trash);b.addEventListener("click",async()=>{await this.ask(t.removeTitle(l.name),t.removeText,t.remove)&&this.refresh({action:"remove",guest:l.id})}),o.append(n("div",{class:`row${l.active?"":" paused"}`},n("div",{class:`avatar${l.online?" on":""}`,style:`background:${$(l.id)}`},T(l.name)),n("div",{class:"who"},n("div",{class:"name"},l.name),n("div",{class:`sub${l.online?" on":""}`},u)),f,b))}o.append(n("div",{class:"label"},t.generalAccess));let h=e.lan?e.addresses.length?t.whereOn(e.addresses.map(l=>`${l}:${e.port}`).join(" \xB7 ")):t.noAddress:t.whereOff,d=g("select wide",{"aria-haspopup":"menu","aria-expanded":"false","data-key":"lan"},"",e.lan?t.onLan:t.onlyHere,p.chevron);d.addEventListener("click",()=>this.openMenu(d,[{label:t.onlyHere,sub:t.onlyHereNote,checked:!e.lan,run:()=>e.lan&&void this.refresh({action:"lan",on:!1})},{label:t.onLan,sub:t.onLanNote,checked:e.lan,run:()=>!e.lan&&void this.refresh({action:"lan",on:!0})}])),o.append(n("div",{class:"row"},n("div",{class:"circle",html:e.lan?p.network:p.lock}),n("div",{class:"who"},d,n("div",{class:"sub multi"},h)))),o.append(n("div",{class:"label"},t.inviteLinks));for(let l of M){let u=e.links[l],f;u.on?f=this.copyButton(l,u.url):(f=g("pill",{"data-key":`copy-${l}`},"",t.turnOn),f.addEventListener("click",()=>void this.refresh({action:"link",role:l,on:!0})));let b=g("icon muted",{"aria-haspopup":"menu","aria-expanded":"false","aria-label":`${t.more}: ${t.linkTitles[l]}`,title:t.more,"data-key":`more-${l}`},p.more);b.addEventListener("click",()=>this.openMenu(b,[u.on?{label:t.turnOffLink,sub:t.turnOffNote,run:()=>void this.refresh({action:"link",role:l,on:!1})}:{label:t.turnOnLink,run:()=>void this.refresh({action:"link",role:l,on:!0})},{label:t.resetLink,sub:t.resetNote,danger:!0,run:async()=>{await this.ask(t.resetTitle(t.linkTitles[l]),t.resetText,t.resetLink)&&this.refresh({action:"reset",role:l})}}])),o.append(n("div",{class:`row${u.on?"":" off"}`,title:u.on?u.url:""},n("div",{class:"circle",html:p[l]}),n("div",{class:"who"},n("div",{class:"name"},t.linkTitles[l]),n("div",{class:"sub"},u.on?t.roleNotes[l]:t.linkOffNote)),f,b))}this.error&&o.append(n("div",{class:"err",role:"alert"},this.error)),this.pop.replaceChildren(o),o.scrollTop=s,this.position(),((i?o.querySelector(`[data-key="${i}"]`):null)??r).focus({preventScroll:!0})}paintGuest(){if(!this.pop)return;let e=this.layerRoot.activeElement?.getAttribute("data-key"),i=n("div",{class:"body"}),s=g("icon muted",{"aria-label":t.close,title:t.close,"data-key":"close"},p.close);if(s.addEventListener("click",()=>this.close()),i.append(n("div",{class:"head"},n("h2",{},x.title||document.title||t.title),s)),this.invites?.length){i.append(n("div",{class:"label"},t.inviteLinks));for(let{role:r,url:c}of this.invites)i.append(n("div",{class:"row",title:c},n("div",{class:"circle",html:p[r]}),n("div",{class:"who"},n("div",{class:"name"},t.linkTitles[r]),n("div",{class:"sub"},t.roleNotes[r])),this.copyButton(r,c)));i.append(n("div",{class:"hint"},t.guestInviteNote),n("div",{class:"rule"}))}i.append(n("div",{class:"foot"},n("div",{class:"note"},t.onlyAccess),this.copyButton("page",location.origin+location.pathname))),this.error&&i.append(n("div",{class:"err",role:"alert"},this.error)),this.pop.replaceChildren(i),this.position(),((e?i.querySelector(`[data-key="${e}"]`):null)??s).focus({preventScroll:!0})}copyButton(e,i){let s=this.copied===e,o=g(`pill${s?" done":""}`,{"data-key":`copy-${e}`},s?p.check:p.link,s?t.copied:t.copyLink),r=()=>k?this.paint():this.paintGuest();return o.addEventListener("click",async()=>{await S(i),this.copied=e,r(),setTimeout(()=>{this.copied===e&&(this.copied=null,!this.menu&&!this.asking&&r())},1600)}),o}};function H(){let a=document.querySelector("[data-baoyu-share-seat]")??document.querySelector("[data-baoyu-comments]")?.shadowRoot?.querySelector("[data-baoyu-share-seat]");if(a)return["into",a,"header"];let e=document.querySelector('[data-testid="ldoc-comments-btn"]'),i=e?.closest(".ml-auto")??e?.parentElement?.parentElement;if(i)return["first",i,"header"];let s=document.querySelector("[data-baoyu-comments-seat]");if(s)return["before",s,"tool"];let o=document.querySelector("header.tb-root .tb-card-end");return o?["first",o,"bar"]:null}var R=()=>new L().mount();document.readyState==="loading"?document.addEventListener("DOMContentLoaded",R,{once:!0}):R();
83
+ `;function r(n,e={},...t){let i=document.createElement(n);for(let[o,s]of Object.entries(e))o==="class"?i.className=s:o==="html"?i.innerHTML=s:i.setAttribute(o,s);return i.append(...t),i}function m(n,e,t,i,o){let s=r("button",{class:n,type:"button",...e});return t&&s.insertAdjacentHTML("beforeend",t),i!==void 0&&s.append(r("span",{},i)),o&&s.insertAdjacentHTML("beforeend",o),s}async function G(n){try{await navigator.clipboard.writeText(n)}catch{let e=r("textarea",{style:"position:fixed;opacity:0"});e.value=n,document.body.append(e),e.select(),document.execCommand("copy"),e.remove()}}var a=y?{title:"\u7248\u672C\u5386\u53F2",close:"\u5173\u95ED",back:"\u8FD4\u56DE",empty:"\u8FD8\u6CA1\u6709\u7248\u672C\u3002",loading:"\u6B63\u5728\u8BFB\u53D6\u2026",today:"\u4ECA\u5929",yesterday:"\u6628\u5929",you:"\uFF08\u4F60\uFF09",claude:"Agent",claudeSub:"\u76F4\u63A5\u6539\u4E86\u8FD9\u53F0\u7535\u8111\u4E0A\u7684\u6587\u4EF6",start:"\u6700\u65E9\u7684\u6837\u5B50",startSub:"\u5386\u53F2\u4ECE\u8FD9\u91CC\u5F00\u59CB",current:"\u5F53\u524D\u7248\u672C",restoredFrom:n=>`\u6062\u590D\u81EA ${n} \u7684\u7248\u672C`,restoredPart:n=>`\u90E8\u5206\u6062\u590D\u81EA ${n} \u7684\u7248\u672C`,overwrote:n=>`\u8986\u76D6\u4E86 ${n} \u7684\u4FEE\u6539`,replaced:n=>`\u6362\u6389\u4E86 ${n} \u521A\u8BBE\u7684\u5185\u5BB9`,ops:{added:"\u65B0\u589E",edited:"\u4FEE\u6539",deleted:"\u5220\u9664"},more:n=>`\u7B49 ${n} \u5904`,changes:"\u770B\u6539\u52A8",preview:"\u9884\u89C8",restore:"\u6062\u590D\u5230\u8FD9\u4E2A\u7248\u672C",restoreTitle:"\u6062\u590D\u5230\u8FD9\u4E2A\u7248\u672C\uFF1F",restoreText:n=>`\u6240\u6709\u5185\u5BB9\u56DE\u5230 ${n} \u7684\u6837\u5B50\u3002\u73B0\u5728\u7684\u5185\u5BB9\u4F1A\u4F5C\u4E3A\u4E00\u4E2A\u7248\u672C\u7559\u5728\u5386\u53F2\u91CC\uFF0C\u968F\u65F6\u80FD\u518D\u6062\u590D\u56DE\u6765\u3002`,restoreOne:"\u53EA\u6062\u590D\u8FD9\u4E00\u5904",restoreOneTitle:"\u53EA\u6062\u590D\u8FD9\u4E00\u5904\uFF1F",restoreOneText:(n,e)=>`\u300C${n}\u300D\u56DE\u5230 ${e} \u7684\u6837\u5B50\uFF0C\u5176\u4ED6\u5185\u5BB9\u4E0D\u53D8\u3002\u73B0\u5728\u7684\u5185\u5BB9\u4F1A\u7559\u5728\u5386\u53F2\u91CC\u3002`,restoreGo:"\u6062\u590D",cancel:"\u53D6\u6D88",binary:"\u8FD9\u4E00\u5904\u4E0D\u662F\u6587\u672C\uFF0C\u770B\u4E0D\u4E86\u9010\u884C\u6539\u52A8\u3002\u53EF\u4EE5\u7528\u300C\u9884\u89C8\u300D\u770B\u90A3\u4E2A\u7248\u672C\u3002",tooLarge:"\u6539\u52A8\u592A\u5927\uFF0C\u8FD9\u91CC\u663E\u793A\u4E0D\u4E0B\u3002\u53EF\u4EE5\u7528\u300C\u9884\u89C8\u300D\u770B\u90A3\u4E2A\u7248\u672C\u3002",missing:"\u8FD9\u4E2A\u7248\u672C\u7684\u5185\u5BB9\u5DF2\u7ECF\u4E0D\u5728\u5386\u53F2\u91CC\u4E86\u3002",skipped:n=>`\u2026 ${n} \u884C\u6CA1\u53D8`,truncated:"\u540E\u9762\u8FD8\u6709\u6539\u52A8\uFF0C\u8FD9\u91CC\u53EA\u663E\u793A\u524D\u4E00\u90E8\u5206\u3002",noChange:"\u5185\u5BB9\u6CA1\u6709\u53D8\u5316\u3002",needsLook:"\u9700\u8981\u4F60\u770B\u4E00\u4E0B",overwritten:(n,e,t)=>`${n} \u4FDD\u5B58\u300C${e}\u300D\u65F6\uFF0C\u8986\u76D6\u4E86\u4F60 ${t} \u7684\u4FEE\u6539\u3002`,overwroteYou:(n,e,t)=>`\u4F60\u4FDD\u5B58\u300C${e}\u300D\u65F6\uFF0C\u8986\u76D6\u4E86 ${n} ${t} \u7684\u4FEE\u6539\u3002`,softOver:(n,e,t)=>`${n} \u7D27\u63A5\u7740\u4E5F\u6539\u4E86\u300C${e}\u300D\uFF0C\u6362\u6389\u4E86\u4F60 ${t} \u8BBE\u7684\u5185\u5BB9\u3002`,deletedBack:(n,e,t)=>`\u4F60 ${t} \u5220\u6389\u4E86\u300C${e}\u300D\uFF0C${n} \u53C8\u6539\u4E86\u5B83\uFF0C\u5B83\u56DE\u6765\u4E86\u3002`,removedOver:(n,e,t)=>`${n} \u5220\u6389\u4E86\u300C${e}\u300D\uFF0C\u4F60 ${t} \u7684\u4FEE\u6539\u4E5F\u8DDF\u7740\u6CA1\u4E86\u3002`,compare:"\u770B\u770B\u5DEE\u522B",bringBack:"\u627E\u56DE",bringBackTitle:"\u627E\u56DE\u88AB\u8986\u76D6\u7684\u5185\u5BB9\uFF1F",bringBackText:(n,e)=>`\u300C${n}\u300D\u6362\u56DE${e}\u88AB\u8986\u76D6\u524D\u7684\u5185\u5BB9\u3002\u73B0\u5728\u7684\u5185\u5BB9\u4F1A\u7559\u5728\u5386\u53F2\u91CC\u3002`,bringBackPart:(n,e)=>`\u300C${n}\u300D\u91CC\u88AB\u6362\u6389\u7684\u90E8\u5206\u6362\u56DE${e}\u7684\u5185\u5BB9\uFF0C\u522B\u7684\u6539\u52A8\u90FD\u7559\u7740\u3002\u73B0\u5728\u7684\u5185\u5BB9\u4F1A\u7559\u5728\u5386\u53F2\u91CC\u3002`,deleteAgain:"\u518D\u5220\u6389",deleteAgainTitle:"\u518D\u5220\u6389\u5B83\uFF1F",deleteAgainText:n=>`\u300C${n}\u300D\u4F1A\u518D\u5220\u6389\u4E00\u6B21\u3002\u73B0\u5728\u7684\u5185\u5BB9\u4F1A\u7559\u5728\u5386\u53F2\u91CC\u3002`,deleteLegend:"\u7EA2\u8272\u662F\u73B0\u5728\u7684\u5185\u5BB9\uFF0C\u518D\u5220\u6389\u540E\u5C31\u6CA1\u6709\u4E86\u3002",yours:"\u4F60",theirs:n=>` ${n} `,dismiss:"\u77E5\u9053\u4E86",later:"\u7A0D\u540E\u518D\u770B",legend:"\u7EA2\u8272\u662F\u73B0\u5728\u7684\u5185\u5BB9\uFF0C\u7EFF\u8272\u662F\u627E\u56DE\u540E\u7684\u5185\u5BB9\u3002",changedSince:"\u4F60\u770B\u7684\u65F6\u5019\u5185\u5BB9\u53C8\u53D8\u4E86\uFF0C\u4E0B\u9762\u662F\u73B0\u5728\u7684\u5BF9\u6BD4\u3002",namesNote:"\u540D\u5B57\u662F\u6BCF\u4E2A\u4EBA\u52A0\u5165\u65F6\u81EA\u5DF1\u586B\u7684\u3002\u300CAgent\u300D\u6307\u76F4\u63A5\u6539\u8FD9\u53F0\u7535\u8111\u4E0A\u6587\u4EF6\u7684\u6539\u52A8\uFF08Agent \u6216\u547D\u4EE4\u884C\uFF09\u3002",viewOnly:"\u4F60\u53EF\u4EE5\u770B\u5386\u53F2\uFF1B\u6062\u590D\u9700\u8981\u7F16\u8F91\u6743\u9650\u3002",bannerAt:(n,e)=>`\u6B63\u5728\u770B ${n} \u7684\u7248\u672C \xB7 ${e}`,bannerCurrent:"\u8FD9\u662F\u5F53\u524D\u7248\u672C",readOnly:"\u53EA\u8BFB",backToCurrent:"\u56DE\u5230\u5F53\u524D\u7248\u672C",restoreThis:"\u6062\u590D\u8FD9\u4E2A\u7248\u672C",done:{restored:"\u5DF2\u6062\u590D",brought:"\u5DF2\u627E\u56DE",deleted:"\u5DF2\u5220\u6389"},failed:"\u6CA1\u80FD\u5B8C\u6210\uFF1A"}:{title:"Version history",close:"Close",back:"Back",empty:"No versions yet.",loading:"Loading\u2026",today:"Today",yesterday:"Yesterday",you:" (you)",claude:"Agent",claudeSub:"changed the files on this computer",start:"Where it started",startSub:"The history starts here",current:"Current",restoredFrom:n=>`Restored from ${n}`,restoredPart:n=>`Partly restored from ${n}`,overwrote:n=>`Saved over ${n}'s change`,replaced:n=>`Replaced what ${n} had just set`,ops:{added:"Added",edited:"Edited",deleted:"Deleted"},more:n=>`+${n} more`,changes:"Changes",preview:"Preview",restore:"Restore this version",restoreTitle:"Restore this version?",restoreText:n=>`Everything goes back to how it was at ${n}. What is there now stays in the history as a version you can restore.`,restoreOne:"Restore just this",restoreOneTitle:"Restore just this part?",restoreOneText:(n,e)=>`\u201C${n}\u201D goes back to how it was at ${e}; nothing else changes. What is there now stays in the history.`,restoreGo:"Restore",cancel:"Cancel",binary:"This part is not text, so there are no line changes to show. Preview shows that version.",tooLarge:"Too many changes to show here. Preview shows that version.",missing:"This version\u2019s content is no longer in the history.",skipped:n=>`\u2026 ${n} unchanged lines`,truncated:"There are more changes than shown here.",noChange:"No changes to the content.",needsLook:"Needs a look",overwritten:(n,e,t)=>`${n} saved \u201C${e}\u201D over your change from ${t}.`,overwroteYou:(n,e,t)=>`You saved \u201C${e}\u201D over ${n}\u2019s change from ${t}.`,softOver:(n,e,t)=>`${n} changed \u201C${e}\u201D right after you and replaced what you set at ${t}.`,deletedBack:(n,e,t)=>`You deleted \u201C${e}\u201D at ${t}; ${n} changed it, so it is back.`,removedOver:(n,e,t)=>`${n} deleted \u201C${e}\u201D, and your change from ${t} with it.`,compare:"Compare",bringBack:"Bring back",bringBackTitle:"Bring back what was saved over?",bringBackText:(n,e)=>`\u201C${n}\u201D goes back to ${e} content from before it was saved over. What is there now stays in the history.`,bringBackPart:(n,e)=>`What was replaced in \u201C${n}\u201D goes back to ${e} content; the other changes stay. What is there now stays in the history.`,deleteAgain:"Delete again",deleteAgainTitle:"Delete it again?",deleteAgainText:n=>`\u201C${n}\u201D is deleted again. What is there now stays in the history.`,deleteLegend:"Red is what is there now; deleting it again removes it.",yours:"your",theirs:n=>`${n}\u2019s`,dismiss:"Dismiss",later:"Later",legend:"Red is what is there now; green is what bringing it back restores.",changedSince:"This changed while you were looking. Here is how it compares now.",namesNote:"Names are what each person typed when they joined. \u201CAgent\u201D is a change made to the files on this computer (by the agent or the command line).",viewOnly:"You can read the history; restoring needs edit access.",bannerAt:(n,e)=>`Viewing the version from ${n} \xB7 ${e}`,bannerCurrent:"This is the current version",readOnly:"Read-only",backToCurrent:"Back to current",restoreThis:"Restore this version",done:{restored:"Restored",brought:"Brought back",deleted:"Deleted"},failed:"Could not do that: "},R={history:w('<path d="M2.6 8a5.4 5.4 0 1 0 1.6-3.8"/><path d="M2.4 2.6v2.6H5"/><path d="M8 5.2V8l1.9 1.3"/>',16),close:w('<path d="M4 4l8 8M12 4l-8 8"/>',18),back:w('<path d="M9.8 3.6 5.4 8l4.4 4.4"/>',18),robot:w(j,16),flag:w('<path d="M4 13.8V2.6M4 3h7.2l-1.6 2.6L11.2 8.2H4"/>',15)},U=`
84
+ .wrap.seat { display: inline-flex; align-items: center; gap: 2px; }
85
+ .open.only { padding: 0; width: 28px; justify-content: center; }
86
+ .open.bar.only { width: 24px; }
87
+ .open.float.only { width: 32px; }
88
+ .open.only .dot { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; }
89
+ .open.tool.only .dot { top: 2px; right: 2px; width: 5px; height: 5px; }
90
+ `,he=`
91
+ .ver { display: flex; gap: 12px; margin: 0 -10px; padding: 8px 10px; border-radius: 12px; cursor: pointer; }
92
+ .ver:hover, .ver.opened { background: var(--soft); }
93
+ .ver .who { display: flex; flex-direction: column; gap: 2px; }
94
+ .top { display: flex; align-items: baseline; gap: 8px; }
95
+ .top .name { flex: 1; min-width: 0; font-weight: 500; }
96
+ .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; flex: none; }
97
+ .avatar.small { width: 30px; height: 30px; font-size: 12px; margin-top: 1px; }
98
+ .avatar.agent { background: #c96442; }
99
+ .avatar.start { background: var(--hover); color: var(--muted); }
100
+ .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
101
+ .badge { font-size: 11.5px; line-height: 18px; padding: 0 8px; border-radius: 999px; background: var(--hover); color: var(--muted); white-space: nowrap; }
102
+ .badge.cur { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
103
+ .badge.warn { background: color-mix(in srgb, #d97706 17%, transparent); color: #a65a06; }
104
+ @media (prefers-color-scheme: dark) { .badge.warn { color: #f2a65a; } }
105
+ .files { margin-top: 6px; display: flex; flex-direction: column; gap: 1px; }
106
+ .file { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: 13px; }
107
+ .file .op { flex: none; font-size: 11.5px; color: var(--muted); min-width: 30px; }
108
+ .file .op.added { color: var(--ok); }
109
+ .file .op.deleted { color: var(--danger); }
110
+ .file .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
111
+ .link { flex: none; border: 0; background: transparent; color: var(--check); font-size: 12.5px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
112
+ .link:hover { background: var(--hover); }
113
+ .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
114
+ .btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
115
+ .btn.primary { background: var(--fg); color: var(--bg); }
116
+ .btn.primary:hover { background: var(--fg); filter: brightness(1.15); }
117
+ .ver.opened .btn:not(.primary), .notice .btn:not(.primary) { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
118
+ .ver.opened .btn:not(.primary):hover, .notice .btn:not(.primary):hover { background: var(--soft); }
119
+ .notice { border: 1px solid color-mix(in srgb, #d97706 30%, var(--line)); background: color-mix(in srgb, #d97706 6%, var(--bg)); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
120
+ .notice p { margin: 0; font-size: 13.5px; }
121
+ .notice .when { display: block; margin-top: 2px; }
122
+ .hint.note { color: #a65a06; }
123
+ @media (prefers-color-scheme: dark) { .hint.note { color: #f2a65a; } }
124
+ .dhead { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
125
+ .dhead h2 { font-size: 16px; }
126
+ .tally { font-size: 12.5px; white-space: nowrap; }
127
+ .tally .a { color: var(--ok); }
128
+ .tally .r { color: var(--danger); margin-left: 6px; }
129
+ .diff { margin: 12px -20px -20px; border-top: 1px solid var(--line); padding: 6px 0 10px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
130
+ .dl { display: flex; padding-right: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
131
+ .dl .k { width: 26px; flex: none; text-align: center; color: var(--faint); user-select: none; }
132
+ .dl.add { background: color-mix(in srgb, var(--ok) 13%, transparent); }
133
+ .dl.add .k { color: var(--ok); }
134
+ .dl.del { background: color-mix(in srgb, var(--danger) 11%, transparent); }
135
+ .dl.del .k { color: var(--danger); }
136
+ .dl mark { color: inherit; border-radius: 3px; }
137
+ .dl.add mark { background: color-mix(in srgb, var(--ok) 32%, transparent); }
138
+ .dl.del mark { background: color-mix(in srgb, var(--danger) 28%, transparent); }
139
+ .dl.skip { color: var(--muted); padding: 3px 26px; font-family: inherit; }
140
+ .note { color: var(--muted); font-size: 12.5px; margin-top: 16px; }
141
+ .toast { position: fixed; right: 16px; bottom: 16px; z-index: 2147483003; width: min(380px, calc(100vw - 32px)); background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; }
142
+ .toast p { margin: 0; font-size: 13.5px; }
143
+ .toast.plain { width: auto; padding: 10px 16px; }
144
+ .banner { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2147482500; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); padding: 6px 6px 6px 16px; border-radius: 999px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow); font-size: 13px; }
145
+ .banner .text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
146
+ .banner .ro { opacity: .65; white-space: nowrap; }
147
+ .banner .btn { height: 28px; padding: 0 12px; font-size: 12.5px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 16%, transparent); color: var(--bg); white-space: nowrap; }
148
+ .banner .btn:hover { background: color-mix(in srgb, var(--bg) 26%, transparent); }
149
+ .banner .btn.primary { background: var(--bg); color: var(--fg); }
150
+ @media (max-width: 560px) { .banner { left: 12px; right: 12px; transform: none; border-radius: 16px; flex-wrap: wrap; padding: 10px 12px; } .banner .text { white-space: normal; flex-basis: 100%; } }
151
+ `,x=n=>y?n.zh:n.en;function B(n){let e=new Date(n),t=new Date,i=s=>new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),o=Math.round((i(t)-i(e))/864e5);return o===0?a.today:o===1?a.yesterday:e.toLocaleDateString(y?"zh-CN":"en",{month:"short",day:"numeric",...e.getFullYear()===t.getFullYear()?{}:{year:"numeric"}})}var P=n=>new Date(n).toLocaleTimeString(y?"zh-CN":"en",{hour:"2-digit",minute:"2-digit"}),M=n=>`${B(n)} ${P(n)}`,ue=n=>P(n.first)===P(n.at)?P(n.at):`${P(n.first)}\u2013${P(n.at)}`;async function A(n,e){let t=await fetch(n,e===void 0?{cache:"no-store"}:{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),i=await t.json().catch(()=>null);if(!t.ok){let o=i;throw Object.assign(new Error(o?.message??`HTTP ${t.status}`),{code:o?.code})}return i}var I=class{button=r("button",{class:"open float only",type:"button","aria-haspopup":"dialog","aria-expanded":"false","aria-label":a.title,title:a.title});boot;look="float";layer=r("div",{"data-baoyu-history-layer":""});layerRoot=this.layer.attachShadow({mode:"open"});layerWrap=r("div",{class:"wrap"});pop=null;caret=r("div",{class:"caret"});toastNode=null;toastTimer;asking=null;data=null;screen={kind:"list"};opened=new Set;diff=null;error="";timer;toasted=new Set;busy=!1;constructor(e){this.boot=e,this.layerRoot.append(r("style",{},E+he),this.layerWrap),this.button.insertAdjacentHTML("beforeend",R.history),this.button.addEventListener("click",()=>this.pop?this.close():void this.open()),document.body.append(this.layer),e.preview?this.banner(e.preview):e.canRestore&&this.watchNotices()}setLook(e){this.look=e,this.button.className=`open ${e} only${this.button.classList.contains("has")?" has":""}`}async open(){this.pop||(this.hideToast(),this.screen={kind:"list"},this.pop=r("div",{class:"pop",role:"dialog","aria-label":a.title}),this.layerWrap.append(this.pop,this.caret),this.button.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",this.onPointer,!0),window.addEventListener("keydown",this.onKey,!0),window.addEventListener("resize",this.position),window.addEventListener("scroll",this.position,!0),this.paint(),await this.refresh(),this.timer=window.setInterval(()=>void this.refresh(),4e3))}close(){window.clearInterval(this.timer),document.removeEventListener("mousedown",this.onPointer,!0),window.removeEventListener("keydown",this.onKey,!0),window.removeEventListener("resize",this.position),window.removeEventListener("scroll",this.position,!0),this.asking=null,this.pop?.remove(),this.pop=null,this.caret.remove(),this.button.setAttribute("aria-expanded","false"),this.button.focus()}position=()=>{if(!this.pop)return;let e=window.innerWidth,t=window.innerHeight,i=this.button.getBoundingClientRect(),o=i.width>0&&i.bottom>0&&i.top<t,s=Math.min(480,e-24),c=o?i.right:e-16,l=Math.max(12,Math.min(c-s,e-s-12)),d=o?i.bottom+10:56;if(Object.assign(this.pop.style,{left:`${l}px`,top:`${d}px`,width:`${s}px`,maxHeight:`${Math.max(240,t-d-12)}px`}),o){let u=Math.max(l+18,Math.min(i.left+i.width/2-7,l+s-32));Object.assign(this.caret.style,{display:"",left:`${u}px`,top:`${d-7}px`})}else this.caret.style.display="none"};onPointer=e=>{let t=e.composedPath();!this.pop||t.includes(this.pop)||t.includes(this.button)||this.close()};onKey=e=>{e.key==="Escape"&&(e.stopPropagation(),e.preventDefault(),this.asking?this.asking():this.screen.kind==="diff"?this.go({kind:"list"}):this.close())};async refresh(){let e=JSON.stringify([this.data,this.error]);try{this.data=await A(`${this.boot.base}__history`),this.error=""}catch(t){this.error=a.failed+t.message}this.mark(this.data?.notices.length??0),!(this.asking||this.busy||this.pop?.firstChild&&JSON.stringify([this.data,this.error])===e)&&this.screen.kind==="list"&&this.paint()}mark(e){this.button.classList.toggle("has",e>0),this.button.querySelector(".dot")?.remove(),e>0&&this.button.append(r("span",{class:"dot",style:"background:#d97706"}))}go(e){this.screen=e,this.diff=null,this.paint(),e.kind==="diff"&&A(e.url).then(t=>{this.screen===e&&(this.diff=t,this.paint())},t=>{this.screen===e&&(this.error=a.failed+t.message,this.paint())})}async act(e,t,i){this.busy=!0;try{return await A(e,t),this.error="",this.toast(i),this.boot.preview?(location.href=this.boot.preview.current_url,!0):(this.screen={kind:"list"},await this.refresh(),this.paint(),!0)}catch(o){return o.code==="changed"&&this.screen.kind==="diff"?(this.error="",this.go({...this.screen,note:a.changedSince}),!1):(this.error=a.failed+o.message,this.paint(),!1)}finally{this.busy=!1}}restore(e,t){let i=M(e.at),o=t?e.files.find(s=>s.path===t):void 0;this.ask(o?a.restoreOneTitle:a.restoreTitle,o?a.restoreOneText(x(o.label),i):a.restoreText(i),a.restoreGo).then(s=>s&&this.act(`${this.boot.base}__history/${e.n}/restore`,t?{paths:[t]}:{},a.done.restored))}bringBack(e){let t=e.kind==="overwritten"?a.yours:a.theirs(e.lostBy==="agent"?a.claude:e.lostName),i=e.part?a.bringBackPart:a.bringBackText,o=this.screen.kind==="diff"&&this.screen.notice?.id===e.id&&this.diff&&"now"in this.diff?{now:this.diff.now}:{},s=c=>l=>l&&this.act(`${this.boot.base}__history/notice/${e.id}/recover`,o,c);e.deleted?this.ask(a.deleteAgainTitle,a.deleteAgainText(x(e.label)),a.deleteAgain).then(s(a.done.deleted)):this.ask(a.bringBackTitle,i(x(e.label),t),a.bringBack).then(s(a.done.brought))}async dismiss(e){try{let{notices:t}=await A(`${this.boot.base}__history/notices`,{dismiss:e.id});this.data&&(this.data.notices=t),this.mark(t.length)}catch(t){this.error=a.failed+t.message}this.screen.kind==="diff"&&(this.screen={kind:"list"}),this.paint()}ask(e,t,i){return new Promise(o=>{if(!this.pop)return o(!1);let s=r("div",{class:"ask",role:"alertdialog","aria-modal":"true","aria-label":e}),c=m("btn",{},"",a.cancel),l=m("btn primary",{},"",i),d=u=>{this.asking=null,s.remove(),o(u)};c.addEventListener("click",()=>d(!1)),l.addEventListener("click",()=>d(!0)),s.addEventListener("mousedown",u=>u.target===s&&d(!1)),s.append(r("div",{class:"ask-card"},r("h3",{},e),r("p",{},t),r("div",{class:"ask-row"},c,l))),this.asking=()=>d(!1),this.pop.append(s),l.focus()})}paint(){if(!this.pop)return;let e=this.pop.querySelector(".body")?.scrollTop??0,t=r("div",{class:"body"});this.screen.kind==="diff"?this.paintDiff(t,this.screen):this.paintList(t),this.error&&t.append(r("div",{class:"err",role:"alert"},this.error)),this.pop.replaceChildren(t),this.screen.kind==="list"&&(t.scrollTop=e),this.position()}paintList(e){let t=m("icon muted",{"aria-label":a.close,title:a.close},R.close);t.addEventListener("click",()=>this.close()),e.append(r("div",{class:"head"},r("h2",{},a.title),t));let i=this.data;if(!i){e.append(r("div",{class:"empty"},a.loading));return}if(i.notices.length){e.append(r("div",{class:"label"},a.needsLook));for(let s of i.notices)e.append(this.noticeCard(s,i.canRestore))}i.rows.length||e.append(r("div",{class:"empty"},a.empty));let o="";for(let s of i.rows){let c=B(s.at);c!==o&&(o=c,e.append(r("div",{class:"label"},c))),e.append(this.versionRow(s,i))}e.append(r("div",{class:"note"},i.canRestore?a.namesNote:`${a.viewOnly} ${a.namesNote}`))}who(e,t){if(e.by==="agent")return{name:a.claude,avatar:r("div",{class:"avatar small agent",html:R.robot})};if(e.by==="system")return{name:a.start,avatar:r("div",{class:"avatar small start",html:R.flag})};let i=e.userId===t;return{name:`${e.name}${i?a.you:""}`,avatar:r("div",{class:"avatar small",style:`background:${S(e.userId??e.name)}`},T(e.name))}}versionRow(e,t){let{name:i,avatar:o}=this.who(e,t.me),s=this.opened.has(e.n),c=e.files.map(g=>e.by==="system"||g.op==="edited"?x(g.label):`${a.ops[g.op]} ${x(g.label)}`),l=e.by==="system"&&!s?a.startSub:c.length>3?`${c.slice(0,3).join(y?"\u3001":", ")} ${a.more(c.length-3)}`:c.join(y?"\u3001":", "),d=r("div",{class:"badges"});if(e.current&&d.append(r("span",{class:"badge cur"},a.current)),e.restoredFrom!==void 0){let g=t.rows.find(L=>L.n===e.restoredFrom),b=g?M(g.at):`#${e.restoredFrom}`;d.append(r("span",{class:"badge"},e.restoredPart?a.restoredPart(b):a.restoredFrom(b)))}for(let g of e.overwrote??[])d.append(r("span",{class:"badge warn",title:x(g.label)},g.soft?a.replaced(g.by==="agent"?a.claude:g.name):a.overwrote(g.by==="agent"?a.claude:g.name)));let u=r("div",{class:"who"},r("div",{class:"top"},r("span",{class:"name"},i),r("span",{class:"when"},ue(e))),...s?[]:[r("div",{class:"sub"},e.by==="agent"&&!c.length?a.claudeSub:l)],...d.childElementCount?[d]:[]),h=r("div",{class:`ver${s?" opened":""}`,role:"button",tabindex:"0","aria-expanded":String(s)},o,u),f=g=>{g.target.closest("button")||(s?this.opened.delete(e.n):this.opened.add(e.n),this.paint())};if(h.addEventListener("click",f),h.addEventListener("keydown",g=>(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),f(g))),s){let g=r("div",{class:"files"});for(let $ of e.files){let q=m("link",{},"",a.changes);q.addEventListener("click",()=>this.go({kind:"diff",url:`${this.boot.base}__history/${e.n}/diff?path=${encodeURIComponent($.path)}`,title:x($.label),sub:`${i} \xB7 ${M(e.at)}`,...t.canRestore&&!e.current?{restore:{n:e.n,path:$.path,when:M(e.at)}}:{}})),g.append(r("div",{class:"file"},r("span",{class:`op ${$.op}`},a.ops[$.op]),r("span",{class:"fname",title:x($.label)},x($.label)),q))}u.append(g);let b=r("div",{class:"actions"}),L=m("btn small",{},"",a.preview);if(L.addEventListener("click",()=>window.open(e.preview,"_blank","noopener")),b.append(L),t.canRestore&&!e.current){let $=m("btn small primary",{},"",a.restore);$.addEventListener("click",()=>this.restore(e)),b.append($)}u.append(b)}return h}noticeText(e){let t=e.lostAt??e.at,i=B(t)===a.today?P(t):M(t);if(e.kind==="overwrote")return a.overwroteYou(e.lostBy==="agent"?a.claude:e.lostName,x(e.label),i);let o=e.by==="agent"?a.claude:e.name;return e.deleted?a.deletedBack(o,x(e.label),i):e.removed?a.removedOver(o,x(e.label),i):e.soft?a.softOver(o,x(e.label),i):a.overwritten(o,x(e.label),i)}noticeScreen(e){return{kind:"diff",url:`${this.boot.base}__history/notice/${e.id}/diff`,title:x(e.label),sub:this.noticeText(e),legend:e.deleted?a.deleteLegend:a.legend,notice:e}}noticeCard(e,t){let i=m("btn small",{},"",a.compare);i.addEventListener("click",()=>this.go(this.noticeScreen(e)));let o=m("btn small",{},"",a.dismiss);o.addEventListener("click",()=>void this.dismiss(e));let s=r("div",{class:"actions"},i);if(t){let c=m("btn small primary",{},"",e.deleted?a.deleteAgain:a.bringBack);c.addEventListener("click",()=>this.bringBack(e)),s.append(c)}return s.append(o),r("div",{class:"notice"},r("p",{},this.noticeText(e)),r("span",{class:"when"},M(e.at)),s)}paintDiff(e,t){let i=m("icon muted",{"aria-label":a.back,title:a.back},R.back);i.addEventListener("click",()=>this.go({kind:"list"}));let o=m("icon muted",{"aria-label":a.close,title:a.close},R.close);o.addEventListener("click",()=>this.close());let s=this.diff,c=s&&!s.binary&&!s.tooLarge&&!s.missing?r("span",{class:"tally"},r("span",{class:"a"},`+${s.added}`),r("span",{class:"r"},`\u2212${s.removed}`)):null;e.append(r("div",{class:"dhead"},i,r("h2",{},t.title),...c?[c]:[],o)),e.append(r("div",{class:"sub multi"},t.sub)),t.legend&&e.append(r("div",{class:"hint"},t.legend)),t.note&&e.append(r("div",{class:"hint note"},t.note));let l=r("div",{class:"actions"});if(t.restore){let h=t.restore,f=m("btn small primary",{},"",a.restoreOne);f.addEventListener("click",()=>{let g=this.data?.rows.find(b=>b.n===h.n);g&&this.restore(g,h.path)}),l.append(f)}if(t.notice){let h=t.notice;if(this.data?.canRestore){let g=m("btn small primary",{},"",h.deleted?a.deleteAgain:a.bringBack);g.addEventListener("click",()=>this.bringBack(h)),l.append(g)}let f=m("btn small",{},"",a.dismiss);f.addEventListener("click",()=>void this.dismiss(h)),l.append(f)}if(l.childElementCount&&e.append(l),!s){e.append(r("div",{class:"empty"},a.loading));return}if(s.missing||s.binary||s.tooLarge){e.append(r("div",{class:"empty"},s.missing?a.missing:s.binary?a.binary:a.tooLarge));return}if(!s.lines.some(([h])=>h==="+"||h==="-")){e.append(r("div",{class:"empty"},a.noChange));return}let d=r("div",{class:"diff"}),u=ge(s.lines);s.lines.forEach(([h,f],g)=>{if(h==="~"){d.append(r("div",{class:"dl skip"},a.skipped(f)));return}let b=u.get(g),L=b?r("span",{},f.slice(0,b[0]),r("mark",{},f.slice(b[0],b[1])),f.slice(b[1])):r("span",{},f||" ");d.append(r("div",{class:`dl${h==="+"?" add":h==="-"?" del":""}`},r("span",{class:"k"},h===" "?"":h==="-"?"\u2212":"+"),L))}),s.truncated&&d.append(r("div",{class:"dl skip"},a.truncated)),e.append(d)}watchNotices(){let e=async()=>{if(!document.hidden)try{let{notices:t}=await A(`${this.boot.base}__history/notices`);if(this.mark(t.length),this.pop)return;let i=t.find(o=>!this.toasted.has(o.id));for(let o of t)this.toasted.add(o.id);i&&this.noticeToast(i)}catch{}};e(),window.setInterval(()=>void e(),5e3)}noticeToast(e){this.hideToast();let t=m("btn small primary",{},"",a.compare);t.addEventListener("click",()=>{this.hideToast(),this.open().then(()=>{let c=this.data?.notices.find(l=>l.id===e.id)??e;this.go(this.noticeScreen(c))})});let i=m("btn small",{},"",a.later);i.addEventListener("click",()=>this.hideToast());let o=m("icon muted",{"aria-label":a.close,title:a.close,style:"margin:-6px -6px 0 0"},R.close);o.addEventListener("click",()=>this.hideToast());let s=r("div",{class:"toast",role:"status"},r("div",{class:"head"},r("p",{style:"flex:1"},this.noticeText(e)),o),r("div",{class:"actions"},t,i));this.toastNode=s,this.layerWrap.append(s)}toast(e){this.hideToast();let t=r("div",{class:"toast plain",role:"status"},r("p",{},e));this.toastNode=t,this.layerWrap.append(t),this.toastTimer=window.setTimeout(()=>this.hideToast(),2400)}hideToast(){window.clearTimeout(this.toastTimer),this.toastNode?.remove(),this.toastNode=null}banner(e){let t=e.by==="agent"?a.claude:e.by==="system"?a.start:e.name,i=r("div",{class:"banner",role:"status"},r("span",{class:"text"},e.current?a.bannerCurrent:a.bannerAt(M(e.at),t)),r("span",{class:"ro"},`\xB7 ${a.readOnly}`));if(this.boot.canRestore&&!e.current){let s=m("btn primary",{},"",a.restoreThis);s.addEventListener("click",async()=>{await this.open();let c=this.data?.rows.find(l=>l.n===e.n);c&&this.restore(c)}),i.append(s)}let o=m("btn",{},"",a.backToCurrent);o.addEventListener("click",()=>location.href=e.current_url),i.append(o),this.layerWrap.append(i)}};function ge(n){let e=new Map;for(let t=0;t<n.length;){if(n[t][0]!=="-"){t++;continue}let i=t;for(;i<n.length&&n[i][0]==="-";)i++;let o=i;for(;o<n.length&&n[o][0]==="+";)o++;if(o-i===i-t)for(let s=0;s<i-t;s++){let c=n[t+s][1],l=n[i+s][1],d=0;for(;d<c.length&&d<l.length&&c[d]===l[d];)d++;let u=0;for(;u<c.length-d&&u<l.length-d&&c[c.length-1-u]===l[l.length-1-u];)u++;d+u<Math.min(c.length,l.length)*.3||(e.set(t+s,[d,c.length-u]),e.set(i+s,[d,l.length-u]))}t=o}return e}function X(){let n=window.__baoyuHistory;return n&&typeof n.base=="string"?new I(n):null}var Te=Object.freeze([]);function Q(n){let e=!1,t=()=>{e||(e=!0,n())};typeof requestAnimationFrame=="function"&&typeof document<"u"&&document.visibilityState==="visible"&&requestAnimationFrame(t),setTimeout(t,typeof document<"u"&&document.visibilityState==="visible"?100:16)}var C=["#785ee8","#dc3c3d","#019c7f","#fbb315","#ce447d","#10a122","#257de0","#d25f25"],D="#d25f25",fe=3e4,Z=5*6e4,me=5e3,W=3,v=y?{here:"\u6B64\u523B\u5728\u8FD9\u91CC",nobody:"\u53EA\u6709\u4F60\u5728\u770B",agent:"Agent",changed:n=>`\u521A\u6539\u4E86${n}`,slide:(n,e)=>`\u7B2C ${n} \u9875${e?` \xB7 ${e}`:""}`,board:n=>`\u5728\u300C${n}\u300D`,canvas:"\u5728\u753B\u5E03\u4E0A",presenting:"\u6B63\u5728\u653E\u6620",overview:"\u5728\u770B\u5168\u90E8\u9875\u9762",editing:"\u6B63\u5728\u7F16\u8F91",idle:"\u4E00\u4F1A\u513F\u6CA1\u52A8\u4E86",open:"\u5F00\u7740\u8FD9\u4E00\u9875",go:"\u8DF3\u5230\u8FD9\u4E00\u9875",hintEdit:n=>`${n} \u6B63\u5728\u6539\u8FD9\u4E00\u9875`,hintEditBoard:(n,e)=>`${n} \u6B63\u5728\u6539\u300C${e}\u300D`,hintAgent:"Agent \u521A\u6539\u4E86\u8FD9\u4E00\u9875",more:n=>`\u8FD8\u6709 ${n} \u4EBA`,roles:{owner:"\u6240\u6709\u8005",editor:"\u53EF\u7F16\u8F91",commenter:"\u53EF\u8BC4\u8BBA",viewer:"\u53EF\u67E5\u770B"},note:"\u6709\u4EBA\u6539\u4F60\u6B63\u5728\u770B\u7684\u5730\u65B9\u65F6\u4F1A\u63D0\u9192\u4F60\uFF0C\u4E0D\u4F1A\u9501\u4F4F\u3002"}:{here:"Here now",nobody:"Only you",agent:"Agent",changed:n=>`Just changed ${n}`,slide:(n,e)=>`Slide ${n}${e?` \xB7 ${e}`:""}`,board:n=>`On ${n}`,canvas:"On the canvas",presenting:"Presenting",overview:"Looking at all slides",editing:"editing",idle:"idle",open:"Has this open",go:"Go to this slide",hintEdit:n=>`${n} is editing this slide`,hintEditBoard:(n,e)=>`${n} is editing ${e}`,hintAgent:"Agent just changed this slide",more:n=>`${n} more`,roles:{owner:"Owner",editor:"Can edit",commenter:"Can comment",viewer:"Can view"},note:"You get a note when someone edits what you are looking at. Nothing is locked."},ee={robot:w(j,12),go:w('<path d="M6 3.8 10.2 8 6 12.2"/>',14)},ie=`
152
+ .av { position: relative; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 600; letter-spacing: .01em; line-height: 1; }
153
+ .av svg { width: 60%; height: 60%; }
154
+ .av.idle { opacity: .45; }
155
+ .av.editing::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); opacity: .55; }
156
+ `,oe=ie+`
157
+ .peers { padding: 0 4px; gap: 0; }
158
+ .peers[hidden] { display: none; }
159
+ .peers .stack { display: inline-flex; align-items: center; }
160
+ .peers .av { width: 22px; height: 22px; font-size: 10.5px; margin-left: -6px; box-shadow: 0 0 0 2px var(--ring, #fff); }
161
+ .peers .av:first-child { margin-left: 0; }
162
+ .peers.bar .av { width: 20px; height: 20px; font-size: 10px; }
163
+ .peers.float { padding: 0 8px; }
164
+ .open.peers.tool { width: auto; min-width: 24px; padding: 0 1px; }
165
+ .peers .plus { margin-left: 4px; font-size: 12px; color: inherit; opacity: .7; }
166
+ @media (prefers-color-scheme: dark) { .peers .av { box-shadow: 0 0 0 2px var(--ring, #262624); } }
167
+ `,ve=`
168
+ .peer { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; border: 0; background: transparent; margin: 0 -10px; padding: 7px 10px; border-radius: 12px; width: calc(100% + 20px); }
169
+ button.peer:hover { background: var(--soft); }
170
+ .peer .av { width: 30px; height: 30px; font-size: 12px; }
171
+ .peer .who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
172
+ .peer .role { color: var(--muted); font-weight: 400; font-size: 12.5px; margin-left: 6px; }
173
+ .peer .sub .on { color: var(--ok); }
174
+ .peer .go { color: var(--muted); }
175
+ .hint-note { position: fixed; z-index: 2147483000; max-width: min(320px, calc(100vw - 24px)); display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; animation: hint-in .16s ease-out; }
176
+ .hint-note .av { width: 22px; height: 22px; font-size: 10.5px; }
177
+ @keyframes hint-in { from { opacity: 0; transform: translateY(-4px); } }
178
+ `,H=n=>{let e=n.presence.context;return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null},N=n=>typeof n=="string"?n:typeof n=="object"&&n!==null&&typeof n.text=="string"?n.text:"",be=n=>{let e=n.presence.who,t=typeof e?.c=="string"?e.c.toLowerCase():"";if(C.includes(t)&&(n.kind==="agent"||t!==D))return t;if(n.kind==="agent")return D;let i=0;for(let s=0;s<n.by.length;s++)i=i*31+n.by.charCodeAt(s)>>>0;let o=i%C.length;return C[o]===D&&(o=(o+1)%C.length),C[o]},we=n=>{let[e=0,t=0,i=0]=[1,3,5].map(o=>{let s=parseInt(n.slice(o,o+2),16)/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4});return 1.05/(.2126*e+.7152*t+.0722*i+.05)<3?"#0b0b0b":"#ffffff"},V=(n,e)=>{if(n.agent||e-n.at>fe)return!1;let t=H(n.latest);if(!t||t.mode!==void 0&&t.mode!=="edit"&&t.mode!=="focused"&&t.mode!=="canvas")return!1;let i=t.selection;return Array.isArray(i)?i.length>0:Array.isArray(t.selected)&&t.selected.length>0},re=(n,e)=>{let t=n[e];return Array.isArray(t)?t.filter(i=>typeof i=="string"):[]},se=n=>{let e=Array.isArray(n.selected)?n.selected.find(t=>typeof t=="string"&&t.includes("#")):void 0;return e?e.slice(0,e.indexOf("#")):re(n,"selectedArtboards")[0]??""},te=n=>{let e=n.replace(/\.dc\.html$/,"");try{e=decodeURIComponent(e)}catch{}return e.slice(e.lastIndexOf("/")+1)||e},ae=n=>typeof n.page=="string"?n.page:"",ne=n=>{let e=n&&H(n);if(!e)return null;if(typeof e.slideId=="string"&&e.slideId)return`slide:${e.slideId}`;if(Array.isArray(e.visibleArtboards)){let t=se(e);return t?`board:${ae(e)}:${t}`:null}return null},ye=n=>{let e=n&&H(n);return e?typeof e.slideId=="string"&&e.slideId?new Set([`slide:${e.slideId}`]):new Set(re(e,"visibleArtboards").map(t=>`board:${ae(e)}:${t}`)):new Set},Y=class{node=r("button",{class:"open peers float",type:"button","aria-haspopup":"dialog","aria-expanded":"false",hidden:""});presence=null;people=[];seen=new Map;look="float";layer=r("div",{"data-baoyu-presence-layer":""});layerRoot=this.layer.attachShadow({mode:"open"});layerWrap=r("div",{class:"wrap"});pop=null;caret=r("div",{class:"caret"});hint=null;hintTimer;hinted=new Map;frame=!1;constructor(){this.layerRoot.append(r("style",{},E+ie+ve),this.layerWrap),this.node.addEventListener("click",()=>this.pop?this.close():this.open());let e=()=>{let t=window.__baoyuPresence;!t||t===this.presence||(this.presence=t,t.subscribe(()=>this.schedule()),this.schedule())};e(),window.addEventListener("baoyu-presence",e),window.setInterval(()=>this.schedule(),5e3)}setLook(e){this.look=e,this.node.className=`open peers ${e}`}schedule(){this.frame||(this.frame=!0,Q(()=>{this.frame=!1,this.update()}))}update(){let e=this.presence;if(!e)return;let t=Date.now(),i=e.peers(),o=new Set;for(let l of i){o.add(l.peer);let d=JSON.stringify(l.presence),u=this.seen.get(l.peer);(!u||u.json!==d)&&this.seen.set(l.peer,{json:d,at:t})}for(let l of this.seen.keys())o.has(l)||this.seen.delete(l);let s=new Map;for(let l of i){let d=l.kind==="agent";if(!d&&l.by===e.me.by)continue;let u=d?"agent":l.by,h=this.seen.get(l.peer)?.at??t,f=s.get(u);f&&f.at>=h||s.set(u,{key:u,name:d?v.agent:l.name||"?",role:l.role??"",agent:d,color:be(l),latest:l,at:h})}this.people=[...s.values()].sort((l,d)=>Number(d.agent)-Number(l.agent)||d.at-l.at);let c=i.find(l=>l.peer===e.me.peer);this.paintSeat(t),this.pop&&this.paintList(t),this.checkHint(ye(c),t)}avatar(e,t,i=""){let o=!e.agent&&t-e.at>Z,s=V(e,t),c=r("span",{class:`av${o?" idle":""}${s?" editing":""}${i?` ${i}`:""}`,style:`background:${e.color};color:${we(e.color)};--c:${e.color}`});return e.agent?c.innerHTML=ee.robot:c.textContent=T(e.name),c}paintSeat(e){let t=this.people;if(this.node.hidden=t.length===0,!t.length){this.pop&&this.close();return}let i=r("span",{class:"stack"});for(let c of t.slice(0,W))i.append(this.avatar(c,e));this.node.replaceChildren(i),t.length>W&&this.node.append(r("span",{class:"plus"},`+${t.length-W}`));let o=t.map(c=>c.name),s=`${v.here}: ${o.slice(0,5).join(y?"\u3001":", ")}${o.length>5?y?` ${v.more(o.length-5)}`:`, ${v.more(o.length-5)}`:""}`;this.node.setAttribute("aria-label",s),this.node.title=s}whereOf(e,t){let i=e.latest,o=H(i),s=typeof o?.slideId=="string"?o.slideId:"",c=s?document.querySelector(`[role="option"][data-slide-id="${CSS.escape(s)}"]`):null;if(e.agent){let u=i.presence.where,h=typeof(y?u?.zh:u?.en)=="string"?String(y?u.zh:u.en):"";return{text:h?v.changed(h):v.open,editing:!1,slide:c}}let l=V(e,t),d="";if(o?.mode==="present")d=v.presenting;else if(o?.mode==="grid")d=v.overview;else if(typeof o?.slideIndex=="number"&&o.slideIndex>0)d=v.slide(o.slideIndex,N(o.slideTitle));else if(o&&Array.isArray(o.visibleArtboards)){let u=se(o);d=u?v.board(te(u)):N(o.pageName)?v.board(N(o.pageName)):v.canvas}else N(o?.pageName)?d=v.board(N(o?.pageName)):d=v.open;return!l&&t-e.at>Z&&(d+=` \xB7 ${v.idle}`),{text:d,editing:l,slide:o?.mode==="present"?null:c}}open(){this.pop||!this.people.length||(this.pop=r("div",{class:"pop",role:"dialog","aria-label":v.here}),this.layer.isConnected||document.body.append(this.layer),this.layerWrap.append(this.pop,this.caret),this.node.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",this.onPointer,!0),window.addEventListener("keydown",this.onKey,!0),window.addEventListener("resize",this.position),window.addEventListener("scroll",this.position,!0),this.paintList(Date.now()))}close(){document.removeEventListener("mousedown",this.onPointer,!0),window.removeEventListener("keydown",this.onKey,!0),window.removeEventListener("resize",this.position),window.removeEventListener("scroll",this.position,!0),this.pop?.remove(),this.pop=null,this.caret.remove(),this.node.setAttribute("aria-expanded","false")}paintList(e){if(!this.pop)return;let t=r("div",{class:"body"},r("div",{class:"head"},r("h2",{},v.here)));this.people.length||t.append(r("div",{class:"empty"},v.nobody));for(let i of this.people){let o=this.whereOf(i,e),s=r("div",{class:"sub"},o.text);o.editing&&s.append(" \xB7 ",r("span",{class:"on"},v.editing));let c=r("div",{class:"name"},i.name),l=i.agent?"":v.roles[i.role]??"";l&&c.append(r("span",{class:"role"},l));let d=r("div",{class:"who"},c,s),u=o.slide?r("button",{class:"peer",type:"button",title:v.go}):r("div",{class:"peer"});if(u.append(this.avatar(i,e),d),o.slide){let h=o.slide;u.insertAdjacentHTML("beforeend",`<span class="go">${ee.go}</span>`),u.addEventListener("click",()=>{h.click(),h.scrollIntoView({block:"nearest"}),this.close()})}t.append(u)}this.presence?.peers().some(i=>i.kind!=="agent"&&H(i))&&t.append(r("div",{class:"hint"},v.note)),this.pop.replaceChildren(t),this.position()}position=()=>{if(!this.pop)return;let e=window.innerWidth,t=window.innerHeight,i=this.node.getBoundingClientRect(),o=i.width>0&&i.bottom>0&&i.top<t,s=Math.min(320,e-24),c=o?i.right+40:e-16,l=Math.max(12,Math.min(c-s,e-s-12)),d=o?i.bottom+10:56;if(Object.assign(this.pop.style,{left:`${l}px`,top:`${d}px`,width:`${s}px`,maxHeight:`${Math.max(200,t-d-12)}px`}),o){let u=Math.max(l+18,Math.min(i.left+i.width/2-7,l+s-32));Object.assign(this.caret.style,{display:"",left:`${u}px`,top:`${d-7}px`})}else this.caret.style.display="none"};onPointer=e=>{let t=e.composedPath();!this.pop||t.includes(this.pop)||t.includes(this.node)||this.close()};onKey=e=>{e.key==="Escape"&&(e.stopPropagation(),e.preventDefault(),this.close(),this.node.focus())};checkHint(e,t){for(let i of this.hinted.keys())this.people.some(o=>o.key===i&&ne(o.latest)===this.hinted.get(i))||this.hinted.delete(i);if(e.size)for(let i of this.people){let o=ne(i.latest);if(!(!o||!e.has(o)||this.hinted.get(i.key)===o)&&!(!i.agent&&!V(i,t))){this.hinted.set(i.key,o),this.showHint(i,t,o);return}}}showHint(e,t,i){window.clearTimeout(this.hintTimer),this.hint?.remove();let o=this.node.getBoundingClientRect();if(!o.width)return;this.layer.isConnected||document.body.append(this.layer);let s=r("div",{class:"hint-note",role:"status"},this.avatar(e,t),r("span",{},e.agent?v.hintAgent:i.startsWith("board:")?v.hintEditBoard(e.name,te(i.slice(i.indexOf(":",6)+1))):v.hintEdit(e.name)));this.layerWrap.append(s);let c=s.getBoundingClientRect().width;Object.assign(s.style,{top:`${o.bottom+10}px`,left:`${Math.max(12,Math.min(o.right-c,window.innerWidth-c-12))}px`}),this.hint=s,this.hintTimer=window.setTimeout(()=>{s.remove(),this.hint===s&&(this.hint=null)},me)}};function le(){return new Y}var O=window.__baoyuShare??{},_=O.role==="owner",z=O.noun??{en:"artifact",zh:"\u5185\u5BB9",zhThis:"\u8FD9\u4EFD\u5185\u5BB9"},de=["editor","commenter","viewer"],p=y?{share:"\u5206\u4EAB",title:`\u5206\u4EAB${z.zhThis}`,close:"\u5173\u95ED",peopleWithAccess:"\u6709\u6743\u8BBF\u95EE\u7684\u4EBA",joinedPeople:"\u52A0\u5165\u7684\u4EBA",generalAccess:"\u4E00\u822C\u8BBF\u95EE\u6743\u9650",inviteLinks:"\u9080\u8BF7\u94FE\u63A5",you:"\uFF08\u4F60\uFF09",thisComputer:"\u8FD9\u53F0\u7535\u8111",owner:"\u6240\u6709\u8005",roleNames:{editor:"\u7F16\u8F91\u8005",commenter:"\u8BC4\u8BBA\u8005",viewer:"\u67E5\u770B\u8005"},linkTitles:{editor:"\u53EF\u7F16\u8F91",commenter:"\u53EF\u8BC4\u8BBA",viewer:"\u4EC5\u67E5\u770B"},roleNotes:{editor:"\u7F16\u8F91\u548C\u8BC4\u8BBA",commenter:O.reactions?"\u8BC4\u8BBA\u548C\u8868\u60C5\u56DE\u5E94\uFF0C\u4E0D\u80FD\u7F16\u8F91":"\u8BC4\u8BBA\uFF0C\u4E0D\u80FD\u7F16\u8F91",viewer:"\u53EA\u80FD\u770B"},changeRole:n=>`\u66F4\u6539\u300C${n}\u300D\u7684\u89D2\u8272`,linkOff:"\u94FE\u63A5\u5DF2\u5173\u95ED",online:"\u5728\u7EBF",seen:n=>`${n}\u6765\u8FC7`,paused:"\u94FE\u63A5\u5DF2\u5173\u95ED\uFF0C\u6682\u65F6\u65E0\u6CD5\u8BBF\u95EE",none:"\u8FD8\u6CA1\u6709\u4EBA\u52A0\u5165\u3002\u628A\u4E0B\u9762\u7684\u94FE\u63A5\u53D1\u7ED9\u5BF9\u65B9\u3002",remove:"\u79FB\u51FA",removeTitle:n=>`\u79FB\u51FA\u300C${n}\u300D\uFF1F`,removeText:`\u5BF9\u65B9\u5C06\u65E0\u6CD5\u518D\u8BBF\u95EE${z.zhThis}\uFF0C\u4E4B\u540E\u4ECD\u53EF\u4EE5\u7528\u94FE\u63A5\u91CD\u65B0\u52A0\u5165\u3002`,onlyHere:"\u4EC5\u8FD9\u53F0\u7535\u8111",onlyHereNote:"\u522B\u4EBA\u6253\u4E0D\u5F00\u8FD9\u4E9B\u94FE\u63A5\u3002",onLan:"\u540C\u4E00\u7F51\u7EDC\u91CC\u6709\u94FE\u63A5\u7684\u4EBA",onLanNote:"\u540C\u4E00 Wi-Fi \u6216\u5C40\u57DF\u7F51\u91CC\u7684\u4EBA\u7528\u94FE\u63A5\u6253\u5F00\uFF0C\u62FF\u5230\u54EA\u4E2A\u94FE\u63A5\u5C31\u662F\u54EA\u4E2A\u89D2\u8272\u3002",whereOff:"\u53EA\u6709\u8FD9\u53F0\u7535\u8111\u80FD\u6253\u5F00\u8FD9\u4E9B\u94FE\u63A5\u3002",whereOn:n=>`\u5C40\u57DF\u7F51\u5730\u5740\uFF1A${n}`,noAddress:"\u8FD9\u53F0\u7535\u8111\u6CA1\u6709\u5C40\u57DF\u7F51\u5730\u5740\u3002",copyLink:"\u590D\u5236\u94FE\u63A5",onlyAccess:"\u53EA\u6709\u6709\u6743\u8BBF\u95EE\u7684\u4EBA\u624D\u80FD\u6253\u5F00\u8FD9\u4E2A\u94FE\u63A5",guestInviteNote:"\u540C\u4E00\u7F51\u7EDC\u91CC\u7684\u4EBA\u6253\u5F00\u94FE\u63A5\uFF0C\u5C31\u4EE5\u8FD9\u4E2A\u89D2\u8272\u52A0\u5165\u3002\u6240\u6709\u8005\u80FD\u770B\u5230\u8C01\u52A0\u5165\u4E86\uFF0C\u53EF\u4EE5\u6539\u89D2\u8272\u6216\u79FB\u51FA\u3002",copied:"\u5DF2\u590D\u5236",turnOn:"\u5F00\u542F",more:"\u66F4\u591A",linkOffNote:"\u5DF2\u5173\u95ED\uFF0C\u6CA1\u4EBA\u80FD\u7528\u5B83\u52A0\u5165",turnOnLink:"\u5F00\u542F\u94FE\u63A5",turnOffLink:"\u5173\u95ED\u94FE\u63A5",turnOffNote:"\u7528\u5B83\u52A0\u5165\u7684\u4EBA\u6682\u65F6\u65E0\u6CD5\u8BBF\u95EE",resetLink:"\u91CD\u7F6E\u94FE\u63A5",resetNote:"\u6362\u4E00\u4E2A\u65B0\u5730\u5740\uFF0C\u7528\u65E7\u94FE\u63A5\u52A0\u5165\u7684\u4EBA\u4F1A\u88AB\u79FB\u51FA",resetTitle:n=>`\u91CD\u7F6E\u300C${n}\u300D\u94FE\u63A5\uFF1F`,resetText:"\u65E7\u94FE\u63A5\u4F1A\u5931\u6548\uFF0C\u901A\u8FC7\u5B83\u52A0\u5165\u7684\u4EBA\u4E5F\u4F1A\u5931\u53BB\u8BBF\u95EE\u6743\u9650\u3002",cancel:"\u53D6\u6D88",failed:"\u6CA1\u80FD\u5B8C\u6210\uFF1A"}:{share:"Share",title:`Share this ${z.en}`,close:"Close",peopleWithAccess:"People with access",joinedPeople:"People who joined",generalAccess:"General access",inviteLinks:"Invite links",you:" (you)",thisComputer:"This computer",owner:"Owner",roleNames:{editor:"Editor",commenter:"Commenter",viewer:"Viewer"},linkTitles:{editor:"Can edit",commenter:"Can comment",viewer:"Can view"},roleNotes:{editor:"Edit and comment",commenter:O.reactions?"Comment and react, no edits":"Comment, no edits",viewer:"Read only"},changeRole:n=>`Change ${n}'s role`,linkOff:"Link off",online:"Online",seen:n=>`Seen ${n}`,paused:"Link off: no access until it is back on",none:"Nobody has joined yet. Send someone a link below.",remove:"Remove",removeTitle:n=>`Remove ${n}?`,removeText:`They lose access to this ${z.en}. They can join again with a link.`,onlyHere:"Only this computer",onlyHereNote:"Nobody else can open the links.",onLan:"Anyone on your network with a link",onLanNote:"People on the same Wi-Fi or LAN open it with a link; the link sets their role.",whereOff:"Only this computer can open these links.",whereOn:n=>`On this network at ${n}`,noAddress:"This computer has no local network address.",copyLink:"Copy link",onlyAccess:"Only people with access can open this link",guestInviteNote:"Whoever on your network opens one joins in that role. The owner sees who joined and can change or remove them.",copied:"Copied",turnOn:"Turn on",more:"More",linkOffNote:"Off: nobody can join with it",turnOnLink:"Turn on link",turnOffLink:"Turn off link",turnOffNote:"Whoever joined with it loses access until it is back on",resetLink:"Reset link",resetNote:"A new address; whoever joined with the old one is removed",resetTitle:n=>`Reset the "${n}" link?`,resetText:"The old link stops working and the people who joined with it lose access.",cancel:"Cancel",failed:"Could not do that: "},k={share:w('<circle cx="4" cy="8" r="2"/><circle cx="12" cy="3.5" r="2"/><circle cx="12" cy="12.5" r="2"/><path d="M5.8 7 10.2 4.5M5.8 9l4.4 2.5"/>',16),close:w('<path d="M4 4l8 8M12 4l-8 8"/>',18),chevron:w('<path d="M4.5 6.2 8 9.7l3.5-3.5"/>',14),check:w('<path d="M3 8.6 6.3 11.8 13 4.6"/>',18),trash:w('<path d="M2.6 4.2h10.8M6.3 4.2V2.7h3.4v1.5M4 4.2l.7 9.1h6.6l.7-9.1M6.7 6.7v4.2M9.3 6.7v4.2"/>',17),link:w('<path d="M6.8 9.2a2.5 2.5 0 0 0 3.5 0l2.3-2.3a2.5 2.5 0 0 0-3.5-3.5l-.8.8M9.2 6.8a2.5 2.5 0 0 0-3.5 0L3.4 9.1a2.5 2.5 0 0 0 3.5 3.5l.8-.8"/>',15),more:'<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><circle cx="3.5" cy="8" r="1.25"/><circle cx="8" cy="8" r="1.25"/><circle cx="12.5" cy="8" r="1.25"/></svg>',lock:w('<rect x="3.5" y="7" width="9" height="6.5" rx="1.6"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>',17),network:w('<path d="M1.8 6.3a9 9 0 0 1 12.4 0M4 8.7a5.8 5.8 0 0 1 8 0M6.3 11a2.5 2.5 0 0 1 3.4 0"/><circle cx="8" cy="13.2" r=".5" fill="currentColor"/>',17),editor:w('<path d="M10.4 2.9 13.1 5.6 5.9 12.8l-3.3.6.6-3.3z"/><path d="M9.1 4.2l2.7 2.7"/>',16),commenter:w('<path d="M3 3h10a1.2 1.2 0 0 1 1.2 1.2v5.6A1.2 1.2 0 0 1 13 11H7.2l-3.2 2.6V11H3a1.2 1.2 0 0 1-1.2-1.2V4.2A1.2 1.2 0 0 1 3 3z"/>',16),viewer:w('<path d="M1.5 8S3.9 3.6 8 3.6 14.5 8 14.5 8 12.1 12.4 8 12.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="2"/>',16)};async function ce(n){let e=await fetch("/__share",n?{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}:{cache:"no-store"}),t=await e.json();if(!e.ok)throw new Error(t?.message??`HTTP ${e.status}`);return t}var F=class{host=r("span",{"data-baoyu-share":""});root=this.host.attachShadow({mode:"open"});wrap=r("div",{class:"wrap seat"});button=r("button",{class:"open float",type:"button","aria-haspopup":"dialog","aria-expanded":"false"});history=X();presence=le();look="float";layer=r("div",{"data-baoyu-share-layer":""});layerRoot=this.layer.attachShadow({mode:"open"});layerWrap=r("div",{class:"wrap"});pop=null;caret=r("div",{class:"caret"});menu=null;menuAnchor=null;menuJustClosed=null;asking=null;view=null;invites=null;error="";timer;copied=null;constructor(){this.root.append(r("style",{},E+U+oe),this.wrap),this.layerRoot.append(r("style",{},E),this.layerWrap),this.wrap.append(this.presence.node),this.history&&this.wrap.append(this.history.button),this.wrap.append(this.button),this.button.addEventListener("click",()=>this.pop?this.close():void this.open()),this.paintButton(),_&&ce().then(e=>{this.view=e,this.paintButton()},()=>{})}mount(){let e=()=>{let t=xe();if(!t){this.host.isConnected||(this.host.style.cssText="position:fixed;top:10px;right:120px;z-index:2147482000",document.body.append(this.host),this.setLook("float"));return}let[i,o,s]=t;i==="into"&&this.host.parentNode!==o&&o.append(this.host),i==="first"&&o.firstChild!==this.host&&o.prepend(this.host),i==="before"&&o.previousSibling!==this.host&&o.before(this.host),this.host.style.cssText="display:inline-flex;align-items:center",this.setLook(s),this.pop&&this.position()};e(),new MutationObserver(e).observe(document.body,{childList:!0,subtree:!0}),window.setInterval(e,1500)}setLook(e){e!==this.look&&(this.look=e,this.button.className=`open ${e}`,this.history?.setLook(e),this.presence.setLook(e),this.paintButton())}paintButton(){let e=_&&!!this.view?.lan;this.button.innerHTML=k.share,this.look==="tool"?(this.button.setAttribute("aria-label",p.share),this.button.title=e?`${p.share} \xB7 ${p.onLan}`:p.share):(this.button.removeAttribute("aria-label"),this.button.removeAttribute("title"),this.button.append(p.share)),e&&this.button.append(r("span",{class:"dot",title:p.onLan}))}async open(){if(this.pop)return;this.pop=r("div",{class:"pop",role:"dialog","aria-label":p.title}),this.layerWrap.append(this.pop,this.caret),document.body.append(this.layer),this.button.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",this.onPointer,!0),window.addEventListener("keydown",this.onKey,!0),window.addEventListener("resize",this.position),window.addEventListener("scroll",this.position,!0),this.position();let e=_?()=>this.refresh():()=>this.refreshInvites();_||this.paintGuest(),await e(),this.timer=window.setInterval(()=>void e(),4e3)}close(){window.clearInterval(this.timer),document.removeEventListener("mousedown",this.onPointer,!0),window.removeEventListener("keydown",this.onKey,!0),window.removeEventListener("resize",this.position),window.removeEventListener("scroll",this.position,!0),this.closeMenu(),this.asking=null,this.pop?.remove(),this.pop=null,this.caret.remove(),this.layer.remove(),this.button.setAttribute("aria-expanded","false"),this.button.focus()}position=()=>{if(!this.pop)return;let e=window.innerWidth,t=window.innerHeight,i=this.button.getBoundingClientRect(),o=i.width>0&&i.bottom>0&&i.top<t,s=Math.min(460,e-24),c=o?i.right:e-16,l=Math.max(12,Math.min(c-s,e-s-12)),d=o?i.bottom+10:56;if(Object.assign(this.pop.style,{left:`${l}px`,top:`${d}px`,width:`${s}px`,maxHeight:`${Math.max(240,t-d-12)}px`}),o){let u=Math.max(l+18,Math.min(i.left+i.width/2-7,l+s-32));Object.assign(this.caret.style,{display:"",left:`${u}px`,top:`${d-7}px`})}else this.caret.style.display="none";this.menu&&this.menuAnchor&&this.placeMenu(this.menu,this.menuAnchor)};onPointer=e=>{let t=e.composedPath();this.menu&&!t.includes(this.menu)&&(this.menuJustClosed=this.menuAnchor,this.closeMenu(),setTimeout(()=>this.menuJustClosed=null,0)),!(!this.pop||t.includes(this.pop)||t.includes(this.button)||this.menu&&t.includes(this.menu))&&this.close()};onKey=e=>{if(e.key==="Escape")if(e.stopPropagation(),e.preventDefault(),this.asking)this.asking();else if(this.menu){let t=this.menuAnchor;this.closeMenu(),t?.focus()}else this.close()};async refresh(e){let t=JSON.stringify([this.view,this.error]);try{this.view=await ce(e),this.error=""}catch(i){this.error=p.failed+i.message}this.paintButton(),!(!e&&(this.menu||this.asking||this.pop?.firstChild&&JSON.stringify([this.view,this.error])===t))&&this.paint()}async refreshInvites(){let e=JSON.stringify([this.invites,this.error]);try{let t=await fetch("/__share/invite",{cache:"no-store"}),i=await t.json();if(!t.ok)throw new Error(i?.message??`HTTP ${t.status}`);this.invites=i.links,this.error=""}catch(t){this.error=p.failed+t.message}JSON.stringify([this.invites,this.error])!==e&&this.paintGuest()}openMenu(e,t){if(this.menuJustClosed===e)return;this.closeMenu();let i=r("div",{class:"menu",role:"menu"});for(let o of t){let s=r("button",{class:`item${o.danger?" danger":""}`,type:"button",role:o.checked===void 0?"menuitem":"menuitemradio"});o.checked!==void 0&&s.setAttribute("aria-checked",String(o.checked)),s.disabled=o.disabled===!0,s.append(r("span",{class:"who"},r("span",{class:"name"},o.label),...o.sub?[r("span",{class:"sub"},o.sub)]:[])),o.checked!==void 0&&s.append(r("span",{class:"tick",html:o.checked?k.check:""})),s.addEventListener("click",()=>{this.closeMenu(),e.focus({preventScroll:!0}),o.run()}),i.append(s)}i.addEventListener("keydown",o=>{let s=[...i.querySelectorAll("button:not(:disabled)")],c=s.indexOf(this.layerRoot.activeElement),l=d=>s[(d+s.length)%s.length]?.focus();if(o.key==="ArrowDown")l(c+1);else if(o.key==="ArrowUp")l(c-1);else if(o.key==="Home")l(0);else if(o.key==="End")l(-1);else if(o.key==="Tab")this.closeMenu();else return;o.preventDefault()}),this.menu=i,this.menuAnchor=e,e.setAttribute("aria-expanded","true"),this.layerWrap.append(i),this.placeMenu(i,e),(i.querySelector('[aria-checked="true"]:not(:disabled)')??i.querySelector("button:not(:disabled)"))?.focus({preventScroll:!0})}placeMenu(e,t){let i=t.getBoundingClientRect(),o=e.getBoundingClientRect(),s=window.innerWidth,c=window.innerHeight,d=t.classList.contains("wide")?i.left:i.right-o.width;d=Math.max(12,Math.min(d,s-o.width-12));let u=i.bottom+6;u+o.height>c-12&&i.top-o.height-6>12&&(u=i.top-o.height-6),Object.assign(e.style,{left:`${d}px`,top:`${u}px`})}closeMenu(){this.menu?.remove(),this.menuAnchor?.setAttribute("aria-expanded","false"),this.menu=null,this.menuAnchor=null}ask(e,t,i){return new Promise(o=>{if(!this.pop)return o(!1);this.closeMenu();let s=r("div",{class:"ask",role:"alertdialog","aria-modal":"true","aria-label":e}),c=m("btn",{},"",p.cancel),l=m("btn danger",{},"",i),d=u=>{this.asking=null,s.remove(),o(u)};c.addEventListener("click",()=>d(!1)),l.addEventListener("click",()=>d(!0)),s.addEventListener("mousedown",u=>u.target===s&&d(!1)),s.append(r("div",{class:"ask-card"},r("h3",{},e),r("p",{},t),r("div",{class:"ask-row"},c,l))),this.asking=()=>d(!1),this.pop.append(s),c.focus()})}paint(){if(!this.pop||!this.view)return;let e=this.view,t=this.layerRoot.activeElement?.getAttribute("data-key"),i=this.pop.querySelector(".body")?.scrollTop??0,o=r("div",{class:"body"}),s=m("icon muted",{"aria-label":p.close,title:p.close,"data-key":"close"},k.close);s.addEventListener("click",()=>this.close()),o.append(r("div",{class:"head"},r("h2",{},e.title||p.title),s)),o.append(r("div",{class:"label"},p.peopleWithAccess));let c=O.name??"";o.append(r("div",{class:"row"},r("div",{class:"avatar",style:`background:${S("local"+c)}`},T(c)),r("div",{class:"who"},r("div",{class:"name"},c,r("span",{class:"faint"},p.you)),r("div",{class:"sub"},p.thisComputer)),r("span",{class:"select static",html:`<span>${p.owner}</span>${k.chevron}`}))),o.append(r("div",{class:"label"},p.joinedPeople)),e.guests.length||o.append(r("div",{class:"empty"},p.none));for(let h of[...e.guests].sort((f,g)=>Number(g.online)-Number(f.online)||(g.seen??g.joined).localeCompare(f.seen??f.joined))){let f=h.online?p.online:h.active?p.seen(K(h.seen??h.joined)):p.paused,g=m("select",{"aria-haspopup":"menu","aria-expanded":"false","aria-label":p.changeRole(h.name),"data-key":`role-${h.id}`},"",p.roleNames[h.role],k.chevron);g.addEventListener("click",()=>this.openMenu(g,de.map(L=>({label:p.roleNames[L],sub:e.links[L].on?void 0:p.linkOff,checked:L===h.role,disabled:!e.links[L].on,run:()=>L!==h.role&&void this.refresh({action:"role",guest:h.id,role:L})}))));let b=m("icon muted",{"aria-label":`${p.remove} ${h.name}`,title:p.remove,"data-key":`rm-${h.id}`},k.trash);b.addEventListener("click",async()=>{await this.ask(p.removeTitle(h.name),p.removeText,p.remove)&&this.refresh({action:"remove",guest:h.id})}),o.append(r("div",{class:`row${h.active?"":" paused"}`},r("div",{class:`avatar${h.online?" on":""}`,style:`background:${S(h.id)}`},T(h.name)),r("div",{class:"who"},r("div",{class:"name"},h.name),r("div",{class:`sub${h.online?" on":""}`},f)),g,b))}o.append(r("div",{class:"label"},p.generalAccess));let l=e.lan?e.addresses.length?p.whereOn(e.addresses.map(h=>`${h}:${e.port}`).join(" \xB7 ")):p.noAddress:p.whereOff,d=m("select wide",{"aria-haspopup":"menu","aria-expanded":"false","data-key":"lan"},"",e.lan?p.onLan:p.onlyHere,k.chevron);d.addEventListener("click",()=>this.openMenu(d,[{label:p.onlyHere,sub:p.onlyHereNote,checked:!e.lan,run:()=>e.lan&&void this.refresh({action:"lan",on:!1})},{label:p.onLan,sub:p.onLanNote,checked:e.lan,run:()=>!e.lan&&void this.refresh({action:"lan",on:!0})}])),o.append(r("div",{class:"row"},r("div",{class:"circle",html:e.lan?k.network:k.lock}),r("div",{class:"who"},d,r("div",{class:"sub multi"},l)))),o.append(r("div",{class:"label"},p.inviteLinks));for(let h of de){let f=e.links[h],g;f.on?g=this.copyButton(h,f.url):(g=m("pill",{"data-key":`copy-${h}`},"",p.turnOn),g.addEventListener("click",()=>void this.refresh({action:"link",role:h,on:!0})));let b=m("icon muted",{"aria-haspopup":"menu","aria-expanded":"false","aria-label":`${p.more}: ${p.linkTitles[h]}`,title:p.more,"data-key":`more-${h}`},k.more);b.addEventListener("click",()=>this.openMenu(b,[f.on?{label:p.turnOffLink,sub:p.turnOffNote,run:()=>void this.refresh({action:"link",role:h,on:!1})}:{label:p.turnOnLink,run:()=>void this.refresh({action:"link",role:h,on:!0})},{label:p.resetLink,sub:p.resetNote,danger:!0,run:async()=>{await this.ask(p.resetTitle(p.linkTitles[h]),p.resetText,p.resetLink)&&this.refresh({action:"reset",role:h})}}])),o.append(r("div",{class:`row${f.on?"":" off"}`,title:f.on?f.url:""},r("div",{class:"circle",html:k[h]}),r("div",{class:"who"},r("div",{class:"name"},p.linkTitles[h]),r("div",{class:"sub"},f.on?p.roleNotes[h]:p.linkOffNote)),g,b))}this.error&&o.append(r("div",{class:"err",role:"alert"},this.error)),this.pop.replaceChildren(o),o.scrollTop=i,this.position(),((t?o.querySelector(`[data-key="${t}"]`):null)??s).focus({preventScroll:!0})}paintGuest(){if(!this.pop)return;let e=this.layerRoot.activeElement?.getAttribute("data-key"),t=r("div",{class:"body"}),i=m("icon muted",{"aria-label":p.close,title:p.close,"data-key":"close"},k.close);if(i.addEventListener("click",()=>this.close()),t.append(r("div",{class:"head"},r("h2",{},O.title||document.title||p.title),i)),this.invites?.length){t.append(r("div",{class:"label"},p.inviteLinks));for(let{role:s,url:c}of this.invites)t.append(r("div",{class:"row",title:c},r("div",{class:"circle",html:k[s]}),r("div",{class:"who"},r("div",{class:"name"},p.linkTitles[s]),r("div",{class:"sub"},p.roleNotes[s])),this.copyButton(s,c)));t.append(r("div",{class:"hint"},p.guestInviteNote),r("div",{class:"rule"}))}t.append(r("div",{class:"foot"},r("div",{class:"note"},p.onlyAccess),this.copyButton("page",location.origin+location.pathname))),this.error&&t.append(r("div",{class:"err",role:"alert"},this.error)),this.pop.replaceChildren(t),this.position(),((e?t.querySelector(`[data-key="${e}"]`):null)??i).focus({preventScroll:!0})}copyButton(e,t){let i=this.copied===e,o=m(`pill${i?" done":""}`,{"data-key":`copy-${e}`},i?k.check:k.link,i?p.copied:p.copyLink),s=()=>_?this.paint():this.paintGuest();return o.addEventListener("click",async()=>{await G(t),this.copied=e,s(),setTimeout(()=>{this.copied===e&&(this.copied=null,!this.menu&&!this.asking&&s())},1600)}),o}};function xe(){let n=document.querySelector("[data-baoyu-share-seat]")??document.querySelector("[data-baoyu-comments]")?.shadowRoot?.querySelector("[data-baoyu-share-seat]");if(n)return["into",n,"header"];let e=document.querySelector('[data-testid="ldoc-comments-btn"]'),t=e?.closest(".ml-auto")??e?.parentElement?.parentElement;if(t)return["first",t,"header"];let i=document.querySelector("[data-baoyu-comments-seat]");if(i)return["before",i,"tool"];let o=document.querySelector("header.tb-root .tb-card-end");return o?["first",o,"bar"]:null}var pe=()=>new F().mount();document.readyState==="loading"?document.addEventListener("DOMContentLoaded",pe,{once:!0}):pe();