@celljs/ta-rooms 4.17.0 → 4.19.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.
Files changed (3) hide show
  1. package/host/index.mjs +82 -18
  2. package/package.json +12 -12
  3. package/web/index.js +1002 -370
package/web/index.js CHANGED
@@ -161,6 +161,16 @@ var RelayIdentityUtil;
161
161
  // ../ta-relay/esm/common/relay-protocol.js
162
162
  var RELAY_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' https: data: blob:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; media-src https: data: blob:; connect-src 'none'; form-action 'none'";
163
163
  var RELAY_FRAME_HEADER_CSP = `${RELAY_FRAME_CSP}; frame-ancestors 'self'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox`;
164
+ var OPEN_IN_TA = `<p><a id="open" style="display:inline-block;padding:10px 18px;border-radius:20px;background:#111;color:#fff;text-decoration:none;font-weight:600">Open in Ta · 在 Ta 中打开</a></p>
165
+ <script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script>`;
166
+ var RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
167
+ <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
168
+ <h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
169
+ <p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p>${OPEN_IN_TA}</body>`;
170
+ var RELAY_SHARE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
171
+ <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
172
+ <h1>Ta</h1><p>Someone shared an extension of Ta. Scan the code in the Ta app, or paste this link in its Quick open, to open it.</p>
173
+ <p>有人分享了一个 Ta 扩展。在 Ta 应用里扫码,或把这个链接粘贴到“快捷打开”,就能打开它。</p>${OPEN_IN_TA}</body>`;
164
174
  var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
165
175
  var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
166
176
  var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
@@ -331,6 +341,28 @@ ${d}`, s)) {
331
341
  RelayHubUtil2.openAnswer = openAnswer;
332
342
  })(RelayHubUtil || (RelayHubUtil = {}));
333
343
 
344
+ // ../ta-web/esm/browser/extension/share-sheet-compat.js
345
+ function ShareSheetCompat({ pi, ...props }) {
346
+ const h = pi.React.createElement;
347
+ if (pi.ui.ShareSheet) {
348
+ return h(pi.ui.ShareSheet, props);
349
+ }
350
+ const { title, link, error, name, gets, notes, password, own, onClose, children } = props;
351
+ const quiet = { margin: 0, opacity: 0.7, textAlign: "center" };
352
+ return h(pi.ui.Dialog, { title, onClose }, h("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 12 } }, error !== undefined ? h("p", { role: "alert" }, error) : [
353
+ name || gets ? h("p", { key: "who", style: { margin: 0, textAlign: "center" } }, [name, gets].filter(Boolean).join(" · ")) : null,
354
+ link && !own ? h(pi.ui.QrCode, { key: "qr", text: link, label: name || title }) : null,
355
+ h("code", { key: "link", style: { maxWidth: "100%", overflowWrap: "anywhere", userSelect: "all" } }, link !== null && link !== undefined ? link : "…"),
356
+ password ? h("code", { key: "password", style: { userSelect: "all" } }, password) : null,
357
+ link ? h("button", { key: "copy", type: "button", className: "ta-button ta-primary", onClick: () => {
358
+ var _a;
359
+ return void ((_a = navigator.clipboard) === null || _a === undefined ? undefined : _a.writeText(link));
360
+ } }, "Copy") : null,
361
+ children,
362
+ ...(notes !== null && notes !== undefined ? notes : []).filter(Boolean).map((line) => h("p", { key: String(line), style: quiet }, line))
363
+ ]));
364
+ }
365
+
334
366
  // ../ta-protocol/esm/common/language.js
335
367
  var TaLanguageUtil;
336
368
  (function(TaLanguageUtil2) {
@@ -727,10 +759,18 @@ var GRANT_HOURS = [1, 24, 24 * 7];
727
759
 
728
760
  // web-src/i18n.ts
729
761
  var EN = {
730
- roomsTitle: "Rooms",
762
+ friendShareTitle: "From {name}",
763
+ friendShareLine: "{name} sent you this",
764
+ friendShareRow: "[Link] {title}",
765
+ friendShareNote: "It opens as any link of Ta: Ta asks you before it adds, joins or imports anything.",
766
+ friendShareOpen: "Open",
767
+ friendShareDelete: "Delete",
768
+ myCodeGets: "They ask to be your friend; you are friends once you both agree",
769
+ inviteGets: "They ask to join; you let them in",
770
+ roomsTitle: "Group chats",
731
771
  add: "New",
732
- me: "Your name in rooms",
733
- meLine: "In rooms you are “{name}”",
772
+ me: "Your name in group chats",
773
+ meLine: "In group chats you are “{name}”",
734
774
  rename: "Change",
735
775
  renamePlaceholder: "What others see",
736
776
  requests: "Asking to join",
@@ -741,14 +781,14 @@ var EN = {
741
781
  requestGuest: "They ask from a browser, without Ta: let in, they only chat.",
742
782
  accept: "Let in",
743
783
  refuse: "Refuse",
744
- requestBody: "{name} wants to join your room “{title}”.",
745
- requestsBody: "{n} people ask to join your rooms.",
784
+ requestBody: "{name} wants to join your group chat “{title}”.",
785
+ requestsBody: "{n} people ask to join your group chats.",
746
786
  requestFriend: "They are your friend.",
747
787
  requestNew: "They are not your friend: let in only someone you know.",
748
- requestWhat: "Once in, they see the messages and the shared state of the room: in a game, where everyone is and what is built.",
788
+ requestWhat: "Once in, they see the messages and the shared state of the group chat: in a game, where everyone is and what is built.",
749
789
  later: "Later",
750
- ownRoom: "Your room",
751
- roomOf: "A room of {name}",
790
+ ownRoom: "Your group chat",
791
+ roomOf: "A group chat of {name}",
752
792
  people: "{n} people · {online} online",
753
793
  othersOnline: "{n} more online",
754
794
  nobodyOnline: "Nobody else online",
@@ -764,18 +804,12 @@ var EN = {
764
804
  inviteLine: "A link or a QR code; you let them in",
765
805
  inviteTitle: "Invite into “{title}”",
766
806
  inviteHint: "Send the link: opened in a browser, it asks to chat as a web guest; in the Ta app (scan or paste), to join with Ta. You let in who asks; the link works for 7 days, and a new one stops it.",
767
- newLink: "New link",
768
- making: "Making the link…",
769
- copy: "Copy link",
770
- copied: "Copied",
771
- send: "Send…",
772
- qr: "QR code of the invitation",
773
807
  members: "Members",
774
808
  memberCount: "{n} members",
775
809
  onlineCount: "{n} online",
776
- membersTitle: "About the room",
810
+ membersTitle: "About the group chat",
777
811
  membersCount: "{n} members · {online} online",
778
- noRoomOpen: "Open a room to see who is in it",
812
+ noRoomOpen: "Open a group chat to see who is in it",
779
813
  you: "You",
780
814
  owner: "Owner",
781
815
  online: "Online",
@@ -783,12 +817,12 @@ var EN = {
783
817
  remove: "Take out",
784
818
  removeTitle: "Take {name} out of “{title}”?",
785
819
  removeHint: "They are disconnected at once, and come back only by a new invitation.",
786
- leave: "Leave the room",
820
+ leave: "Leave the group chat",
787
821
  leaveTitle: "Leave “{title}”?",
788
822
  leaveHint: "You come back only by a new invitation.",
789
- close: "Close the room",
823
+ close: "Close the group chat",
790
824
  closeTitle: "Close “{title}” for everyone?",
791
- closeHint: "Everyone is taken out, and the relay deletes all the room kept.",
825
+ closeHint: "Everyone is taken out, and the relay deletes all the group chat kept.",
792
826
  forget: "Remove",
793
827
  friends: "Friends",
794
828
  friendsCount: "{n}",
@@ -798,7 +832,6 @@ var EN = {
798
832
  removeFriendTitle: "Remove {name} from your friends?",
799
833
  removeFriendHint: "You are no longer friends on both sides: neither sees the other’s posts, nor what is shared with friends. The rooms you share stay as they are.",
800
834
  addFriend: "Add friend",
801
- addFriendHint: "Let them scan this code, or send them the link. Once you both agree, you are friends: you see each other’s posts and may share with each other.",
802
835
  addFriendExpires: "Works for {days} more days",
803
836
  addFriendAction: "Add as friend",
804
837
  addFriendBody: "Ask {name} to be your friend? They see your name and answer in their Ta. Once both agree, you see each other’s posts and may share with each other.",
@@ -813,44 +846,70 @@ var EN = {
813
846
  friendAccept: "Agree",
814
847
  friendRequestNote: "Once friends, you see each other’s posts, and they may share with you. Agree only to someone you know.",
815
848
  friendsEmpty: "No friends yet",
816
- friendsEmptyHint: "Add a friend by a code or a link, or from the members of a room you are both in.",
817
- scanFriend: "Scan",
818
- pasteFriend: "Paste a link",
819
- emptyTitle: "No rooms yet",
849
+ friendsEmptyHint: "Add a friend by a code or a link, or from the members of a group chat you are both in.",
850
+ myCode: "My QR code",
851
+ addFriendPaste: "Paste a link someone sent you",
852
+ addFriendOpen: "Open",
853
+ addFriendScan: "The QR code of a friend or a group chat",
854
+ addFriendNearby: "Add those beside you, or make a group chat with them",
855
+ addFriendInGroup: "In a group chat, its members can be added as friends too. A link to a group chat pasted above joins it.",
856
+ emptyTitle: "No group chats yet",
820
857
  emptyListHint: "Make one with +, or open a link of invitation",
821
- pickRoom: "Pick a room to chat in",
858
+ pickRoom: "Pick a group chat to chat in",
822
859
  joinTitle: "Join “{title}”?",
823
- joinBody: "A room of {by}. They let you in first, and your name “{name}” goes to them.",
860
+ joinBody: "A group chat of {by}. They let you in first, and your name “{name}” goes to them.",
824
861
  joinAction: "Ask to join",
825
862
  joinByLink: "Join by a link",
826
863
  joinByLinkPlaceholder: "Paste the link of the invitation",
827
864
  scan: "Scan a code",
828
- scanHint: "Scan the QR code of an invitation",
829
- notInvite: "That is not a link that invites into a room.",
865
+ scanHint: "Scan the QR code of a friend or a group chat",
866
+ notInvite: "That is not a link of Ta.",
830
867
  asked: "Asked {by}: you are in once they let you in.",
831
868
  admitted: "You are in “{title}”.",
832
869
  refusedNotice: "{by} did not let you into “{title}”.",
833
870
  removedNotice: "You were taken out of “{title}”.",
834
871
  closedNotice: "“{title}” was closed by its owner.",
835
- oldApp: "Update the Ta app to use rooms.",
836
- room: "Room",
837
- newRoom: "New room",
872
+ oldApp: "Update the Ta app to use group chats.",
873
+ room: "Group chat",
874
+ newRoom: "New group chat",
838
875
  newRoomPlaceholder: "Its name, which those you invite see",
839
- roomOfName: "{name}’s room",
876
+ roomOfName: "{name}’s group chat",
840
877
  back: "Back",
841
878
  openPage: "Open {name}",
842
- apps: "Apps of the room",
843
- pageLine: "A room of {name}: play in it together",
844
- chatEmpty: "Nothing said yet. Only those in the room read it: the relay keeps it sealed.",
879
+ apps: "Apps of the group chat",
880
+ pageLine: "A group chat of {name}: play in it together",
881
+ chatEmpty: "Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.",
845
882
  chatPlaceholder: "Message",
846
- showOnHome: "Show rooms on the double's home",
847
- showOnHomeHint: "With rooms, the double's home has a Rooms section, beside members and channels."
883
+ showOnHome: "Show group chats on the double's home",
884
+ showOnHomeHint: "With group chats, the double's home has a Group chats section, beside members and channels.",
885
+ friendsDetail: "{n} friends",
886
+ friendsAsking: "{n} asking to be your friend",
887
+ inviteFriends: "Invite friends",
888
+ inviteFriendsLine: "They find it in their Ta, and are in once they join",
889
+ inviteFriendsTitle: "Invite friends into “{title}”",
890
+ inviteFriendsLead: "Each friend you tap finds the group chat in their Ta: once they join, they are in, without your saying yes again.",
891
+ inviteFriendsNone: "All your friends are in, or you have none yet",
892
+ inviteFriendsOld: "Update Ta on this computer to invite friends",
893
+ invitedFriend: "Invited",
894
+ groupInviteTitle: "Invited to a group chat",
895
+ groupInviteLine: "{name} invites you",
896
+ groupInviteNote: "Once in, you see what is said in it, and its members see you. You may leave any time.",
897
+ groupInviteIgnore: "Ignore",
898
+ groupInviteJoin: "Join"
848
899
  };
849
900
  var ZH = {
850
- roomsTitle: "房间",
901
+ friendShareTitle: "{name} 发来的",
902
+ friendShareLine: "{name} 发给你",
903
+ friendShareRow: "[链接] {title}",
904
+ friendShareNote: "打开后和任何 Ta 链接一样:添加、加入、导入之前 Ta 都会先问你。",
905
+ friendShareOpen: "打开",
906
+ friendShareDelete: "删除",
907
+ myCodeGets: "对方申请加你为好友,双方同意后成为好友",
908
+ inviteGets: "对方申请加入,你同意后进群",
909
+ roomsTitle: "群聊",
851
910
  add: "新建",
852
- me: "我在房间里的名字",
853
- meLine: "你在房间里叫「{name}」",
911
+ me: "我在群里的名字",
912
+ meLine: "你在群里叫「{name}」",
854
913
  rename: "修改",
855
914
  renamePlaceholder: "别人看到的名字",
856
915
  requests: "加入申请",
@@ -861,14 +920,14 @@ var ZH = {
861
920
  requestGuest: "对方是用浏览器申请的,没有装 Ta:进来后只能聊天。",
862
921
  accept: "同意",
863
922
  refuse: "拒绝",
864
- requestBody: "「{name}」想加入你的房间「{title}」。",
865
- requestsBody: "有 {n} 人申请加入你的房间。",
923
+ requestBody: "「{name}」想加入你的群聊「{title}」。",
924
+ requestsBody: "有 {n} 人申请加入你的群聊。",
866
925
  requestFriend: "对方是你的好友。",
867
926
  requestNew: "对方不是你的好友:只让认识的人进来。",
868
- requestWhat: "进来后,对方能看到房间里的消息和共享的内容;在游戏里就是大家的位置和搭的东西。",
927
+ requestWhat: "进来后,对方能看到群里的消息和共享的内容;在游戏里就是大家的位置和搭的东西。",
869
928
  later: "稍后",
870
- ownRoom: "我建的房间",
871
- roomOf: "{name}的房间",
929
+ ownRoom: "我建的群聊",
930
+ roomOf: "{name}的群聊",
872
931
  people: "{n} 人 · {online} 人在线",
873
932
  othersOnline: "另有 {n} 人在线",
874
933
  nobodyOnline: "其他人都不在线",
@@ -876,7 +935,7 @@ var ZH = {
876
935
  yesterday: "昨天",
877
936
  waiting: "等{name}同意",
878
937
  refused: "{name}没有同意",
879
- closed: "房主已解散",
938
+ closed: "群主已解散",
880
939
  removed: "你已被移出",
881
940
  inviteGone: "邀请已失效",
882
941
  connecting: "连接中…",
@@ -884,31 +943,25 @@ var ZH = {
884
943
  inviteLine: "发链接或二维码,由你同意进入",
885
944
  inviteTitle: "邀请加入「{title}」",
886
945
  inviteHint: "把链接发给对方:在浏览器里打开,可以作为网页访客申请聊天;在 Ta 应用里扫码或粘贴,就用 Ta 加入。都要你同意;链接 7 天内有效,换新链接后旧的作废。",
887
- newLink: "换一个链接",
888
- making: "正在生成链接…",
889
- copy: "复制链接",
890
- copied: "已复制",
891
- send: "发送…",
892
- qr: "邀请二维码",
893
946
  members: "成员",
894
947
  memberCount: "{n} 位成员",
895
948
  onlineCount: "{n} 人在线",
896
- membersTitle: "房间信息",
949
+ membersTitle: "群聊信息",
897
950
  membersCount: "{n} 位成员 · {online} 人在线",
898
- noRoomOpen: "打开一个房间,这里显示它的成员",
951
+ noRoomOpen: "打开一个群聊,这里显示它的成员",
899
952
  you: "我",
900
- owner: "房主",
953
+ owner: "群主",
901
954
  online: "在线",
902
955
  offline: "离线",
903
956
  remove: "移出",
904
957
  removeTitle: "把「{name}」移出「{title}」?",
905
958
  removeHint: "对方会立刻断开,只有新的邀请才能再进来。",
906
- leave: "退出房间",
959
+ leave: "退出群聊",
907
960
  leaveTitle: "退出「{title}」?",
908
961
  leaveHint: "退出后要有新的邀请才能再进来。",
909
- close: "解散房间",
962
+ close: "解散群聊",
910
963
  closeTitle: "解散「{title}」?",
911
- closeHint: "所有人都会被移出,中继会删除房间保存的全部内容。",
964
+ closeHint: "所有人都会被移出,中继会删除群聊保存的全部内容。",
912
965
  forget: "删除",
913
966
  friends: "好友",
914
967
  friendsCount: "{n} 位",
@@ -916,9 +969,8 @@ var ZH = {
916
969
  friendAdding: "等对方同意",
917
970
  removeFriend: "删除",
918
971
  removeFriendTitle: "删除好友「{name}」?",
919
- removeFriendHint: "两边同时不再是好友:互相看不到动态,也收不到只给好友的分享。一起所在的房间不受影响。",
972
+ removeFriendHint: "两边同时不再是好友:互相看不到动态,也收不到只给好友的分享。一起所在的群聊不受影响。",
920
973
  addFriend: "加好友",
921
- addFriendHint: "让对方扫这个码,或把链接发给对方。双方都同意后就是好友:互相看到动态,也能互相分享。",
922
974
  addFriendExpires: "还能用 {days} 天",
923
975
  addFriendAction: "加为好友",
924
976
  addFriendBody: "请「{name}」加你为好友?对方会看到你的名字,在自己的 Ta 里同意。双方同意后互相看到动态,也能互相分享。",
@@ -933,44 +985,70 @@ var ZH = {
933
985
  friendAccept: "同意",
934
986
  friendRequestNote: "成为好友后互相看到动态,对方也能给你分享东西。只同意认识的人。",
935
987
  friendsEmpty: "还没有好友",
936
- friendsEmptyHint: "用二维码或链接加好友,也可以在一起所在房间的成员里加。",
937
- scanFriend: "扫一扫",
938
- pasteFriend: "粘贴链接",
939
- emptyTitle: "还没有房间",
988
+ friendsEmptyHint: "用二维码或链接加好友,也可以在一起所在群聊的成员里加。",
989
+ myCode: "我的二维码",
990
+ addFriendPaste: "粘贴别人发来的链接",
991
+ addFriendOpen: "打开",
992
+ addFriendScan: "扫好友或群聊的二维码",
993
+ addFriendNearby: "加身边的人为好友,或一起建群聊",
994
+ addFriendInGroup: "在群聊的成员里也能加好友。群聊的邀请链接粘贴到上面,就能申请加入。",
995
+ emptyTitle: "还没有群聊",
940
996
  emptyListHint: "点 + 新建一个,或打开别人发来的邀请链接",
941
- pickRoom: "选一个房间开始聊天",
997
+ pickRoom: "选一个群聊开始聊天",
942
998
  joinTitle: "加入「{title}」?",
943
- joinBody: "这是{by}的房间。房主同意后你才能进去,你的名字「{name}」会发给对方。",
999
+ joinBody: "这是{by}的群聊。群主同意后你才能进去,你的名字「{name}」会发给对方。",
944
1000
  joinAction: "申请加入",
945
1001
  joinByLink: "用邀请链接加入",
946
1002
  joinByLinkPlaceholder: "粘贴别人发来的邀请链接",
947
1003
  scan: "扫一扫",
948
- scanHint: "扫描房间的邀请二维码",
949
- notInvite: "这不是房间的邀请链接。",
1004
+ scanHint: "扫好友或群聊的二维码",
1005
+ notInvite: "这不是 Ta 的链接。",
950
1006
  asked: "已向{by}发出申请,对方同意后就能进入。",
951
1007
  admitted: "已加入「{title}」。",
952
1008
  refusedNotice: "{by}没有同意你加入「{title}」。",
953
1009
  removedNotice: "你已被移出「{title}」。",
954
- closedNotice: "「{title}」已被房主解散。",
955
- oldApp: "请更新 Ta 应用后再使用房间。",
956
- room: "房间",
957
- newRoom: "新建房间",
958
- newRoomPlaceholder: "房间名,受邀的人能看到",
959
- roomOfName: "{name}的房间",
1010
+ closedNotice: "「{title}」已被群主解散。",
1011
+ oldApp: "请更新 Ta 应用后再使用群聊。",
1012
+ room: "群聊",
1013
+ newRoom: "新建群聊",
1014
+ newRoomPlaceholder: "群聊名,受邀的人能看到",
1015
+ roomOfName: "{name}的群聊",
960
1016
  back: "返回",
961
1017
  openPage: "打开{name}",
962
- apps: "房间应用",
963
- pageLine: "{name}的房间,大家可以一起玩",
964
- chatEmpty: "还没有人说话。只有房间里的人能看到,中继保存的是密文。",
1018
+ apps: "群聊应用",
1019
+ pageLine: "{name}的群聊,大家可以一起玩",
1020
+ chatEmpty: "还没有人说话。只有群里的人能看到,中继保存的是密文。",
965
1021
  chatPlaceholder: "发消息",
966
- showOnHome: "在分身首页显示房间",
967
- showOnHomeHint: "有房间时,分身首页多一个“房间”分类,和成员、频道放在一起。"
1022
+ showOnHome: "在分身首页显示群聊",
1023
+ showOnHomeHint: "有群聊时,分身首页多一个“群聊”分类,和成员、频道放在一起。",
1024
+ friendsDetail: "{n} 位好友",
1025
+ friendsAsking: "{n} 个新的好友申请",
1026
+ inviteFriends: "邀请好友",
1027
+ inviteFriendsLine: "对方在自己的 Ta 里看到,点加入就进来",
1028
+ inviteFriendsTitle: "邀请好友进「{title}」",
1029
+ inviteFriendsLead: "点一位好友,对方就会在自己的 Ta 里看到这个群聊;对方点加入就直接进来,不用你再同意。",
1030
+ inviteFriendsNone: "好友都在群里了,或者还没有好友",
1031
+ inviteFriendsOld: "先把这台电脑上的 Ta 更新到新版,才能邀请好友",
1032
+ invitedFriend: "已邀请",
1033
+ groupInviteTitle: "群聊邀请",
1034
+ groupInviteLine: "{name} 邀请你加入",
1035
+ groupInviteNote: "进来后能看到群里的聊天,群成员也能看到你。随时可以退出。",
1036
+ groupInviteIgnore: "忽略",
1037
+ groupInviteJoin: "加入"
968
1038
  };
969
1039
  var ZH_TW = {
970
- roomsTitle: "房間",
1040
+ friendShareTitle: "{name} 傳來的",
1041
+ friendShareLine: "{name} 傳給你",
1042
+ friendShareRow: "[連結] {title}",
1043
+ friendShareNote: "開啟後和任何 Ta 連結一樣:新增、加入、匯入之前 Ta 都會先問你。",
1044
+ friendShareOpen: "開啟",
1045
+ friendShareDelete: "刪除",
1046
+ myCodeGets: "對方申請加你為好友,雙方同意後成為好友",
1047
+ inviteGets: "對方申請加入,你同意後進群",
1048
+ roomsTitle: "群聊",
971
1049
  add: "新建",
972
- me: "我在房間裡的名字",
973
- meLine: "你在房間裡叫「{name}」",
1050
+ me: "我在群裡的名字",
1051
+ meLine: "你在群裡叫「{name}」",
974
1052
  rename: "修改",
975
1053
  renamePlaceholder: "別人看到的名字",
976
1054
  requests: "加入申請",
@@ -981,14 +1059,14 @@ var ZH_TW = {
981
1059
  requestGuest: "對方是用瀏覽器申請的,沒有裝 Ta:進來後只能聊天。",
982
1060
  accept: "同意",
983
1061
  refuse: "拒絕",
984
- requestBody: "「{name}」想加入你的房間「{title}」。",
985
- requestsBody: "有 {n} 人申請加入你的房間。",
1062
+ requestBody: "「{name}」想加入你的群聊「{title}」。",
1063
+ requestsBody: "有 {n} 人申請加入你的群聊。",
986
1064
  requestFriend: "對方是你的好友。",
987
1065
  requestNew: "對方不是你的好友:只讓認識的人進來。",
988
- requestWhat: "進來後,對方能看到房間裡的訊息和共享的內容;在遊戲裡就是大家的位置和搭的東西。",
1066
+ requestWhat: "進來後,對方能看到群裡的訊息和共享的內容;在遊戲裡就是大家的位置和搭的東西。",
989
1067
  later: "稍後",
990
- ownRoom: "我建的房間",
991
- roomOf: "{name}的房間",
1068
+ ownRoom: "我建的群聊",
1069
+ roomOf: "{name}的群聊",
992
1070
  people: "{n} 人 · {online} 人線上",
993
1071
  othersOnline: "另有 {n} 人線上",
994
1072
  nobodyOnline: "其他人都不線上",
@@ -996,7 +1074,7 @@ var ZH_TW = {
996
1074
  yesterday: "昨天",
997
1075
  waiting: "等{name}同意",
998
1076
  refused: "{name}沒有同意",
999
- closed: "房主已解散",
1077
+ closed: "群主已解散",
1000
1078
  removed: "你已被移出",
1001
1079
  inviteGone: "邀請已失效",
1002
1080
  connecting: "連線中…",
@@ -1004,31 +1082,25 @@ var ZH_TW = {
1004
1082
  inviteLine: "發連結或QR 碼,由你同意進入",
1005
1083
  inviteTitle: "邀請加入「{title}」",
1006
1084
  inviteHint: "把連結發給對方:在瀏覽器裡開啟,可以作為網頁訪客申請聊天;在 Ta 應用裡掃碼或貼上,就用 Ta 加入。都要你同意;連結 7 天內有效,換新連結後舊的作廢。",
1007
- newLink: "換一個連結",
1008
- making: "正在生成連結…",
1009
- copy: "複製連結",
1010
- copied: "已複製",
1011
- send: "傳送…",
1012
- qr: "邀請QR 碼",
1013
1085
  members: "成員",
1014
1086
  memberCount: "{n} 位成員",
1015
1087
  onlineCount: "{n} 人線上",
1016
- membersTitle: "房間資訊",
1088
+ membersTitle: "群聊資訊",
1017
1089
  membersCount: "{n} 位成員 · {online} 人線上",
1018
- noRoomOpen: "開啟一個房間,這裡顯示它的成員",
1090
+ noRoomOpen: "開啟一個群聊,這裡顯示它的成員",
1019
1091
  you: "我",
1020
- owner: "房主",
1092
+ owner: "群主",
1021
1093
  online: "線上",
1022
1094
  offline: "離線",
1023
1095
  remove: "移出",
1024
1096
  removeTitle: "把「{name}」移出「{title}」?",
1025
1097
  removeHint: "對方會立刻斷開,只有新的邀請才能再進來。",
1026
- leave: "退出房間",
1098
+ leave: "退出群聊",
1027
1099
  leaveTitle: "退出「{title}」?",
1028
1100
  leaveHint: "退出後要有新的邀請才能再進來。",
1029
- close: "解散房間",
1101
+ close: "解散群聊",
1030
1102
  closeTitle: "解散「{title}」?",
1031
- closeHint: "所有人都會被移出,中繼會刪除房間儲存的全部內容。",
1103
+ closeHint: "所有人都會被移出,中繼會刪除群聊儲存的全部內容。",
1032
1104
  forget: "刪除",
1033
1105
  friends: "好友",
1034
1106
  friendsCount: "{n} 位",
@@ -1036,9 +1108,8 @@ var ZH_TW = {
1036
1108
  friendAdding: "等對方同意",
1037
1109
  removeFriend: "刪除",
1038
1110
  removeFriendTitle: "刪除好友「{name}」?",
1039
- removeFriendHint: "兩邊同時不再是好友:互相看不到動態,也收不到只給好友的分享。一起所在的房間不受影響。",
1111
+ removeFriendHint: "兩邊同時不再是好友:互相看不到動態,也收不到只給好友的分享。一起所在的群聊不受影響。",
1040
1112
  addFriend: "加好友",
1041
- addFriendHint: "讓對方掃這個碼,或把連結發給對方。雙方都同意後就是好友:互相看到動態,也能互相分享。",
1042
1113
  addFriendExpires: "還能用 {days} 天",
1043
1114
  addFriendAction: "加為好友",
1044
1115
  addFriendBody: "請「{name}」加你為好友?對方會看到你的名字,在自己的 Ta 裡同意。雙方同意後互相看到動態,也能互相分享。",
@@ -1053,44 +1124,70 @@ var ZH_TW = {
1053
1124
  friendAccept: "同意",
1054
1125
  friendRequestNote: "成為好友後互相看到動態,對方也能給你分享東西。只同意認識的人。",
1055
1126
  friendsEmpty: "還沒有好友",
1056
- friendsEmptyHint: "用QR 碼或連結加好友,也可以在一起所在房間的成員里加。",
1057
- scanFriend: "掃一掃",
1058
- pasteFriend: "貼上連結",
1059
- emptyTitle: "還沒有房間",
1127
+ friendsEmptyHint: "用QR 碼或連結加好友,也可以在一起所在群聊的成員里加。",
1128
+ myCode: "我的 QR 碼",
1129
+ addFriendPaste: "貼上別人發來的連結",
1130
+ addFriendOpen: "開啟",
1131
+ addFriendScan: "掃好友或群聊的 QR 碼",
1132
+ addFriendNearby: "加身邊的人為好友,或一起建群聊",
1133
+ addFriendInGroup: "在群聊的成員裡也能加好友。群聊的邀請連結貼到上面,就能申請加入。",
1134
+ emptyTitle: "還沒有群聊",
1060
1135
  emptyListHint: "點 + 新建一個,或開啟別人發來的邀請連結",
1061
- pickRoom: "選一個房間開始聊天",
1136
+ pickRoom: "選一個群聊開始聊天",
1062
1137
  joinTitle: "加入「{title}」?",
1063
- joinBody: "這是{by}的房間。房主同意後你才能進去,你的名字「{name}」會發給對方。",
1138
+ joinBody: "這是{by}的群聊。群主同意後你才能進去,你的名字「{name}」會發給對方。",
1064
1139
  joinAction: "申請加入",
1065
1140
  joinByLink: "用邀請連結加入",
1066
1141
  joinByLinkPlaceholder: "貼上別人發來的邀請連結",
1067
1142
  scan: "掃一掃",
1068
- scanHint: "掃描房間的邀請QR 碼",
1069
- notInvite: "這不是房間的邀請連結。",
1143
+ scanHint: "掃好友或群聊的 QR 碼",
1144
+ notInvite: "這不是 Ta 的連結。",
1070
1145
  asked: "已向{by}發出申請,對方同意後就能進入。",
1071
1146
  admitted: "已加入「{title}」。",
1072
1147
  refusedNotice: "{by}沒有同意你加入「{title}」。",
1073
1148
  removedNotice: "你已被移出「{title}」。",
1074
- closedNotice: "「{title}」已被房主解散。",
1075
- oldApp: "請更新 Ta 應用後再使用房間。",
1076
- room: "房間",
1077
- newRoom: "新建房間",
1078
- newRoomPlaceholder: "房間名,受邀的人能看到",
1079
- roomOfName: "{name}的房間",
1149
+ closedNotice: "「{title}」已被群主解散。",
1150
+ oldApp: "請更新 Ta 應用後再使用群聊。",
1151
+ room: "群聊",
1152
+ newRoom: "新建群聊",
1153
+ newRoomPlaceholder: "群聊名,受邀的人能看到",
1154
+ roomOfName: "{name}的群聊",
1080
1155
  back: "返回",
1081
1156
  openPage: "開啟{name}",
1082
- apps: "房間應用",
1083
- pageLine: "{name}的房間,大家可以一起玩",
1084
- chatEmpty: "還沒有人說話。只有房間裡的人能看到,中繼儲存的是密文。",
1157
+ apps: "群聊應用",
1158
+ pageLine: "{name}的群聊,大家可以一起玩",
1159
+ chatEmpty: "還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。",
1085
1160
  chatPlaceholder: "發訊息",
1086
- showOnHome: "在分身首頁顯示房間",
1087
- showOnHomeHint: "有房間時,分身首頁多一個「房間」分類,和成員、頻道放在一起。"
1161
+ showOnHome: "在分身首頁顯示群聊",
1162
+ showOnHomeHint: "有群聊時,分身首頁多一個「群聊」分類,和成員、頻道放在一起。",
1163
+ friendsDetail: "{n} 位好友",
1164
+ friendsAsking: "{n} 個新的好友申請",
1165
+ inviteFriends: "邀請好友",
1166
+ inviteFriendsLine: "對方在自己的 Ta 裡看到,點加入就進來",
1167
+ inviteFriendsTitle: "邀請好友進「{title}」",
1168
+ inviteFriendsLead: "點一位好友,對方就會在自己的 Ta 裡看到這個群聊;對方點加入就直接進來,不用你再同意。",
1169
+ inviteFriendsNone: "好友都在群裡了,或者還沒有好友",
1170
+ inviteFriendsOld: "先把這台電腦上的 Ta 更新到新版,才能邀請好友",
1171
+ invitedFriend: "已邀請",
1172
+ groupInviteTitle: "群聊邀請",
1173
+ groupInviteLine: "{name} 邀請你加入",
1174
+ groupInviteNote: "進來後能看到群裡的聊天,群成員也能看到你。隨時可以退出。",
1175
+ groupInviteIgnore: "忽略",
1176
+ groupInviteJoin: "加入"
1088
1177
  };
1089
1178
  var JA = {
1090
- roomsTitle: "ルーム",
1179
+ friendShareTitle: "{name} から",
1180
+ friendShareLine: "{name} から届きました",
1181
+ friendShareRow: "[リンク] {title}",
1182
+ friendShareNote: "ほかの Ta のリンクと同じく、追加・参加・インポートの前に Ta が確認します。",
1183
+ friendShareOpen: "開く",
1184
+ friendShareDelete: "削除",
1185
+ myCodeGets: "相手から友だち申請が届き、双方が同意すると友だちになります",
1186
+ inviteGets: "相手が参加を申請し、あなたが許可すると参加します",
1187
+ roomsTitle: "グループチャット",
1091
1188
  add: "新規作成",
1092
- me: "ルーム内での私の名前",
1093
- meLine: "ルーム内で「{name}」と呼ばれています",
1189
+ me: "グループ内での私の名前",
1190
+ meLine: "グループ内で「{name}」と呼ばれています",
1094
1191
  rename: "変更",
1095
1192
  renamePlaceholder: "他の人に見える名前",
1096
1193
  requests: "参加リクエスト",
@@ -1101,14 +1198,14 @@ var JA = {
1101
1198
  requestGuest: "相手はブラウザから申請しており、Ta をインストールしていません:参加後はチャットのみ可能です。",
1102
1199
  accept: "了承",
1103
1200
  refuse: "拒否",
1104
- requestBody: "「{name}」があなたのルーム「{title}」に参加したいと言っています。",
1105
- requestsBody: "{n} 人がルームへの参加をリクエストしています。",
1201
+ requestBody: "「{name}」があなたのグループチャット「{title}」に参加したいと言っています。",
1202
+ requestsBody: "{n} 人がグループチャットへの参加をリクエストしています。",
1106
1203
  requestFriend: "相手はあなたの友だちです。",
1107
1204
  requestNew: "相手はあなたの友だちではありません:知っている人だけを参加させてください。",
1108
- requestWhat: "参加すると、相手はルーム内のメッセージと共有されたコンテンツを見ることができます:ゲームでは、みんなの位置と作られたものです。",
1205
+ requestWhat: "参加すると、相手はグループ内のメッセージと共有されたコンテンツを見ることができます:ゲームでは、みんなの位置と作られたものです。",
1109
1206
  later: "後で",
1110
- ownRoom: "私が作ったルーム",
1111
- roomOf: "{name}のルーム",
1207
+ ownRoom: "私が作ったグループチャット",
1208
+ roomOf: "{name}のグループチャット",
1112
1209
  people: "{n} 人 · {online} 人がオンライン",
1113
1210
  othersOnline: "さらに {n} 人がオンライン",
1114
1211
  nobodyOnline: "他に誰もオンラインではありません",
@@ -1124,18 +1221,12 @@ var JA = {
1124
1221
  inviteLine: "リンクまたは QR コードを送信します。参加を許可するのはあなたです",
1125
1222
  inviteTitle: "「{title}」に招待",
1126
1223
  inviteHint: "リンクを相手に送信します:ブラウザで開くと、ウェブゲストとしてチャットをリクエストできます。Ta アプリでスキャンまたは貼り付けると、Ta で参加できます。どちらの場合も参加を許可するのはあなたです。リンクは 7 日間有効で、新しいリンクを作成すると古いリンクは無効になります。",
1127
- newLink: "新しいリンクを作成",
1128
- making: "リンクを生成中…",
1129
- copy: "リンクをコピー",
1130
- copied: "コピーしました",
1131
- send: "送信…",
1132
- qr: "招待用 QR コード",
1133
1224
  members: "メンバー",
1134
1225
  memberCount: "{n} 人のメンバー",
1135
1226
  onlineCount: "{n} 人がオンライン",
1136
- membersTitle: "ルーム情報",
1227
+ membersTitle: "グループチャット情報",
1137
1228
  membersCount: "{n} 人のメンバー · {online} 人がオンライン",
1138
- noRoomOpen: "ルームを開いて、メンバーを確認します",
1229
+ noRoomOpen: "グループチャットを開いて、メンバーを確認します",
1139
1230
  you: "私",
1140
1231
  owner: "オーナー",
1141
1232
  online: "オンライン",
@@ -1143,12 +1234,12 @@ var JA = {
1143
1234
  remove: "削除",
1144
1235
  removeTitle: "「{name}」を「{title}」から削除しますか?",
1145
1236
  removeHint: "相手はすぐに切断され、新しい招待でのみ戻ることができます。",
1146
- leave: "ルームを退出",
1237
+ leave: "グループチャットを退出",
1147
1238
  leaveTitle: "「{title}」を退出しますか?",
1148
1239
  leaveHint: "新しい招待を受け取ってのみ戻ることができます。",
1149
- close: "ルームを閉鎖",
1240
+ close: "グループチャットを閉鎖",
1150
1241
  closeTitle: "「{title}」をすべてのユーザーに対して閉鎖しますか?",
1151
- closeHint: "すべてのユーザーが削除され、リレーはルームに保存されているすべてを削除します。",
1242
+ closeHint: "すべてのユーザーが削除され、リレーはグループチャットに保存されているすべてを削除します。",
1152
1243
  forget: "削除",
1153
1244
  friends: "友だち",
1154
1245
  friendsCount: "{n} 人",
@@ -1156,9 +1247,8 @@ var JA = {
1156
1247
  friendAdding: "ユーザーが同意するのを待機中",
1157
1248
  removeFriend: "削除",
1158
1249
  removeFriendTitle: "友だち「{name}」を削除しますか?",
1159
- removeFriendHint: "両側で友だちではなくなります:お互いの投稿が見えなくなり、友だちのみとの共有も受け取れません。共有しているルームは影響を受けません。",
1250
+ removeFriendHint: "両側で友だちではなくなります:お互いの投稿が見えなくなり、友だちのみとの共有も受け取れません。共有しているグループチャットは影響を受けません。",
1160
1251
  addFriend: "友だち追加",
1161
- addFriendHint: "このコードをスキャンしてもらうか、リンクを送信します。双方が同意すると友だちになります:お互いの投稿が見え、共有できます。",
1162
1252
  addFriendExpires: "あと {days} 日間利用可能",
1163
1253
  addFriendAction: "友だち追加",
1164
1254
  addFriendBody: "「{name}」を友だち追加しますか?相手はあなたの名前を見て、自分の Ta で返答できます。双方が同意するとお互いの投稿が見え、共有できます。",
@@ -1173,38 +1263,56 @@ var JA = {
1173
1263
  friendAccept: "同意",
1174
1264
  friendRequestNote: "友だちになると、お互いの投稿が見え、相手があなたと共有できるようになります。知っている人だけに同意してください。",
1175
1265
  friendsEmpty: "まだ友だちがいません",
1176
- friendsEmptyHint: "コードまたはリンクで友だちを追加するか、共有するルームのメンバーから追加します。",
1177
- scanFriend: "スキャン",
1178
- pasteFriend: "リンクを貼り付け",
1179
- emptyTitle: "まだルームがありません",
1266
+ friendsEmptyHint: "コードまたはリンクで友だちを追加するか、共有するグループチャットのメンバーから追加します。",
1267
+ myCode: "マイQRコード",
1268
+ addFriendPaste: "届いたリンクを貼り付け",
1269
+ addFriendOpen: "開く",
1270
+ addFriendScan: "友だちやグループチャットのQRコード",
1271
+ addFriendNearby: "近くの人を友だちに追加、または一緒にグループチャットを作成",
1272
+ addFriendInGroup: "グループチャットのメンバーからも友だち追加できます。グループチャットの招待リンクを上に貼り付けると参加を申請します。",
1273
+ emptyTitle: "まだグループチャットがありません",
1180
1274
  emptyListHint: "+ で新しく作成するか、招待リンクを開きます",
1181
- pickRoom: "チャットするルームを選択します",
1275
+ pickRoom: "チャットするグループチャットを選択します",
1182
1276
  joinTitle: "「{title}」に参加しますか?",
1183
- joinBody: "{by} のルーム。オーナーが許可すると参加できます。あなたの名前「{name}」は相手に送信されます。",
1277
+ joinBody: "{by} のグループチャット。オーナーが許可すると参加できます。あなたの名前「{name}」は相手に送信されます。",
1184
1278
  joinAction: "参加をリクエスト",
1185
1279
  joinByLink: "リンクで参加",
1186
1280
  joinByLinkPlaceholder: "招待リンクを貼り付けます",
1187
1281
  scan: "スキャン",
1188
- scanHint: "招待の QR コードをスキャン",
1189
- notInvite: "これはルーム招待リンクではありません。",
1282
+ scanHint: "友だちやグループチャットのQRコードをスキャン",
1283
+ notInvite: "これは Ta のリンクではありません。",
1190
1284
  asked: "{by} にリクエストを送信しました:相手が許可すると参加できます。",
1191
1285
  admitted: "「{title}」に参加しました。",
1192
1286
  refusedNotice: "{by} はあなたの「{title}」への参加を許可しませんでした。",
1193
1287
  removedNotice: "「{title}」から削除されました。",
1194
1288
  closedNotice: "「{title}」はオーナーによって閉鎖されました。",
1195
- oldApp: "ルームを使用するには Ta アプリを更新してください。",
1196
- room: "ルーム",
1197
- newRoom: "新しいルームを作成",
1198
- newRoomPlaceholder: "ルーム名。招待された人が見ます",
1199
- roomOfName: "{name}のルーム",
1289
+ oldApp: "グループチャットを使用するには Ta アプリを更新してください。",
1290
+ room: "グループチャット",
1291
+ newRoom: "新しいグループチャット",
1292
+ newRoomPlaceholder: "グループチャット名。招待された人が見ます",
1293
+ roomOfName: "{name}のグループチャット",
1200
1294
  back: "戻る",
1201
1295
  openPage: "{name} を開く",
1202
- apps: "ルームのアプリ",
1203
- pageLine: "{name} のルーム:一緒にプレイします",
1204
- chatEmpty: "まだ何も言われていません。ルーム内の人だけが見ることができます。リレーは暗号化されて保存します。",
1296
+ apps: "グループチャットのアプリ",
1297
+ pageLine: "{name} のグループチャット:一緒にプレイします",
1298
+ chatEmpty: "まだ何も言われていません。グループ内の人だけが見ることができます。リレーは暗号化されて保存します。",
1205
1299
  chatPlaceholder: "メッセージ",
1206
- showOnHome: "分身のホームにルームを表示",
1207
- showOnHomeHint: "ルームがあると、分身のホームに「ルーム」セクションが追加され、メンバーとチャンネルと一緒に表示されます。"
1300
+ showOnHome: "分身のホームにグループチャットを表示",
1301
+ showOnHomeHint: "グループチャットがあると、分身のホームに「グループチャット」セクションが追加され、メンバーとチャンネルと一緒に表示されます。",
1302
+ friendsDetail: "友だち {n} 人",
1303
+ friendsAsking: "友だち申請 {n} 件",
1304
+ inviteFriends: "友だちを招待",
1305
+ inviteFriendsLine: "相手の Ta に届き、参加するとすぐ入れます",
1306
+ inviteFriendsTitle: "「{title}」に友だちを招待",
1307
+ inviteFriendsLead: "友だちをタップすると、その人の Ta にこのグループチャットが届きます。参加すれば、あなたの承認なしで入れます。",
1308
+ inviteFriendsNone: "友だちは全員参加済みか、まだ友だちがいません",
1309
+ inviteFriendsOld: "友だちを招待するには、このコンピュータの Ta を更新してください",
1310
+ invitedFriend: "招待済み",
1311
+ groupInviteTitle: "グループチャットへの招待",
1312
+ groupInviteLine: "{name} からの招待",
1313
+ groupInviteNote: "参加するとチャットが見え、メンバーからもあなたが見えます。いつでも退出できます。",
1314
+ groupInviteIgnore: "無視",
1315
+ groupInviteJoin: "参加"
1208
1316
  };
1209
1317
  var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
1210
1318
  var RoomWords;
@@ -1225,6 +1333,26 @@ function bind(react) {
1225
1333
  React = react;
1226
1334
  }
1227
1335
 
1336
+ // web-src/room-seen.ts
1337
+ var RoomSeenUtil;
1338
+ ((RoomSeenUtil) => {
1339
+ function parse(value) {
1340
+ return value && typeof value === "object" ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "number")) : {};
1341
+ }
1342
+ RoomSeenUtil.parse = parse;
1343
+ function merge(a, b) {
1344
+ const later = Object.entries(b).filter(([room, at]) => at > (a[room] ?? 0));
1345
+ return later.length ? { ...a, ...Object.fromEntries(later) } : a;
1346
+ }
1347
+ RoomSeenUtil.merge = merge;
1348
+ })(RoomSeenUtil ||= {});
1349
+ function unseen(room, lines, seen) {
1350
+ const self = room.members.find((member) => member.self)?.member;
1351
+ const since = seen[room.id] ?? room.joinedAt ?? room.createdAt;
1352
+ const last = lines[lines.length - 1];
1353
+ return !!last && last.at > since && last.from !== self;
1354
+ }
1355
+
1228
1356
  // web-src/page.tsx
1229
1357
  var ROOMS_KIND = "ta-rooms";
1230
1358
  var ROOMS_VIEW = "@celljs/ta-rooms/rooms";
@@ -1250,7 +1378,7 @@ function rooms() {
1250
1378
  }
1251
1379
 
1252
1380
  class RoomBook {
1253
- state = { requests: [], friendRequests: [], seen: {} };
1381
+ state = { requests: [], friendRequests: [], groupInvites: [], seen: {} };
1254
1382
  listeners = new Set;
1255
1383
  chats = new Map;
1256
1384
  agentStates = new Map;
@@ -1277,7 +1405,7 @@ class RoomBook {
1277
1405
  }
1278
1406
  const server = rooms();
1279
1407
  if (!server) {
1280
- this.set({ rooms: [], friends: [], friendRequests: [] });
1408
+ this.set({ rooms: [], friends: [], friendRequests: [], groupInvites: [] });
1281
1409
  return Promise.resolve();
1282
1410
  }
1283
1411
  this.readSeen();
@@ -1288,11 +1416,20 @@ class RoomBook {
1288
1416
  }),
1289
1417
  server.listRequests().catch(() => this.state.requests),
1290
1418
  server.listFriends().catch(() => this.state.friends ?? []),
1291
- server.listFriendRequests ? server.listFriendRequests().catch(() => this.state.friendRequests) : Promise.resolve([])
1292
- ]).then(([identity, all, requests, friends, friendRequests]) => {
1419
+ server.listFriendRequests ? server.listFriendRequests().catch(() => this.state.friendRequests) : Promise.resolve([]),
1420
+ server.listGroupInvites ? server.listGroupInvites().catch(() => this.state.groupInvites) : Promise.resolve([])
1421
+ ]).then(([identity, all, requests, friends, friendRequests, groupInvites]) => {
1293
1422
  const unlisted = new Set((all ?? []).filter((room) => room.unlisted).map((room) => room.id));
1294
1423
  const list = all ? all.filter((room) => !unlisted.has(room.id)) : this.state.rooms ?? [];
1295
- this.read({ ...this.state, identity, rooms: list, requests: requests.filter((request) => !unlisted.has(request.room)), friends, friendRequests });
1424
+ this.read({
1425
+ ...this.state,
1426
+ identity,
1427
+ rooms: list,
1428
+ requests: requests.filter((request) => !unlisted.has(request.room)),
1429
+ friends,
1430
+ friendRequests,
1431
+ groupInvites
1432
+ });
1296
1433
  }).finally(() => {
1297
1434
  this.loading = undefined;
1298
1435
  if (this.again) {
@@ -1508,26 +1645,8 @@ function useAgents(room) {
1508
1645
  function useJoining(room) {
1509
1646
  return React.useSyncExternalStore((listener) => book.subscribe(listener), () => book.joining(room.id));
1510
1647
  }
1511
- var RoomSeenUtil;
1512
- ((RoomSeenUtil) => {
1513
- function parse(value) {
1514
- return value && typeof value === "object" ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "number")) : {};
1515
- }
1516
- RoomSeenUtil.parse = parse;
1517
- function merge(a, b) {
1518
- const later = Object.entries(b).filter(([room, at]) => at > (a[room] ?? 0));
1519
- return later.length ? { ...a, ...Object.fromEntries(later) } : a;
1520
- }
1521
- RoomSeenUtil.merge = merge;
1522
- })(RoomSeenUtil ||= {});
1523
- function unseen(room, lines, seen) {
1524
- const self = room.members.find((member) => member.self)?.member;
1525
- const since = seen[room.id] ?? room.joinedAt ?? room.createdAt;
1526
- const last = lines[lines.length - 1];
1527
- return !!last && last.at > since && last.from !== self;
1528
- }
1529
1648
  function openRoom(id, direct = false) {
1530
- book.set({ opened: id, direct });
1649
+ book.set({ opened: id, direct: direct || !!pi.ui.doubleInChats });
1531
1650
  pi.ui.showView(ROOMS_VIEW);
1532
1651
  }
1533
1652
  function useOpened() {
@@ -1833,10 +1952,10 @@ var ZH2 = {
1833
1952
  mentionLabel: "问分身",
1834
1953
  mentionDetail: "问 TA 的分身",
1835
1954
  answersHere: "我的分身在这里回答",
1836
- answersHint: "有人 @ 你的分身时,它会在这个房间里回答。默认只能聊天和读房间里的内容,你允许后才能替某人做更多事。",
1955
+ answersHint: "有人 @ 你的分身时,它会在这个群里回答。默认只能聊天和读群里的内容,你允许后才能替某人做更多事。",
1837
1956
  permissions: "授权分身替 TA 做事",
1838
1957
  grantTitle: "让分身替{name}做事",
1839
- grantLead: "{name}在房间里问你的分身时,它还可以在你的电脑上:",
1958
+ grantLead: "{name}在群里问你的分身时,它还可以在你的电脑上:",
1840
1959
  files: "读写文件",
1841
1960
  filesHint: "只限下面这个目录。",
1842
1961
  commands: "运行命令",
@@ -1872,7 +1991,7 @@ var ZH2 = {
1872
1991
  stop: "停掉",
1873
1992
  logTitle: "分身记录",
1874
1993
  logEmpty: "还没有记录",
1875
- logEmptyHint: "分身在房间里替别人做的事会列在这里",
1994
+ logEmptyHint: "分身在群里替别人做的事会列在这里",
1876
1995
  asked: "{name}问",
1877
1996
  answered: "已回答",
1878
1997
  failed: "失败",
@@ -1883,25 +2002,25 @@ var ZH2 = {
1883
2002
  noGrants: "分身只替别人聊天",
1884
2003
  log: "分身记录",
1885
2004
  noPermission: "还没有授权",
1886
- oldServer: "请先更新电脑上的 Ta,再在房间里使用分身。",
2005
+ oldServer: "请先更新电脑上的 Ta,再在群里使用分身。",
1887
2006
  agentTag: "智能体",
1888
2007
  myAgent: "我的智能体",
1889
2008
  agentOf: "{name}的智能体",
1890
2009
  agentsTitle: "智能体",
1891
2010
  inviteAgent: "邀请智能体",
1892
- inviteAgentLine: "让你的智能体在房间里帮忙",
2011
+ inviteAgentLine: "让你的智能体在群里帮忙",
1893
2012
  pickAgentTitle: "邀请智能体进「{title}」",
1894
- pickAgentLead: "房间里的人 @ 它就能找它帮忙。你自己问它时,它像平常一样在自己的目录里用工具做事;别人问它时,和分身一样只能聊天,除非你授权。",
2013
+ pickAgentLead: "群里的人 @ 它就能找它帮忙。你自己问它时,它像平常一样在自己的目录里用工具做事;别人问它时,和分身一样只能聊天,除非你授权。",
1895
2014
  noAgents: "还没有智能体",
1896
2015
  noAgentsHint: "先在分身侧栏新建一个智能体。",
1897
- inRoom: "已在房间里",
2016
+ inRoom: "已在群里",
1898
2017
  joining: "正在加入…",
1899
- joiningRoom: "{name}正在加入房间…",
2018
+ joiningRoom: "{name}正在加入群聊…",
1900
2019
  inviteFailed: "没能邀请{name}:{error}",
1901
- dismiss: "请出房间",
2020
+ dismiss: "请出群聊",
1902
2021
  dismissTitle: "让{name}离开「{title}」?",
1903
- dismissHint: "它会在房间里道别,之后不再回答这里的问题。",
1904
- tryAlone: "邀请一个你的智能体进来,一个人也能试试房间。",
2022
+ dismissHint: "它会在群里道别,之后不再回答这里的问题。",
2023
+ tryAlone: "邀请一个你的智能体进来,一个人也能试试群聊。",
1905
2024
  agentAsked: "{name}问{agent}",
1906
2025
  taskTag: "任务",
1907
2026
  taskSent: "已交出",
@@ -1918,9 +2037,9 @@ var ZH2 = {
1918
2037
  taskWaitsFor: "等{name}授权",
1919
2038
  stopTask: "停止任务",
1920
2039
  cancelTask: "取消任务",
1921
- openTaskRoom: "打开房间",
2040
+ openTaskRoom: "打开群聊",
1922
2041
  forgetTask: "删除",
1923
- forgetTaskHint: "只删除这条记录,房间里说过的话还在。",
2042
+ forgetTaskHint: "只删除这条记录,群里说过的话还在。",
1924
2043
  taskResult: "交给{name}的分身的任务",
1925
2044
  taskLog: "{name}交来任务"
1926
2045
  };
@@ -1931,10 +2050,10 @@ var ZH_TW2 = {
1931
2050
  mentionLabel: "問分身",
1932
2051
  mentionDetail: "問 TA 的分身",
1933
2052
  answersHere: "我的分身在這裡回答",
1934
- answersHint: "有人 @ 你的分身時,它會在這個房間裡回答。預設只能聊天和讀房間裡的內容,你允許後才能替某人做更多事。",
2053
+ answersHint: "有人 @ 你的分身時,它會在這個群裡回答。預設只能聊天和讀群裡的內容,你允許後才能替某人做更多事。",
1935
2054
  permissions: "授權分身替 TA 做事",
1936
2055
  grantTitle: "讓分身替{name}做事",
1937
- grantLead: "{name}在房間裡問你的分身時,它還可以在你的電腦上:",
2056
+ grantLead: "{name}在群裡問你的分身時,它還可以在你的電腦上:",
1938
2057
  files: "讀寫檔案",
1939
2058
  filesHint: "只限下面這個目錄。",
1940
2059
  commands: "執行命令",
@@ -1970,7 +2089,7 @@ var ZH_TW2 = {
1970
2089
  stop: "停掉",
1971
2090
  logTitle: "分身記錄",
1972
2091
  logEmpty: "還沒有記錄",
1973
- logEmptyHint: "分身在房間裡替別人做的事會列在這裡",
2092
+ logEmptyHint: "分身在群裡替別人做的事會列在這裡",
1974
2093
  asked: "{name}問",
1975
2094
  answered: "已回答",
1976
2095
  failed: "失敗",
@@ -1981,25 +2100,25 @@ var ZH_TW2 = {
1981
2100
  noGrants: "分身只替別人聊天",
1982
2101
  log: "分身記錄",
1983
2102
  noPermission: "還沒有授權",
1984
- oldServer: "請先更新電腦上的 Ta,再在房間裡使用分身。",
2103
+ oldServer: "請先更新電腦上的 Ta,再在群裡使用分身。",
1985
2104
  agentTag: "智慧體",
1986
2105
  myAgent: "我的智慧體",
1987
2106
  agentOf: "{name}的智慧體",
1988
2107
  agentsTitle: "智慧體",
1989
2108
  inviteAgent: "邀請智慧體",
1990
- inviteAgentLine: "讓你的智慧體在房間裡幫忙",
2109
+ inviteAgentLine: "讓你的智慧體在群裡幫忙",
1991
2110
  pickAgentTitle: "邀請智慧體進「{title}」",
1992
- pickAgentLead: "房間裡的人 @ 它就能找它幫忙。你自己問它時,它像平常一樣在自己的目錄裡用工具做事;別人問它時,和分身一樣只能聊天,除非你授權。",
2111
+ pickAgentLead: "群裡的人 @ 它就能找它幫忙。你自己問它時,它像平常一樣在自己的目錄裡用工具做事;別人問它時,和分身一樣只能聊天,除非你授權。",
1993
2112
  noAgents: "還沒有智慧體",
1994
2113
  noAgentsHint: "先在分身側欄新建一個智慧體。",
1995
- inRoom: "已在房間裡",
2114
+ inRoom: "已在群裡",
1996
2115
  joining: "正在加入…",
1997
- joiningRoom: "{name}正在加入房間…",
2116
+ joiningRoom: "{name}正在加入群聊…",
1998
2117
  inviteFailed: "沒能邀請{name}:{error}",
1999
- dismiss: "請出房間",
2118
+ dismiss: "請出群聊",
2000
2119
  dismissTitle: "讓{name}離開「{title}」?",
2001
- dismissHint: "它會在房間裡道別,之後不再回答這裡的問題。",
2002
- tryAlone: "邀請一個你的智慧體進來,一個人也能試試房間。",
2120
+ dismissHint: "它會在群裡道別,之後不再回答這裡的問題。",
2121
+ tryAlone: "邀請一個你的智慧體進來,一個人也能試試群聊。",
2003
2122
  agentAsked: "{name}問{agent}",
2004
2123
  taskTag: "任務",
2005
2124
  taskSent: "已交出",
@@ -2016,9 +2135,9 @@ var ZH_TW2 = {
2016
2135
  taskWaitsFor: "等{name}授權",
2017
2136
  stopTask: "停止任務",
2018
2137
  cancelTask: "取消任務",
2019
- openTaskRoom: "開啟房間",
2138
+ openTaskRoom: "開啟群聊",
2020
2139
  forgetTask: "刪除",
2021
- forgetTaskHint: "只刪除這條記錄,房間裡說過的話還在。",
2140
+ forgetTaskHint: "只刪除這條記錄,群裡說過的話還在。",
2022
2141
  taskResult: "交給{name}的分身的任務",
2023
2142
  taskLog: "{name}交來任務"
2024
2143
  };
@@ -2029,10 +2148,10 @@ var JA2 = {
2029
2148
  mentionLabel: "分身に質問",
2030
2149
  mentionDetail: "彼らの分身に質問",
2031
2150
  answersHere: "私の分身がここで返答します",
2032
- answersHint: "@で分身に尋ねられると、このルーム内で返答します。デフォルトではチャットとルーム内容の読み取りのみが可能で、許可後は誰かの代わりにより多くのことを実行できます。",
2151
+ answersHint: "@で分身に尋ねられると、このグループ内で返答します。デフォルトではチャットとグループ内容の読み取りのみが可能で、許可後は誰かの代わりにより多くのことを実行できます。",
2033
2152
  permissions: "分身に代行を許可",
2034
2153
  grantTitle: "分身に {name} の代わりに作業させる",
2035
- grantLead: "{name} がルーム内で分身に質問すると、コンピュータ上で次のことも実行できます:",
2154
+ grantLead: "{name} がグループ内で分身に質問すると、コンピュータ上で次のことも実行できます:",
2036
2155
  files: "ファイルの読み書き",
2037
2156
  filesHint: "下記のディレクトリのみ。",
2038
2157
  commands: "コマンドの実行",
@@ -2068,7 +2187,7 @@ var JA2 = {
2068
2187
  stop: "停止",
2069
2188
  logTitle: "分身の記録",
2070
2189
  logEmpty: "まだ記録がありません",
2071
- logEmptyHint: "ルーム内で分身が他の人のために実行したアクションが記録されます",
2190
+ logEmptyHint: "グループ内で分身が他の人のために実行したアクションが記録されます",
2072
2191
  asked: "{name} が質問",
2073
2192
  answered: "返答済み",
2074
2193
  failed: "失敗",
@@ -2079,25 +2198,25 @@ var JA2 = {
2079
2198
  noGrants: "分身は他の人とのチャットのみ",
2080
2199
  log: "分身の記録",
2081
2200
  noPermission: "まだ設定されていません",
2082
- oldServer: "ルーム内で分身を使用する前に、コンピュータ上の Ta を更新してください。",
2201
+ oldServer: "グループ内で分身を使用する前に、コンピュータ上の Ta を更新してください。",
2083
2202
  agentTag: "エージェント",
2084
2203
  myAgent: "私のエージェント",
2085
2204
  agentOf: "{name} のエージェント",
2086
2205
  agentsTitle: "エージェント",
2087
2206
  inviteAgent: "エージェントを招待",
2088
- inviteAgentLine: "ルーム内でエージェントをサポート",
2207
+ inviteAgentLine: "グループ内でエージェントをサポート",
2089
2208
  pickAgentTitle: "「{title}」にエージェントを招待",
2090
- pickAgentLead: "ルーム内の誰もが @ で質問できます。自分が質問するとき、いつものようにディレクトリ内のツールで動作します;他の人が質問するとき、分身と同じくチャットのみが可能です。許可後はより多くを実行できます。",
2209
+ pickAgentLead: "グループ内の誰もが @ で質問できます。自分が質問するとき、いつものようにディレクトリ内のツールで動作します;他の人が質問するとき、分身と同じくチャットのみが可能です。許可後はより多くを実行できます。",
2091
2210
  noAgents: "エージェントがまだありません",
2092
2211
  noAgentsHint: "分身のサイドバーでエージェントを新規作成してください。",
2093
- inRoom: "ルームに参加済み",
2212
+ inRoom: "グループチャットに参加済み",
2094
2213
  joining: "参加中…",
2095
- joiningRoom: "{name} がルームに参加中…",
2214
+ joiningRoom: "{name} がグループチャットに参加中…",
2096
2215
  inviteFailed: "{name} を招待できませんでした:{error}",
2097
- dismiss: "ルームを出るようにリクエスト",
2216
+ dismiss: "グループチャットを出るようにリクエスト",
2098
2217
  dismissTitle: "{name} に「{title}」を出るようにリクエストしますか?",
2099
- dismissHint: "ルーム内でさようならを言い、その後、このルームの質問には応答しません。",
2100
- tryAlone: "エージェントを招待します:自分でルームを試すことができます。",
2218
+ dismissHint: "グループ内でさようならを言い、その後、このグループチャットの質問には応答しません。",
2219
+ tryAlone: "エージェントを招待します:自分でグループチャットを試すことができます。",
2101
2220
  agentAsked: "{name} が {agent} に質問",
2102
2221
  taskTag: "タスク",
2103
2222
  taskSent: "送信済み",
@@ -2114,9 +2233,9 @@ var JA2 = {
2114
2233
  taskWaitsFor: "{name} の許可を待機中",
2115
2234
  stopTask: "タスクを停止",
2116
2235
  cancelTask: "キャンセル",
2117
- openTaskRoom: "ルームを開く",
2236
+ openTaskRoom: "グループチャットを開く",
2118
2237
  forgetTask: "削除",
2119
- forgetTaskHint: "エントリのみが削除されます。ルーム内の会話は保持されます。",
2238
+ forgetTaskHint: "エントリのみが削除されます。グループ内の会話は保持されます。",
2120
2239
  taskResult: "{name} の分身のタスク",
2121
2240
  taskLog: "{name} がタスクを送信"
2122
2241
  };
@@ -2290,6 +2409,7 @@ function saidHello(chat, hello) {
2290
2409
  });
2291
2410
  }
2292
2411
  function AgentPicker({ room, close }) {
2412
+ const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
2293
2413
  const [agents, setAgents] = React.useState();
2294
2414
  const [error, setError] = React.useState();
2295
2415
  const inRoom = useAgents(room);
@@ -2310,9 +2430,7 @@ function AgentPicker({ room, close }) {
2310
2430
  className: "trm-dialog"
2311
2431
  }, /* @__PURE__ */ React.createElement("p", {
2312
2432
  className: "trm-note"
2313
- }, dt("pickAgentLead")), !agents && !error && pi.ui.Skeleton && /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
2314
- rows: 3
2315
- }), agents?.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
2433
+ }, dt("pickAgentLead")), !agents && !error && Loading && /* @__PURE__ */ React.createElement(Loading, null), agents?.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
2316
2434
  title: dt("noAgents"),
2317
2435
  hint: dt("noAgentsHint"),
2318
2436
  compact: true
@@ -3246,6 +3364,7 @@ function FriendRow({ friend }) {
3246
3364
  })));
3247
3365
  }
3248
3366
  function FriendsPage() {
3367
+ const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
3249
3368
  const { friends, friendRequests } = useBook();
3250
3369
  const Add = icon("UserPlus");
3251
3370
  if (!rooms()) {
@@ -3273,9 +3392,7 @@ function FriendsPage() {
3273
3392
  size: 14
3274
3393
  }), " ", t("addFriend"))) : /* @__PURE__ */ React.createElement("section", {
3275
3394
  className: "trm-section"
3276
- }, !!friends?.length && /* @__PURE__ */ React.createElement("h3", null, `${t("friends")} · ${friends.length}`), friends === undefined ? pi.ui.Skeleton ? /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
3277
- rows: 3
3278
- }) : null : /* @__PURE__ */ React.createElement("ul", {
3395
+ }, !!friends?.length && /* @__PURE__ */ React.createElement("h3", null, `${t("friends")} · ${friends.length}`), friends === undefined ? Loading ? /* @__PURE__ */ React.createElement(Loading, null) : null : /* @__PURE__ */ React.createElement("ul", {
3279
3396
  className: "trm-rooms"
3280
3397
  }, friends.map((friend) => /* @__PURE__ */ React.createElement(FriendRow, {
3281
3398
  key: friend.id,
@@ -3323,70 +3440,9 @@ function FriendsEntry() {
3323
3440
  size: 16
3324
3441
  }));
3325
3442
  }
3326
- function AddFriendDialog({ close }) {
3327
- const [link, setLink] = React.useState();
3328
- const [error, setError] = React.useState();
3329
- const [copied, setCopied] = React.useState(false);
3330
- const make = React.useCallback((renew) => {
3331
- setError(undefined);
3332
- setCopied(false);
3333
- rooms()?.friendLink(renew).then(setLink).catch((failure) => setError(message(failure)));
3334
- }, []);
3335
- React.useEffect(() => make(false), [make]);
3336
- const canSend = typeof navigator !== "undefined" && typeof navigator.share === "function";
3337
- const days = link ? Math.max(1, Math.round((link.expiresAt - Date.now()) / 86400000)) : 0;
3338
- const other = (read) => () => {
3339
- close();
3340
- read().then((text) => text && openFriendLink(text));
3341
- };
3342
- return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
3343
- title: t("addFriend"),
3344
- onClose: close
3345
- }, /* @__PURE__ */ React.createElement("div", {
3346
- className: "trm-dialog trm-invite"
3347
- }, link ? /* @__PURE__ */ React.createElement(React.Fragment, null, pi.ui.QrCode && /* @__PURE__ */ React.createElement("div", {
3348
- className: "trm-qr"
3349
- }, /* @__PURE__ */ React.createElement(pi.ui.QrCode, {
3350
- text: link.link,
3351
- label: t("qr")
3352
- })), /* @__PURE__ */ React.createElement("p", {
3353
- className: "trm-hint"
3354
- }, t("addFriendHint")), /* @__PURE__ */ React.createElement("p", {
3355
- className: "trm-hint trm-quiet"
3356
- }, t("addFriendExpires", { days })), /* @__PURE__ */ React.createElement("div", {
3357
- className: "trm-actions trm-center"
3358
- }, /* @__PURE__ */ React.createElement("button", {
3359
- type: "button",
3360
- className: "ta-button ta-primary",
3361
- onClick: () => void navigator.clipboard?.writeText(link.link).then(() => setCopied(true))
3362
- }, copied ? t("copied") : t("copy")), canSend && /* @__PURE__ */ React.createElement("button", {
3363
- type: "button",
3364
- className: "ta-button",
3365
- onClick: () => void navigator.share({ title: t("addFriend"), url: link.link }).catch(() => {
3366
- return;
3367
- })
3368
- }, t("send")), /* @__PURE__ */ React.createElement("button", {
3369
- type: "button",
3370
- className: "ta-button",
3371
- onClick: () => make(true)
3372
- }, t("newLink")))) : error ? /* @__PURE__ */ React.createElement("p", {
3373
- className: "trm-error"
3374
- }, error) : /* @__PURE__ */ React.createElement("p", {
3375
- className: "trm-hint"
3376
- }, t("making")), /* @__PURE__ */ React.createElement("div", {
3377
- className: "trm-actions trm-center trm-friends-other"
3378
- }, pi.ui.scanCode && /* @__PURE__ */ React.createElement("button", {
3379
- type: "button",
3380
- className: "trm-link",
3381
- onClick: other(async () => (await pi.ui.scanCode?.(t("scanHint")))?.trim())
3382
- }, t("scanFriend")), /* @__PURE__ */ React.createElement("button", {
3383
- type: "button",
3384
- className: "trm-link",
3385
- onClick: other(async () => (await pi.ui.input(t("pasteFriend"), t("joinByLinkPlaceholder")))?.trim())
3386
- }, t("pasteFriend")))));
3387
- }
3443
+ var ADD_FRIEND_VIEW = "@celljs/ta-rooms/add-friend";
3388
3444
  function openAddFriend() {
3389
- show(AddFriendDialog);
3445
+ pi.ui.showView(ADD_FRIEND_VIEW);
3390
3446
  }
3391
3447
  function FriendLinkDialog({ text, close }) {
3392
3448
  const link = RelayHubUtil.parse(text);
@@ -3430,9 +3486,6 @@ function FriendLinkDialog({ text, close }) {
3430
3486
  }
3431
3487
  function openFriendLink(text) {
3432
3488
  if (!isFriendLink(text)) {
3433
- if (!RelayHubUtil.is(text)) {
3434
- pi.ui.notify(t("notInvite"), "warning");
3435
- }
3436
3489
  return false;
3437
3490
  }
3438
3491
  show(({ close }) => /* @__PURE__ */ React.createElement(FriendLinkDialog, {
@@ -3441,6 +3494,53 @@ function openFriendLink(text) {
3441
3494
  }));
3442
3495
  return true;
3443
3496
  }
3497
+ function FriendDialog({ id, close }) {
3498
+ const { friends } = useBook();
3499
+ const friend = friends?.find((each) => each.id === id);
3500
+ React.useEffect(() => {
3501
+ if (friends && !friend) {
3502
+ close();
3503
+ }
3504
+ }, [friends, friend, close]);
3505
+ if (!friend) {
3506
+ return null;
3507
+ }
3508
+ const line = friend.status === "adding" ? t("friendAdding") : friend.online ? t("online") : undefined;
3509
+ const remove = () => void confirmThen(t("removeFriendTitle", { name: friend.name }), t("removeFriendHint"), t("removeFriend"), async () => {
3510
+ await rooms()?.removeFriend(friend.id);
3511
+ close();
3512
+ await book.load();
3513
+ });
3514
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
3515
+ title: t("friends"),
3516
+ onClose: close
3517
+ }, /* @__PURE__ */ React.createElement("div", {
3518
+ className: "trm-dialog"
3519
+ }, /* @__PURE__ */ React.createElement("div", {
3520
+ className: "trm-join"
3521
+ }, /* @__PURE__ */ React.createElement(Face, {
3522
+ id: friend.id,
3523
+ name: friend.name,
3524
+ size: 56,
3525
+ online: friend.status === "friend" ? friend.online : undefined
3526
+ }), /* @__PURE__ */ React.createElement("strong", {
3527
+ className: "trm-join-name"
3528
+ }, friend.name), line && /* @__PURE__ */ React.createElement("p", {
3529
+ className: "trm-lead"
3530
+ }, line)), /* @__PURE__ */ React.createElement("div", {
3531
+ className: "trm-actions trm-center"
3532
+ }, /* @__PURE__ */ React.createElement("button", {
3533
+ type: "button",
3534
+ className: "ta-button ta-danger",
3535
+ onClick: remove
3536
+ }, t("removeFriend")))));
3537
+ }
3538
+ function openFriend(id) {
3539
+ show(({ close }) => /* @__PURE__ */ React.createElement(FriendDialog, {
3540
+ id,
3541
+ close
3542
+ }));
3543
+ }
3444
3544
  function FriendRequestsDialog({ close }) {
3445
3545
  const { friendRequests } = useBook();
3446
3546
  const seen = React.useRef(false);
@@ -3644,49 +3744,26 @@ function JoinDialog({ link, text, close }) {
3644
3744
  function InviteDialog({ room, close }) {
3645
3745
  const [link, setLink] = React.useState();
3646
3746
  const [error, setError] = React.useState();
3647
- const [copied, setCopied] = React.useState(false);
3648
3747
  const make = React.useCallback((renew) => {
3649
3748
  setError(undefined);
3650
- setCopied(false);
3651
3749
  rooms()?.invite(room.id, renew ? { renew } : undefined).then((made) => setLink(made.link)).catch((failure) => setError(message(failure)));
3652
3750
  }, [room.id]);
3653
3751
  React.useEffect(() => make(false), [make]);
3654
- const canSend = typeof navigator !== "undefined" && typeof navigator.share === "function";
3655
- return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
3752
+ return /* @__PURE__ */ React.createElement(ShareSheetCompat, {
3753
+ pi,
3656
3754
  title: t("inviteTitle", { title: room.title }),
3755
+ link,
3756
+ error,
3757
+ face: /* @__PURE__ */ React.createElement(RoomFace, {
3758
+ room,
3759
+ size: 44
3760
+ }),
3761
+ name: room.title,
3762
+ gets: t("inviteGets"),
3763
+ notes: [t("inviteHint")],
3764
+ onRenew: () => make(true),
3657
3765
  onClose: close
3658
- }, /* @__PURE__ */ React.createElement("div", {
3659
- className: "trm-dialog trm-invite"
3660
- }, link ? /* @__PURE__ */ React.createElement(React.Fragment, null, pi.ui.QrCode && /* @__PURE__ */ React.createElement("div", {
3661
- className: "trm-qr"
3662
- }, /* @__PURE__ */ React.createElement(pi.ui.QrCode, {
3663
- text: link,
3664
- label: t("qr")
3665
- })), /* @__PURE__ */ React.createElement("p", {
3666
- className: "trm-hint"
3667
- }, t("inviteHint")), /* @__PURE__ */ React.createElement("div", {
3668
- className: "trm-link-box"
3669
- }, link), /* @__PURE__ */ React.createElement("div", {
3670
- className: "trm-actions trm-center"
3671
- }, /* @__PURE__ */ React.createElement("button", {
3672
- type: "button",
3673
- className: "ta-button ta-primary",
3674
- onClick: () => void navigator.clipboard?.writeText(link).then(() => setCopied(true))
3675
- }, copied ? t("copied") : t("copy")), canSend && /* @__PURE__ */ React.createElement("button", {
3676
- type: "button",
3677
- className: "ta-button",
3678
- onClick: () => void navigator.share({ title: room.title, url: link }).catch(() => {
3679
- return;
3680
- })
3681
- }, t("send")), /* @__PURE__ */ React.createElement("button", {
3682
- type: "button",
3683
- className: "ta-button",
3684
- onClick: () => make(true)
3685
- }, t("newLink")))) : error ? /* @__PURE__ */ React.createElement("p", {
3686
- className: "trm-error"
3687
- }, error) : /* @__PURE__ */ React.createElement("p", {
3688
- className: "trm-hint"
3689
- }, t("making"))));
3766
+ });
3690
3767
  }
3691
3768
  function openInvite(room) {
3692
3769
  show(({ close }) => /* @__PURE__ */ React.createElement(InviteDialog, {
@@ -3700,20 +3777,26 @@ function openJoin(text) {
3700
3777
  return;
3701
3778
  }
3702
3779
  const link = RelayHubUtil.parse(text);
3703
- const known = book.get().rooms?.find((room) => room.id === link.room && room.status === "member");
3704
- if (known) {
3705
- if (known.view) {
3706
- pi.ui.showView(known.view);
3780
+ const known = () => book.get().rooms?.find((room) => room.id === link.room && room.status === "member");
3781
+ const go = () => {
3782
+ const room = known();
3783
+ if (!room) {
3784
+ show(({ close }) => /* @__PURE__ */ React.createElement(JoinDialog, {
3785
+ link,
3786
+ text,
3787
+ close
3788
+ }));
3789
+ } else if (room.view) {
3790
+ pi.ui.showView(room.view);
3707
3791
  } else {
3708
- openRoom(known.id);
3792
+ openRoom(room.id);
3709
3793
  }
3710
- return;
3794
+ };
3795
+ if (known()) {
3796
+ go();
3797
+ } else {
3798
+ book.load().then(go, go);
3711
3799
  }
3712
- show(({ close }) => /* @__PURE__ */ React.createElement(JoinDialog, {
3713
- link,
3714
- text,
3715
- close
3716
- }));
3717
3800
  }
3718
3801
  async function createRoom() {
3719
3802
  const name = book.get().identity?.name;
@@ -3737,22 +3820,31 @@ async function pasteLink() {
3737
3820
  if (!text) {
3738
3821
  return;
3739
3822
  }
3740
- if (!RelayHubUtil.is(text)) {
3823
+ await openPasted(text);
3824
+ }
3825
+ async function openPasted(text) {
3826
+ const opened = pi.openLink ? await pi.openLink(text, { onlyTa: true }) : openHub(text);
3827
+ if (opened === false) {
3741
3828
  pi.ui.notify(t("notInvite"), "warning");
3742
- return;
3743
3829
  }
3744
- openJoin(text);
3830
+ }
3831
+ function openHub(text) {
3832
+ if (!RelayHubUtil.is(text)) {
3833
+ return false;
3834
+ }
3835
+ if (isFriendLink(text)) {
3836
+ openFriendLink(text);
3837
+ } else {
3838
+ openJoin(text);
3839
+ }
3840
+ return true;
3745
3841
  }
3746
3842
  async function scanLink() {
3747
3843
  const text = (await pi.ui.scanCode?.(t("scanHint")))?.trim();
3748
3844
  if (!text) {
3749
3845
  return;
3750
3846
  }
3751
- if (!RelayHubUtil.is(text)) {
3752
- pi.ui.notify(t("notInvite"), "warning");
3753
- return;
3754
- }
3755
- openJoin(text);
3847
+ await openPasted(text);
3756
3848
  }
3757
3849
  async function rename() {
3758
3850
  const identity = book.get().identity;
@@ -3766,6 +3858,296 @@ async function rename() {
3766
3858
  }
3767
3859
  }
3768
3860
 
3861
+ // web-src/add-friend-view.tsx
3862
+ var NEARBY_VIEW = "@celljs/ta-nearby/nearby";
3863
+ function MyCodeDialog({ close }) {
3864
+ const [link, setLink] = React.useState();
3865
+ const [error, setError] = React.useState();
3866
+ const { identity } = useBook();
3867
+ const make = React.useCallback((renew) => {
3868
+ setError(undefined);
3869
+ rooms()?.friendLink(renew).then(setLink).catch((failure) => setError(message(failure)));
3870
+ }, []);
3871
+ React.useEffect(() => make(false), [make]);
3872
+ const days = link ? Math.max(1, Math.round((link.expiresAt - Date.now()) / 86400000)) : 0;
3873
+ return /* @__PURE__ */ React.createElement(ShareSheetCompat, {
3874
+ pi,
3875
+ title: t("myCode"),
3876
+ link: link?.link,
3877
+ error,
3878
+ face: identity ? /* @__PURE__ */ React.createElement(Face, {
3879
+ id: identity.id,
3880
+ name: identity.name,
3881
+ size: 44
3882
+ }) : undefined,
3883
+ name: identity?.name,
3884
+ gets: t("myCodeGets"),
3885
+ notes: [link && t("addFriendExpires", { days })],
3886
+ onRenew: () => make(true),
3887
+ onClose: close
3888
+ });
3889
+ }
3890
+ function Way({ name, tint: tint2, title, line, onClick }) {
3891
+ const Icon = icon(name);
3892
+ const Chevron = icon("ChevronRight");
3893
+ return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
3894
+ type: "button",
3895
+ className: "trm-add-way",
3896
+ onClick
3897
+ }, /* @__PURE__ */ React.createElement("span", {
3898
+ className: `trm-add-way-icon trm-app-tint-${tint2}`
3899
+ }, /* @__PURE__ */ React.createElement(Icon, {
3900
+ size: 18
3901
+ })), /* @__PURE__ */ React.createElement("span", {
3902
+ className: "trm-row-text"
3903
+ }, /* @__PURE__ */ React.createElement("span", {
3904
+ className: "trm-row-title"
3905
+ }, title), /* @__PURE__ */ React.createElement("span", {
3906
+ className: "trm-row-line"
3907
+ }, line)), /* @__PURE__ */ React.createElement(Chevron, {
3908
+ size: 16
3909
+ })));
3910
+ }
3911
+ function AddFriendPage() {
3912
+ const [text, setText] = React.useState("");
3913
+ const pages = pi.ui.usePages();
3914
+ const nearby = pages.find((page) => page.id === NEARBY_VIEW);
3915
+ const LinkIcon = icon("Link");
3916
+ const QrCode = icon("QrCode");
3917
+ if (!rooms()) {
3918
+ return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
3919
+ title: t("oldApp")
3920
+ });
3921
+ }
3922
+ const submit = (value) => {
3923
+ const link = value.trim();
3924
+ if (link) {
3925
+ setText("");
3926
+ openPasted(link);
3927
+ }
3928
+ };
3929
+ const scan = async () => {
3930
+ const code = (await pi.ui.scanCode?.(t("scanHint")))?.trim();
3931
+ if (code) {
3932
+ openPasted(code);
3933
+ }
3934
+ };
3935
+ return /* @__PURE__ */ React.createElement("div", {
3936
+ className: "trm-list trm-friends-page trm-add"
3937
+ }, /* @__PURE__ */ React.createElement("form", {
3938
+ className: "trm-add-box",
3939
+ onSubmit: (event) => {
3940
+ event.preventDefault();
3941
+ submit(text);
3942
+ }
3943
+ }, /* @__PURE__ */ React.createElement(LinkIcon, {
3944
+ size: 15
3945
+ }), /* @__PURE__ */ React.createElement("input", {
3946
+ value: text,
3947
+ placeholder: t("addFriendPaste"),
3948
+ "aria-label": t("addFriendPaste"),
3949
+ enterKeyHint: "go",
3950
+ onChange: (event) => setText(event.target.value),
3951
+ onPaste: (event) => {
3952
+ const pasted = event.clipboardData.getData("text").trim();
3953
+ if (/^(https?|ta):\/\/\S+$/i.test(pasted)) {
3954
+ event.preventDefault();
3955
+ submit(pasted);
3956
+ }
3957
+ }
3958
+ }), text.trim() && /* @__PURE__ */ React.createElement("button", {
3959
+ type: "submit",
3960
+ className: "trm-link"
3961
+ }, t("addFriendOpen"))), /* @__PURE__ */ React.createElement("button", {
3962
+ type: "button",
3963
+ className: "trm-add-mine",
3964
+ onClick: () => show(MyCodeDialog)
3965
+ }, t("myCode"), /* @__PURE__ */ React.createElement(QrCode, {
3966
+ size: 15
3967
+ })), (pi.ui.scanCode || nearby) && /* @__PURE__ */ React.createElement("ul", {
3968
+ className: "trm-card trm-add-ways"
3969
+ }, pi.ui.scanCode && /* @__PURE__ */ React.createElement(Way, {
3970
+ name: "ScanLine",
3971
+ tint: 0,
3972
+ title: t("scan"),
3973
+ line: t("addFriendScan"),
3974
+ onClick: () => void scan()
3975
+ }), nearby && /* @__PURE__ */ React.createElement(Way, {
3976
+ name: "Radar",
3977
+ tint: 1,
3978
+ title: nearby.title,
3979
+ line: t("addFriendNearby"),
3980
+ onClick: () => void pi.ui.showView(NEARBY_VIEW)
3981
+ })), /* @__PURE__ */ React.createElement("p", {
3982
+ className: "trm-note"
3983
+ }, t("addFriendInGroup")));
3984
+ }
3985
+ function AddFriendHead() {
3986
+ return /* @__PURE__ */ React.createElement("div", {
3987
+ className: "trm-head trm-head-center"
3988
+ }, /* @__PURE__ */ React.createElement("span", {
3989
+ className: "trm-head-title"
3990
+ }, t("addFriend")));
3991
+ }
3992
+
3993
+ // web-src/group-invites.tsx
3994
+ function invitable(room, friends) {
3995
+ const inside = new Set(room.members.map((member) => member.id));
3996
+ return (friends ?? []).filter((friend) => friend.status === "friend" && !inside.has(friend.id));
3997
+ }
3998
+ function FriendPicker({ room, close }) {
3999
+ const { friends } = useBook();
4000
+ const [invited, setInvited] = React.useState([]);
4001
+ const [busy, setBusy] = React.useState();
4002
+ const [error, setError] = React.useState();
4003
+ const list = invitable(room, friends);
4004
+ const Plus = icon("Plus");
4005
+ const Check = icon("Check");
4006
+ const invite = (friend) => {
4007
+ const server = rooms();
4008
+ if (!server?.inviteFriends) {
4009
+ setError(t("inviteFriendsOld"));
4010
+ return;
4011
+ }
4012
+ setBusy(friend.id);
4013
+ setError(undefined);
4014
+ server.inviteFriends(room.id, [friend.id]).then(() => {
4015
+ setInvited((before) => [...before, friend.id]);
4016
+ setBusy(undefined);
4017
+ }, (failure) => {
4018
+ setError(message(failure));
4019
+ setBusy(undefined);
4020
+ });
4021
+ };
4022
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
4023
+ title: t("inviteFriendsTitle", { title: room.title }),
4024
+ onClose: close
4025
+ }, /* @__PURE__ */ React.createElement("div", {
4026
+ className: "trm-dialog"
4027
+ }, /* @__PURE__ */ React.createElement("p", {
4028
+ className: "trm-note"
4029
+ }, t("inviteFriendsLead")), list.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
4030
+ title: t("inviteFriendsNone"),
4031
+ compact: true
4032
+ }), list.length > 0 && /* @__PURE__ */ React.createElement("ul", {
4033
+ className: "trm-rows trm-agent-pick"
4034
+ }, list.map((friend) => {
4035
+ const done = invited.includes(friend.id);
4036
+ return /* @__PURE__ */ React.createElement("li", {
4037
+ key: friend.id
4038
+ }, /* @__PURE__ */ React.createElement("button", {
4039
+ type: "button",
4040
+ className: "trm-member",
4041
+ disabled: done || !!busy,
4042
+ onClick: () => invite(friend)
4043
+ }, /* @__PURE__ */ React.createElement(Face, {
4044
+ id: friend.id,
4045
+ name: friend.name,
4046
+ size: 34
4047
+ }), /* @__PURE__ */ React.createElement("span", {
4048
+ className: "trm-member-text"
4049
+ }, /* @__PURE__ */ React.createElement("span", {
4050
+ className: "trm-member-name trm-ellipsis"
4051
+ }, friend.name), /* @__PURE__ */ React.createElement("span", {
4052
+ className: "trm-member-detail trm-ellipsis"
4053
+ }, done ? t("invitedFriend") : t("friendTag"))), busy === friend.id ? /* @__PURE__ */ React.createElement("span", {
4054
+ className: "ta-spinner"
4055
+ }) : done ? /* @__PURE__ */ React.createElement(Check, {
4056
+ size: 16
4057
+ }) : /* @__PURE__ */ React.createElement(Plus, {
4058
+ size: 16
4059
+ })));
4060
+ })), error && /* @__PURE__ */ React.createElement("p", {
4061
+ className: "trm-error"
4062
+ }, error)));
4063
+ }
4064
+ function openFriendPicker(room) {
4065
+ show(({ close }) => /* @__PURE__ */ React.createElement(FriendPicker, {
4066
+ room,
4067
+ close
4068
+ }));
4069
+ }
4070
+ function InviteDialog2({ invite, close }) {
4071
+ const [busy, setBusy] = React.useState(false);
4072
+ const [error, setError] = React.useState();
4073
+ const answer = (accept) => {
4074
+ setBusy(true);
4075
+ setError(undefined);
4076
+ Promise.resolve(rooms()?.answerGroupInvite?.(invite.room, accept)).then(async () => {
4077
+ await book.load();
4078
+ close();
4079
+ if (accept) {
4080
+ openRoom(invite.room, true);
4081
+ }
4082
+ }).catch((failure) => {
4083
+ setError(message(failure));
4084
+ setBusy(false);
4085
+ });
4086
+ };
4087
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
4088
+ title: t("groupInviteTitle"),
4089
+ onClose: close
4090
+ }, /* @__PURE__ */ React.createElement("div", {
4091
+ className: "trm-dialog"
4092
+ }, /* @__PURE__ */ React.createElement("div", {
4093
+ className: "trm-invite-who"
4094
+ }, /* @__PURE__ */ React.createElement(Face, {
4095
+ id: invite.by.id,
4096
+ name: invite.by.name,
4097
+ size: 44
4098
+ }), /* @__PURE__ */ React.createElement("span", {
4099
+ className: "trm-member-text"
4100
+ }, /* @__PURE__ */ React.createElement("span", {
4101
+ className: "trm-member-name trm-ellipsis"
4102
+ }, invite.title), /* @__PURE__ */ React.createElement("span", {
4103
+ className: "trm-member-detail trm-ellipsis"
4104
+ }, t("groupInviteLine", { name: invite.by.name })))), /* @__PURE__ */ React.createElement("p", {
4105
+ className: "trm-note"
4106
+ }, t("groupInviteNote")), error && /* @__PURE__ */ React.createElement("p", {
4107
+ className: "trm-error"
4108
+ }, error), /* @__PURE__ */ React.createElement("div", {
4109
+ className: "trm-actions"
4110
+ }, /* @__PURE__ */ React.createElement("button", {
4111
+ type: "button",
4112
+ className: "ta-button",
4113
+ disabled: busy,
4114
+ onClick: () => answer(false)
4115
+ }, t("groupInviteIgnore")), /* @__PURE__ */ React.createElement("button", {
4116
+ type: "button",
4117
+ className: "ta-button ta-primary",
4118
+ disabled: busy,
4119
+ onClick: () => answer(true)
4120
+ }, busy ? /* @__PURE__ */ React.createElement("span", {
4121
+ className: "ta-spinner"
4122
+ }) : t("groupInviteJoin")))));
4123
+ }
4124
+ function GroupInviteRow({ invite }) {
4125
+ return /* @__PURE__ */ React.createElement("li", {
4126
+ className: "trm-row"
4127
+ }, /* @__PURE__ */ React.createElement(Face, {
4128
+ id: invite.by.id,
4129
+ name: invite.by.name
4130
+ }), /* @__PURE__ */ React.createElement("div", {
4131
+ className: "trm-row-text"
4132
+ }, /* @__PURE__ */ React.createElement("span", {
4133
+ className: "trm-row-title"
4134
+ }, invite.title), /* @__PURE__ */ React.createElement("span", {
4135
+ className: "trm-row-line"
4136
+ }, t("groupInviteLine", { name: invite.by.name }))), /* @__PURE__ */ React.createElement("div", {
4137
+ className: "trm-answers"
4138
+ }, /* @__PURE__ */ React.createElement("button", {
4139
+ type: "button",
4140
+ className: "ta-button ta-primary",
4141
+ onClick: () => openGroupInvite(invite)
4142
+ }, t("groupInviteJoin"))));
4143
+ }
4144
+ function openGroupInvite(invite) {
4145
+ show(({ close }) => /* @__PURE__ */ React.createElement(InviteDialog2, {
4146
+ invite,
4147
+ close
4148
+ }));
4149
+ }
4150
+
3769
4151
  // web-src/members-view.tsx
3770
4152
  function MemberRow({ room, member }) {
3771
4153
  const Remove = icon("X");
@@ -3913,6 +4295,7 @@ function MembersView() {
3913
4295
  }
3914
4296
  const Plus = icon("Plus");
3915
4297
  const Bot = icon("Bot");
4298
+ const Contact = icon("Contact");
3916
4299
  const online = room.members.filter((member) => member.online).length;
3917
4300
  const self = room.members.find((member) => member.self)?.member;
3918
4301
  return /* @__PURE__ */ React.createElement("div", {
@@ -3939,7 +4322,21 @@ function MembersView() {
3939
4322
  className: "trm-panel-label"
3940
4323
  }, t("membersCount", { n: room.members.length, online })), /* @__PURE__ */ React.createElement("ul", {
3941
4324
  className: "trm-panel-members"
3942
- }, room.owner && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
4325
+ }, room.owner && !!pi.rooms && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
4326
+ type: "button",
4327
+ className: "trm-member trm-member-add",
4328
+ onClick: () => openFriendPicker(room)
4329
+ }, /* @__PURE__ */ React.createElement("span", {
4330
+ className: "trm-member-plus"
4331
+ }, /* @__PURE__ */ React.createElement(Contact, {
4332
+ size: 16
4333
+ })), /* @__PURE__ */ React.createElement("span", {
4334
+ className: "trm-member-text"
4335
+ }, /* @__PURE__ */ React.createElement("span", {
4336
+ className: "trm-member-name"
4337
+ }, t("inviteFriends")), /* @__PURE__ */ React.createElement("span", {
4338
+ className: "trm-member-detail"
4339
+ }, t("inviteFriendsLine"))))), room.owner && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
3943
4340
  type: "button",
3944
4341
  className: "trm-member trm-member-add",
3945
4342
  onClick: () => openInvite(room)
@@ -4004,7 +4401,94 @@ function MembersView() {
4004
4401
  }, room.owner ? t("close") : t("leave"))));
4005
4402
  }
4006
4403
 
4404
+ // web-src/friend-shares.tsx
4405
+ var FriendShares;
4406
+ ((FriendShares) => {
4407
+ let list = [];
4408
+ const listeners = new Set;
4409
+ FriendShares.get = () => list;
4410
+ function subscribe(listener) {
4411
+ listeners.add(listener);
4412
+ return () => listeners.delete(listener);
4413
+ }
4414
+ FriendShares.subscribe = subscribe;
4415
+ async function load() {
4416
+ const server = rooms();
4417
+ if (!server?.listFriendShares) {
4418
+ return;
4419
+ }
4420
+ list = await server.listFriendShares().catch(() => list);
4421
+ for (const listener of listeners) {
4422
+ listener();
4423
+ }
4424
+ }
4425
+ FriendShares.load = load;
4426
+ function start() {
4427
+ load();
4428
+ return pi.onRoomEvent?.((event) => event.type === "rooms" && void load(), { messages: false }) ?? (() => {
4429
+ return;
4430
+ });
4431
+ }
4432
+ FriendShares.start = start;
4433
+ })(FriendShares ||= {});
4434
+ function FriendShareDialog({ share, close }) {
4435
+ const [busy, setBusy] = React.useState(false);
4436
+ const answer = (keep) => {
4437
+ setBusy(true);
4438
+ Promise.resolve(rooms()?.answerFriendShare(share.id, keep)).then(() => {
4439
+ close();
4440
+ if (keep) {
4441
+ pi.openLink?.(share.link);
4442
+ }
4443
+ }).catch((failure) => {
4444
+ pi.ui.notify(message(failure), "error");
4445
+ setBusy(false);
4446
+ });
4447
+ };
4448
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
4449
+ title: t("friendShareTitle", { name: share.by.name }),
4450
+ onClose: close
4451
+ }, /* @__PURE__ */ React.createElement("div", {
4452
+ className: "trm-dialog"
4453
+ }, /* @__PURE__ */ React.createElement("div", {
4454
+ className: "trm-invite-who"
4455
+ }, /* @__PURE__ */ React.createElement(Face, {
4456
+ id: share.by.id,
4457
+ name: share.by.name,
4458
+ size: 44
4459
+ }), /* @__PURE__ */ React.createElement("span", {
4460
+ className: "trm-member-text"
4461
+ }, /* @__PURE__ */ React.createElement("span", {
4462
+ className: "trm-member-name trm-ellipsis"
4463
+ }, share.title || share.link), /* @__PURE__ */ React.createElement("span", {
4464
+ className: "trm-member-detail trm-ellipsis"
4465
+ }, t("friendShareLine", { name: share.by.name })))), /* @__PURE__ */ React.createElement("p", {
4466
+ className: "trm-note"
4467
+ }, t("friendShareNote")), /* @__PURE__ */ React.createElement("div", {
4468
+ className: "trm-actions"
4469
+ }, /* @__PURE__ */ React.createElement("button", {
4470
+ type: "button",
4471
+ className: "ta-button ta-danger",
4472
+ disabled: busy,
4473
+ onClick: () => answer(false)
4474
+ }, t("friendShareDelete")), /* @__PURE__ */ React.createElement("button", {
4475
+ type: "button",
4476
+ className: "ta-button ta-primary",
4477
+ disabled: busy,
4478
+ onClick: () => answer(true)
4479
+ }, t("friendShareOpen")))));
4480
+ }
4481
+ function openFriendShare(share) {
4482
+ show(({ close }) => /* @__PURE__ */ React.createElement(FriendShareDialog, {
4483
+ share,
4484
+ close
4485
+ }));
4486
+ }
4487
+
4007
4488
  // web-src/rooms-page.tsx
4489
+ function partners() {
4490
+ return !!pi.ui.doubleInChats;
4491
+ }
4008
4492
  function plain(text) {
4009
4493
  return text.replace(/```[\s\S]*?(```|$)/g, " ").replace(/[*_~`>#]+/g, "").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\s+/g, " ").trim();
4010
4494
  }
@@ -4078,7 +4562,8 @@ function RoomRow({ room, active, seen, openMenu }) {
4078
4562
  }, preview))));
4079
4563
  }
4080
4564
  function RoomList({ openMenu }) {
4081
- const { identity, rooms: list, requests, opened, seen } = useBook();
4565
+ const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
4566
+ const { identity, rooms: list, requests, groupInvites, opened, seen } = useBook();
4082
4567
  const { asks } = useDoubles();
4083
4568
  const sorted = useSorted(list ?? []);
4084
4569
  return /* @__PURE__ */ React.createElement("div", {
@@ -4090,6 +4575,13 @@ function RoomList({ openMenu }) {
4090
4575
  }, asks.map((ask) => /* @__PURE__ */ React.createElement(AskRow, {
4091
4576
  key: ask.id,
4092
4577
  ask
4578
+ })))), groupInvites.length > 0 && /* @__PURE__ */ React.createElement("section", {
4579
+ className: "trm-section"
4580
+ }, /* @__PURE__ */ React.createElement("h3", null, t("groupInviteTitle")), /* @__PURE__ */ React.createElement("ul", {
4581
+ className: "trm-card"
4582
+ }, groupInvites.map((invite) => /* @__PURE__ */ React.createElement(GroupInviteRow, {
4583
+ key: invite.room,
4584
+ invite
4093
4585
  })))), requests.length > 0 && /* @__PURE__ */ React.createElement("section", {
4094
4586
  className: "trm-section"
4095
4587
  }, /* @__PURE__ */ React.createElement("h3", null, t("requests")), /* @__PURE__ */ React.createElement("ul", {
@@ -4099,9 +4591,7 @@ function RoomList({ openMenu }) {
4099
4591
  request
4100
4592
  })))), /* @__PURE__ */ React.createElement("section", {
4101
4593
  className: "trm-section"
4102
- }, /* @__PURE__ */ React.createElement("h3", null, t("roomsTitle")), list === undefined ? pi.ui.Skeleton ? /* @__PURE__ */ React.createElement(pi.ui.Skeleton, {
4103
- rows: 3
4104
- }) : null : sorted.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
4594
+ }, /* @__PURE__ */ React.createElement("h3", null, t("roomsTitle")), list === undefined ? Loading ? /* @__PURE__ */ React.createElement(Loading, null) : null : sorted.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
4105
4595
  compact: true,
4106
4596
  title: t("emptyTitle"),
4107
4597
  hint: t("emptyListHint")
@@ -4149,6 +4639,13 @@ function RoomsHead() {
4149
4639
  }, /* @__PURE__ */ React.createElement(Plus, {
4150
4640
  size: 18
4151
4641
  }));
4642
+ if (partners() && (!compact || opened)) {
4643
+ return /* @__PURE__ */ React.createElement("div", {
4644
+ className: "trm-head"
4645
+ }, opened && /* @__PURE__ */ React.createElement(RoomHead, {
4646
+ room: opened
4647
+ }));
4648
+ }
4152
4649
  if (compact && opened && (pi.ui.Stack || book.get().direct)) {
4153
4650
  return /* @__PURE__ */ React.createElement("div", {
4154
4651
  className: "trm-head"
@@ -4206,6 +4703,15 @@ function RoomsPage() {
4206
4703
  openMenu
4207
4704
  });
4208
4705
  const close = () => book.set({ opened: undefined });
4706
+ if (partners() && (!compact || opened)) {
4707
+ return opened ? /* @__PURE__ */ React.createElement(RoomView, {
4708
+ key: opened.id,
4709
+ room: opened,
4710
+ head: false
4711
+ }) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
4712
+ title: t("pickRoom")
4713
+ });
4714
+ }
4209
4715
  if (!compact) {
4210
4716
  return /* @__PURE__ */ React.createElement("div", {
4211
4717
  className: "trm-split"
@@ -4267,12 +4773,16 @@ function homeFace(id) {
4267
4773
  }
4268
4774
 
4269
4775
  class RoomsHome {
4776
+ partners;
4270
4777
  current = [];
4271
4778
  signature = "";
4272
4779
  shown = true;
4273
4780
  listeners = new Set;
4274
4781
  chats = new Map;
4275
4782
  faces = new Map;
4783
+ constructor(partners2 = false) {
4784
+ this.partners = partners2;
4785
+ }
4276
4786
  items = () => this.current;
4277
4787
  subscribe = (listener) => {
4278
4788
  this.listeners.add(listener);
@@ -4280,11 +4790,19 @@ class RoomsHome {
4280
4790
  };
4281
4791
  start() {
4282
4792
  const stopBook = book.subscribe(() => this.refresh());
4793
+ const stopShares = this.partners ? FriendShares.subscribe(() => this.refresh()) : () => {
4794
+ return;
4795
+ };
4796
+ const stopSharesLoad = this.partners ? FriendShares.start() : () => {
4797
+ return;
4798
+ };
4283
4799
  const stopStorage = pi.storage.onChange((keys) => keys.includes(HOME_KEY) && this.readShown());
4284
4800
  this.readShown();
4285
4801
  this.refresh();
4286
4802
  return () => {
4287
4803
  stopBook();
4804
+ stopShares();
4805
+ stopSharesLoad();
4288
4806
  stopStorage();
4289
4807
  for (const stop of this.chats.values()) {
4290
4808
  stop();
@@ -4301,16 +4819,33 @@ class RoomsHome {
4301
4819
  });
4302
4820
  }
4303
4821
  refresh() {
4304
- const { rooms: rooms2 = [], seen } = book.get();
4305
- const joined = this.shown ? rooms2.filter((room) => room.status === "member") : [];
4822
+ const { rooms: rooms2 = [], seen, friends, friendRequests, requests, groupInvites } = book.get();
4823
+ const sent = this.partners ? FriendShares.get() : [];
4824
+ const joined = this.shown || this.partners ? rooms2.filter((room) => room.status === "member") : [];
4306
4825
  this.follow(joined);
4307
4826
  const rows = joined.map((room) => ({ room, lines: book.chat(room.id)?.lines ?? [] })).sort((a, b) => lastAt(b.room) - lastAt(a.room));
4308
- const signature = rows.map(({ room, lines }) => [room.id, room.title, lines.at(-1)?.id ?? "", unseen(room, lines, seen) ? 1 : 0, room.connected ? 1 : 0, room.members.length].join(":")).join("|");
4827
+ const signature = [
4828
+ this.partners ? [
4829
+ ...(friends ?? []).map((friend) => [friend.id, friend.name, friend.look, friend.status, friend.online ? 1 : 0].join("/")),
4830
+ ...friendRequests.map((request) => request.id),
4831
+ ...requests.map((request) => `${request.room}/${request.ask}`),
4832
+ ...groupInvites.map((invite) => invite.room),
4833
+ ...sent.map((share) => `${share.id}/${share.seen ? 1 : 0}`)
4834
+ ].join(",") : "",
4835
+ ...rows.map(({ room, lines }) => [room.id, room.title, lines.at(-1)?.id ?? "", unseen(room, lines, seen) ? 1 : 0, room.connected ? 1 : 0, room.members.length].join(":"))
4836
+ ].join("|");
4309
4837
  if (signature === this.signature) {
4310
4838
  return;
4311
4839
  }
4312
4840
  this.signature = signature;
4313
- this.current = rows.map(({ room, lines }) => this.item(room, lines, unseen(room, lines, seen)));
4841
+ this.current = [
4842
+ ...this.partners ? friendRequests.map((request) => this.askingFriend(request)) : [],
4843
+ ...this.partners ? requests.map((request) => this.asking(request)) : [],
4844
+ ...this.partners ? groupInvites.map((invite) => this.invited(invite)) : [],
4845
+ ...sent.map((share) => this.sharedBy(share)),
4846
+ ...rows.map(({ room, lines }) => this.item(room, lines, unseen(room, lines, seen))),
4847
+ ...this.partners ? (friends ?? []).map((friend) => this.friend(friend)) : []
4848
+ ];
4314
4849
  for (const listener of this.listeners) {
4315
4850
  listener();
4316
4851
  }
@@ -4328,11 +4863,98 @@ class RoomsHome {
4328
4863
  icon: icon("Users"),
4329
4864
  face,
4330
4865
  section: t("roomsTitle"),
4866
+ ...this.partners ? { place: "groups" } : {},
4331
4867
  at: lastAt(room),
4332
4868
  unseen: fresh,
4333
4869
  open: () => openRoom(room.id, true)
4334
4870
  };
4335
4871
  }
4872
+ askingFriend(request) {
4873
+ return {
4874
+ id: `friend-request:${request.id}`,
4875
+ title: request.name,
4876
+ detail: request.via === "room" && request.room ? t("friendRequestRoom", { room: request.room }) : t("friendRequestLink"),
4877
+ icon: icon("UserPlus"),
4878
+ face: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
4879
+ id: request.id,
4880
+ name: request.name,
4881
+ size
4882
+ }),
4883
+ unseen: true,
4884
+ at: request.at,
4885
+ place: "partners",
4886
+ open: openFriendRequests
4887
+ };
4888
+ }
4889
+ friend(friend) {
4890
+ const online = friend.status === "friend" ? friend.online : undefined;
4891
+ return {
4892
+ id: `friend:${friend.id}`,
4893
+ title: friend.name,
4894
+ ...friend.status === "adding" ? { detail: t("friendAdding") } : {},
4895
+ icon: icon("Contact"),
4896
+ face: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
4897
+ id: friend.id,
4898
+ name: friend.name,
4899
+ size,
4900
+ online
4901
+ }),
4902
+ section: t("friends"),
4903
+ place: "partners",
4904
+ open: () => openFriend(friend.id)
4905
+ };
4906
+ }
4907
+ asking(request) {
4908
+ return {
4909
+ id: `request:${request.room}:${request.ask}`,
4910
+ title: request.name,
4911
+ detail: t("requestLine", { title: request.title }),
4912
+ icon: icon("UserPlus"),
4913
+ face: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
4914
+ id: request.id,
4915
+ name: request.name,
4916
+ size
4917
+ }),
4918
+ unseen: true,
4919
+ at: request.at,
4920
+ place: "groups",
4921
+ open: openRequests
4922
+ };
4923
+ }
4924
+ invited(invite) {
4925
+ return {
4926
+ id: `invite:${invite.room}`,
4927
+ title: invite.title,
4928
+ detail: t("groupInviteLine", { name: invite.by.name }),
4929
+ icon: icon("MessagesSquare"),
4930
+ face: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
4931
+ id: invite.by.id,
4932
+ name: invite.by.name,
4933
+ size
4934
+ }),
4935
+ unseen: true,
4936
+ at: invite.at,
4937
+ place: "groups",
4938
+ open: () => openGroupInvite(invite)
4939
+ };
4940
+ }
4941
+ sharedBy(share) {
4942
+ return {
4943
+ id: `share:${share.id}`,
4944
+ title: share.by.name,
4945
+ detail: t("friendShareRow", { title: share.title || share.link }),
4946
+ icon: icon("Send"),
4947
+ face: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
4948
+ id: share.by.id,
4949
+ name: share.by.name,
4950
+ size
4951
+ }),
4952
+ unseen: !share.seen,
4953
+ at: share.at,
4954
+ place: "partners",
4955
+ open: () => openFriendShare(share)
4956
+ };
4957
+ }
4336
4958
  follow(joined) {
4337
4959
  const ids = new Set(joined.map((room) => room.id));
4338
4960
  for (const [id, stop] of this.chats) {
@@ -4561,10 +5183,10 @@ button.trm-member { cursor: pointer; }
4561
5183
  .trm-hint { text-align: center; color: var(--ta-secondary); }
4562
5184
  .trm-error { margin: 0; color: var(--ta-red); font-size: calc(12.5px * var(--ta-font-scale)); }
4563
5185
  .trm-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
5186
+ .trm-invite-who { display: flex; align-items: center; gap: 12px; }
4564
5187
  .trm-center { justify-content: center; }
4565
5188
  .trm-join { display: flex; align-items: center; gap: 12px; }
4566
5189
  .trm-friends-page { max-width: var(--ta-page-width); margin: 0 auto; width: 100%; overflow-y: auto; height: 100%; }
4567
- .trm-friends-other { gap: 18px; padding-top: 4px; }
4568
5190
  .trm-friends-entry { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--ta-surface, transparent); color: inherit; font: inherit; cursor: pointer; text-align: left; }
4569
5191
  @media (hover: hover) { .trm-friends-entry:hover { background: var(--ta-hover); } }
4570
5192
  .trm-friends-entry-label { font-weight: 500; }
@@ -4573,10 +5195,17 @@ button.trm-member { cursor: pointer; }
4573
5195
  .trm-join-name { font-size: calc(15px * var(--ta-font-scale)); }
4574
5196
  .trm-dialog .trm-join:has(.trm-join-name) { flex-direction: column; text-align: center; gap: 8px; }
4575
5197
  .trm-member-friend { color: var(--ta-muted); }
4576
- .trm-invite { align-items: stretch; }
4577
- .trm-qr { align-self: center; width: 188px; padding: 10px; border-radius: 14px; background: #fff; border: 1px solid var(--ta-border-muted); }
4578
- .trm-qr svg { display: block; width: 100%; height: auto; }
4579
- .trm-link-box { padding: 8px 10px; border-radius: 8px; background: var(--ta-code); font-family: var(--ta-mono); font-size: calc(11.5px * var(--ta-font-scale)); color: var(--ta-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
5198
+ /* Add friend (AddFriendPage): the box for a link, the user's code under it, the ways as rows of a card */
5199
+ .trm-add { gap: 12px; padding-top: 10px; }
5200
+ .trm-add > .trm-note { padding: 0 8px; }
5201
+ .trm-add-box { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px 0 12px; border-radius: 10px; background: var(--ta-raised); color: var(--ta-muted); }
5202
+ .trm-add-box input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: none; color: var(--ta-text); font: inherit; }
5203
+ .trm-add-mine { align-self: center; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 0; border-radius: 8px; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(13px * var(--ta-font-scale)); cursor: pointer; }
5204
+ .trm-add-ways > li + li { border-top: 1px solid var(--ta-border-muted); }
5205
+ .trm-add-way { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 6px; border: 0; background: none; color: var(--ta-text); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
5206
+ .trm-add-way > svg:last-child { flex: none; color: var(--ta-muted); }
5207
+ .trm-add-way-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; }
5208
+ @media (hover: hover) { .trm-add-mine:hover { background: var(--ta-hover); } .trm-add-way:hover { border-radius: 10px; background: var(--ta-hover); } }
4580
5209
  .trm-dialog .trm-row { padding: 8px 0; }
4581
5210
  /* The doubles (docs/design/ta-link.md 4): what a double says, its permissions, its log */
4582
5211
  .trm-tag-double { margin-left: 6px; background: var(--ta-tint-3); color: var(--ta-tint-ink-3); }
@@ -4675,13 +5304,14 @@ function activate(pi2) {
4675
5304
  bind(pi2.React);
4676
5305
  bindPage(pi2);
4677
5306
  const removeStyle = injectStyle();
5307
+ const partners2 = !!pi2.ui.doubleInChats;
5308
+ const place = partners2 ? { navigation: false } : { group: "people" };
4678
5309
  pi2.registerView("rooms", {
4679
5310
  title: () => t("roomsTitle"),
4680
5311
  icon: icon("Users"),
4681
5312
  render: RoomsPage,
4682
5313
  head: RoomsHead,
4683
- discover: true,
4684
- group: "people",
5314
+ ...place,
4685
5315
  order: 81
4686
5316
  });
4687
5317
  pi2.registerView("friends", {
@@ -4689,10 +5319,10 @@ function activate(pi2) {
4689
5319
  icon: icon("Contact"),
4690
5320
  render: FriendsPage,
4691
5321
  head: FriendsHead,
4692
- discover: true,
4693
- group: "people",
5322
+ ...place,
4694
5323
  order: 79
4695
5324
  });
5325
+ pi2.registerView("add-friend", { title: () => t("addFriend"), icon: icon("UserPlus"), render: AddFriendPage, head: AddFriendHead, navigation: false });
4696
5326
  pi2.registerView("members", { title: () => t("membersTitle"), icon: icon("Users"), render: MembersView, location: "panel", order: 90 });
4697
5327
  pi2.registerView(DOUBLES_VIEW.slice(DOUBLES_VIEW.lastIndexOf("/") + 1), {
4698
5328
  title: () => dt("logTitle"),
@@ -4701,8 +5331,10 @@ function activate(pi2) {
4701
5331
  location: "panel",
4702
5332
  order: 91
4703
5333
  });
4704
- pi2.registerSettings(roomsSettings());
4705
- const home = new RoomsHome;
5334
+ if (!partners2) {
5335
+ pi2.registerSettings(roomsSettings());
5336
+ }
5337
+ const home = new RoomsHome(partners2);
4706
5338
  const stopHome = pi2.rooms ? home.start() : () => {
4707
5339
  return;
4708
5340
  };