pi-roundtable-web 0.29.2 → 0.30.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 (215) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +3 -3
  3. package/dist/chunk-account-51nmc9g6.js +1 -0
  4. package/dist/{chunk-action-menu-37zgbhje.js → chunk-action-menu-mxcvx4a1.js} +1 -1
  5. package/dist/chunk-agent-x53f7c2h.js +1 -0
  6. package/dist/chunk-arranged-rooms-1w3zqdtt.js +1 -0
  7. package/dist/{chunk-attachments-3vbj05g5.js → chunk-attachments-qbv5ar62.js} +2 -2
  8. package/dist/chunk-bulk-actions-aktwxqc9.js +1 -0
  9. package/dist/{chunk-character-creator-bg3tdc8p.js → chunk-character-creator-1mfybhjz.js} +2 -2
  10. package/dist/{chunk-codeeditor-102wa9bj.js → chunk-codeeditor-y2emmmr0.js} +2 -2
  11. package/dist/chunk-command-menu-sj2kfe4d.js +59 -0
  12. package/dist/chunk-confirm-ex5kc1st.js +1 -0
  13. package/dist/{chunk-connectors-0jzzren3.js → chunk-connectors-1nmm8yc3.js} +2 -2
  14. package/dist/{chunk-conversations-3276jq4q.js → chunk-conversations-ec3aqjxs.js} +1 -1
  15. package/dist/chunk-council-sheet-hdsg3fes.js +2 -0
  16. package/dist/chunk-council-view-sba8fs4c.js +1 -0
  17. package/dist/{chunk-drag-sw692nr3.js → chunk-drag-pkghf4ts.js} +1 -1
  18. package/dist/{chunk-entry-mb6jd983.js → chunk-entry-e24gjxtd.js} +1 -1
  19. package/dist/{chunk-folder-list-g7st6p1e.js → chunk-folder-list-kghgyc0x.js} +1 -1
  20. package/dist/chunk-folds-crd9k375.js +1 -0
  21. package/dist/chunk-gate-xay9vedw.js +1 -0
  22. package/dist/chunk-host-icons-y9hd1qqd.js +1 -0
  23. package/dist/chunk-host-picture-k16n5wm3.js +1 -0
  24. package/dist/chunk-host-state-1mbsrmhk.js +1 -0
  25. package/dist/chunk-host-ui-4pymhn6v.js +1 -0
  26. package/dist/{chunk-index-e8535c4h.js → chunk-index-0dyf2gdm.js} +2 -2
  27. package/dist/chunk-index-14cxgacv.js +2 -0
  28. package/dist/{chunk-index-edjyj761.js → chunk-index-37g8ggry.js} +1 -1
  29. package/dist/chunk-index-39gw0qhr.js +2 -0
  30. package/dist/chunk-index-4p45h04z.js +2 -0
  31. package/dist/chunk-index-5e8wn6r3.js +2 -0
  32. package/dist/chunk-index-65p4hfkr.js +2 -0
  33. package/dist/{chunk-index-6yfcfcc8.js → chunk-index-6e9nmad3.js} +1 -1
  34. package/dist/chunk-index-6f4qvp5p.js +2 -0
  35. package/dist/{chunk-index-yn1vvxj2.js → chunk-index-6hy2fabj.js} +1 -1
  36. package/dist/{chunk-index-0qzqzp6t.js → chunk-index-6j75embz.js} +2 -2
  37. package/dist/{chunk-index-1tkzdy4s.js → chunk-index-70pq2k7q.js} +2 -2
  38. package/dist/{chunk-index-7gk2sdf4.js → chunk-index-726w3145.js} +3 -3
  39. package/dist/chunk-index-86x6b7dx.js +3 -0
  40. package/dist/chunk-index-8cxmgzhy.js +2 -0
  41. package/dist/{chunk-index-gmbk3sra.js → chunk-index-93dr9fh8.js} +1 -1
  42. package/dist/chunk-index-97238pp8.js +2 -0
  43. package/dist/{chunk-index-7p31pda8.js → chunk-index-ads1abh1.js} +3 -3
  44. package/dist/{chunk-index-jrj09r5c.js → chunk-index-awc03q99.js} +2 -2
  45. package/dist/chunk-index-bh6m0bpm.js +2 -0
  46. package/dist/chunk-index-br1wechm.js +2 -0
  47. package/dist/{chunk-index-qedt9szy.js → chunk-index-c8vsw9h8.js} +2 -2
  48. package/dist/{chunk-index-mey1p7h8.js → chunk-index-cd0ymvtj.js} +2 -2
  49. package/dist/{chunk-index-50w6yq2d.js → chunk-index-e3encn5p.js} +1 -1
  50. package/dist/{chunk-index-d941ae7c.js → chunk-index-fw6kawhw.js} +2 -2
  51. package/dist/{chunk-index-6ycrvwzs.js → chunk-index-g3f1sdw0.js} +2 -2
  52. package/dist/{chunk-index-6cs1wvhy.js → chunk-index-gae833v6.js} +1 -1
  53. package/dist/{chunk-index-m8bv51r9.js → chunk-index-gc30hm37.js} +2 -2
  54. package/dist/{chunk-index-5fyqxh0r.js → chunk-index-gpaychmm.js} +2 -2
  55. package/dist/chunk-index-hk6aq03d.js +2 -0
  56. package/dist/chunk-index-k3hj2310.js +2 -0
  57. package/dist/chunk-index-maf6wr1b.js +2 -0
  58. package/dist/{chunk-index-eyythjdx.js → chunk-index-mhb8mpg3.js} +2 -2
  59. package/dist/chunk-index-n92zea3s.js +2 -0
  60. package/dist/{chunk-index-m7wzrmcd.js → chunk-index-ndhwytvz.js} +2 -2
  61. package/dist/{chunk-index-qk7rp7fk.js → chunk-index-ne8v2rxx.js} +12 -12
  62. package/dist/chunk-index-p4rc9swx.js +2 -0
  63. package/dist/chunk-index-pce4byw4.js +2 -0
  64. package/dist/{chunk-index-6nja2vd8.js → chunk-index-ptvrkv0r.js} +2 -2
  65. package/dist/{chunk-index-mzw7nmkc.js → chunk-index-pz6926p5.js} +2 -2
  66. package/dist/chunk-index-qb41kkt3.js +2 -0
  67. package/dist/{chunk-index-5x3h176v.js → chunk-index-qqaaxh63.js} +2 -2
  68. package/dist/chunk-index-qwztcbjz.js +2 -0
  69. package/dist/chunk-index-r1g24er0.js +2 -0
  70. package/dist/chunk-index-rvatmx8s.js +50 -0
  71. package/dist/{chunk-index-qq86fxda.js → chunk-index-tfgd7vr5.js} +2 -2
  72. package/dist/{chunk-index-qw9a7ken.js → chunk-index-tqrjr37v.js} +2 -2
  73. package/dist/chunk-index-tvsvtd4q.js +2 -0
  74. package/dist/chunk-index-vaxytvde.js +2 -0
  75. package/dist/{chunk-index-n2v2bz8d.js → chunk-index-ve07gdef.js} +1 -1
  76. package/dist/chunk-index-vw592m3p.js +2 -0
  77. package/dist/{chunk-index-y1xv3dxs.js → chunk-index-vwd5drzh.js} +4 -4
  78. package/dist/{chunk-index-0t68az7d.js → chunk-index-vxn4zws9.js} +3 -3
  79. package/dist/{chunk-index-6m25qpa7.js → chunk-index-wqbcade7.js} +2 -2
  80. package/dist/chunk-index-x7p6k52w.js +138 -0
  81. package/dist/{chunk-index-syxwqhry.js → chunk-index-xekytvrr.js} +1 -1
  82. package/dist/{chunk-index-6q3dx093.js → chunk-index-xkb336kq.js} +2 -2
  83. package/dist/{chunk-index-sk8cvb4e.js → chunk-index-xv3e4x0j.js} +2 -2
  84. package/dist/{chunk-index-50syrmaq.js → chunk-index-xvdna54d.js} +2 -2
  85. package/dist/chunk-index-yzd9cg0s.js +1 -0
  86. package/dist/{chunk-index-tasbd41t.js → chunk-index-zr2qwzz4.js} +2 -2
  87. package/dist/chunk-lang-css-6t2q4xw4.js +1 -0
  88. package/dist/{chunk-lang-dockerfile-e87ssppx.js → chunk-lang-dockerfile-9rc0adjw.js} +1 -1
  89. package/dist/{chunk-lang-go-kbcbn346.js → chunk-lang-go-t47kg9n0.js} +2 -2
  90. package/dist/chunk-lang-html-c6p22v5m.js +1 -0
  91. package/dist/chunk-lang-javascript-m57t19pw.js +1 -0
  92. package/dist/{chunk-lang-json-4pe1fv7e.js → chunk-lang-json-y33kawwg.js} +1 -1
  93. package/dist/{chunk-lang-markdown-67cm3tjx.js → chunk-lang-markdown-2c2sqc4z.js} +4 -4
  94. package/dist/{chunk-lang-python-mnfhcvww.js → chunk-lang-python-ymasvj52.js} +2 -2
  95. package/dist/{chunk-lang-rust-e4a9s76x.js → chunk-lang-rust-qcg53mkn.js} +1 -1
  96. package/dist/{chunk-lang-shell-43nea8tq.js → chunk-lang-shell-996wb0dk.js} +1 -1
  97. package/dist/{chunk-lang-sql-28364npv.js → chunk-lang-sql-60rh2y3y.js} +2 -2
  98. package/dist/{chunk-lang-toml-a83hr7bw.js → chunk-lang-toml-q1yzt70y.js} +1 -1
  99. package/dist/chunk-lang-typescript-7gcbrhbd.js +1 -0
  100. package/dist/{chunk-lang-xml-2hv5xc8n.js → chunk-lang-xml-k2a92cm3.js} +1 -1
  101. package/dist/{chunk-lang-yaml-vw22drt8.js → chunk-lang-yaml-qp3asq06.js} +1 -1
  102. package/dist/chunk-layout-actions-yxh77zcz.js +1 -0
  103. package/dist/chunk-mention-menu-qpksygcf.js +43 -0
  104. package/dist/chunk-menu-items-95evdhk1.js +1 -0
  105. package/dist/chunk-mode-toggle-dqwvcr2p.js +1 -0
  106. package/dist/{chunk-note-row-c0trzayj.js → chunk-note-row-ngzxbdn6.js} +4 -4
  107. package/dist/chunk-notes-9ykcajzc.js +1 -0
  108. package/dist/chunk-notice-bell-eryn2k5m.js +1 -0
  109. package/dist/{chunk-notices-gkaqncqz.js → chunk-notices-jkv1derx.js} +1 -1
  110. package/dist/{chunk-onboarding-fkq9ptcw.js → chunk-onboarding-ka11bgd0.js} +1 -1
  111. package/dist/{chunk-overview-yssxbg0d.js → chunk-overview-dgvrjwbc.js} +1 -1
  112. package/dist/{chunk-palette-w6qbr7zp.js → chunk-palette-wmvynt7n.js} +1 -1
  113. package/dist/chunk-placement-items-zyqq2mp7.js +1 -0
  114. package/dist/{chunk-profile-9sjgayrx.js → chunk-profile-sdn7bs08.js} +1 -1
  115. package/dist/chunk-prompt-history-qfnj4w2y.js +1 -0
  116. package/dist/chunk-prompts-4hdcvy6t.js +1 -0
  117. package/dist/chunk-room-confirms-b8gvak47.js +1 -0
  118. package/dist/chunk-room-menu-18mnqcja.js +1 -0
  119. package/dist/chunk-rooms-menu-button-hjg4zqjy.js +1 -0
  120. package/dist/{chunk-schedules-m9mn68gt.js → chunk-schedules-cy2dv8x0.js} +1 -1
  121. package/dist/{chunk-seat-menu-3tdcr44t.js → chunk-seat-menu-cw3z9560.js} +1 -1
  122. package/dist/chunk-section-fold-9tc2m103.js +1 -0
  123. package/dist/{chunk-settings-18qmhcyr.js → chunk-settings-rhdv64p7.js} +1 -1
  124. package/dist/chunk-sheet-hosts-hhs1e3a8.js +29 -0
  125. package/dist/chunk-shortcut-help-fv6b6ntc.js +26 -0
  126. package/dist/{chunk-shortcuts-qee393s5.js → chunk-shortcuts-sjwrv858.js} +1 -1
  127. package/dist/{chunk-skill-editor-pryntvpr.js → chunk-skill-editor-zzmv9nfq.js} +2 -2
  128. package/dist/chunk-skills-b2enxk30.js +1 -0
  129. package/dist/{chunk-start-over-line-azexcxj1.js → chunk-start-over-line-4rwasr8k.js} +2 -2
  130. package/dist/{chunk-switcher-list-6hacxjfe.js → chunk-switcher-list-dcq91xxa.js} +1 -1
  131. package/dist/{chunk-tab-dot-h0eskhrt.js → chunk-tab-dot-b3gcgcrq.js} +1 -1
  132. package/dist/chunk-table-6j64ps89.js +1 -0
  133. package/dist/{chunk-table2d-vy4w4r5k.js → chunk-table2d-k4z439nt.js} +1 -1
  134. package/dist/{chunk-table3d-0a62jerb.js → chunk-table3d-mx0afnv8.js} +23 -23
  135. package/dist/chunk-thread-actions-rs5xpf1r.js +1 -0
  136. package/dist/{chunk-thread-cards-mwxzy02t.js → chunk-thread-cards-k9m7p5fn.js} +1 -1
  137. package/dist/{chunk-thread-list-52mx2m9p.js → chunk-thread-list-zz7596zy.js} +2 -2
  138. package/dist/chunk-transcript-8yjp18cr.js +1 -0
  139. package/dist/chunk-waiting-9gshhhx0.js +1 -0
  140. package/dist/{chunk-waiting-chip-wvkbsnw5.js → chunk-waiting-chip-nr9cza2j.js} +2 -2
  141. package/dist/chunk-where-8mq8azgw.js +1 -0
  142. package/dist/{chunk-workspace-ne2nkf4h.js → chunk-workspace-hdamnf4r.js} +2 -2
  143. package/dist/chunk-zh-tw-ama40y87.js +1 -0
  144. package/dist/index.html +1 -1
  145. package/dist/sw.js +1 -1
  146. package/package.json +3 -3
  147. package/src/api-types.ts +17 -0
  148. package/src/app/app.ts +3 -0
  149. package/src/app/command-routes.ts +45 -0
  150. package/src/app/routes.ts +13 -0
  151. package/src/i18n/zh-tw.ts +8 -1
  152. package/src/web-plugin.ts +2 -0
  153. package/dist/chunk-account-dq0nhfvj.js +0 -1
  154. package/dist/chunk-agent-yqe6reej.js +0 -1
  155. package/dist/chunk-arranged-rooms-sx6xg9df.js +0 -1
  156. package/dist/chunk-bulk-actions-6pehrsgb.js +0 -1
  157. package/dist/chunk-confirm-ghxga720.js +0 -1
  158. package/dist/chunk-council-sheet-7m884s44.js +0 -2
  159. package/dist/chunk-council-view-rkzcxeg8.js +0 -1
  160. package/dist/chunk-folds-rb1b069h.js +0 -1
  161. package/dist/chunk-gate-3rxxyfev.js +0 -1
  162. package/dist/chunk-host-icons-cyj62pwp.js +0 -1
  163. package/dist/chunk-host-picture-9wnhqckv.js +0 -1
  164. package/dist/chunk-host-state-b858k3p8.js +0 -1
  165. package/dist/chunk-host-ui-j6wvj0pe.js +0 -1
  166. package/dist/chunk-index-2s48qyrs.js +0 -2
  167. package/dist/chunk-index-33cqx9v2.js +0 -2
  168. package/dist/chunk-index-36m3knsk.js +0 -2
  169. package/dist/chunk-index-91wnf1k9.js +0 -1
  170. package/dist/chunk-index-9ehqccfe.js +0 -2
  171. package/dist/chunk-index-ar1x9fhw.js +0 -2
  172. package/dist/chunk-index-axw4wkqq.js +0 -2
  173. package/dist/chunk-index-b5patef1.js +0 -2
  174. package/dist/chunk-index-dagc92hw.js +0 -2
  175. package/dist/chunk-index-ddssgba9.js +0 -2
  176. package/dist/chunk-index-dpgn7kzp.js +0 -2
  177. package/dist/chunk-index-eez0kbk4.js +0 -2
  178. package/dist/chunk-index-ekp5mmvp.js +0 -2
  179. package/dist/chunk-index-fdg2qd3f.js +0 -2
  180. package/dist/chunk-index-g0sdxjxr.js +0 -2
  181. package/dist/chunk-index-hsc9yz2x.js +0 -2
  182. package/dist/chunk-index-kvztbfqj.js +0 -2
  183. package/dist/chunk-index-nncy9wxw.js +0 -2
  184. package/dist/chunk-index-p2e7rwac.js +0 -2
  185. package/dist/chunk-index-p98tt12y.js +0 -2
  186. package/dist/chunk-index-qdtmetsy.js +0 -120
  187. package/dist/chunk-index-s356ybxk.js +0 -50
  188. package/dist/chunk-index-vxqzavgz.js +0 -2
  189. package/dist/chunk-index-x5xq9g9a.js +0 -3
  190. package/dist/chunk-index-xx0kecz9.js +0 -2
  191. package/dist/chunk-lang-css-rwkzd784.js +0 -1
  192. package/dist/chunk-lang-html-zhngbs9v.js +0 -1
  193. package/dist/chunk-lang-javascript-bk2s6a56.js +0 -1
  194. package/dist/chunk-lang-typescript-r5npc6zf.js +0 -1
  195. package/dist/chunk-layout-actions-rw5myg2t.js +0 -1
  196. package/dist/chunk-menu-items-q0hy5kzd.js +0 -1
  197. package/dist/chunk-mode-toggle-yk2t0tcy.js +0 -1
  198. package/dist/chunk-notes-0xcmm938.js +0 -1
  199. package/dist/chunk-notice-bell-f9nhxg71.js +0 -1
  200. package/dist/chunk-placement-items-wcwy91mp.js +0 -1
  201. package/dist/chunk-prompt-history-kn42sf8y.js +0 -1
  202. package/dist/chunk-prompts-824fwgvh.js +0 -1
  203. package/dist/chunk-room-confirms-hvs9tra4.js +0 -1
  204. package/dist/chunk-room-menu-pkd0487m.js +0 -1
  205. package/dist/chunk-rooms-menu-button-w5hfhsfv.js +0 -1
  206. package/dist/chunk-section-fold-g0tx68cj.js +0 -1
  207. package/dist/chunk-sheet-hosts-tsppnmvv.js +0 -29
  208. package/dist/chunk-shortcut-help-wnm0cm8n.js +0 -26
  209. package/dist/chunk-skills-sap3rysr.js +0 -1
  210. package/dist/chunk-table-jtn49c2m.js +0 -1
  211. package/dist/chunk-thread-actions-31scmndt.js +0 -1
  212. package/dist/chunk-transcript-p5q2m795.js +0 -1
  213. package/dist/chunk-waiting-s7nm3q0p.js +0 -1
  214. package/dist/chunk-where-j99f8pb8.js +0 -1
  215. package/dist/chunk-zh-tw-vm5d0w6j.js +0 -1
package/src/app/app.ts CHANGED
@@ -148,6 +148,8 @@ export interface OwnerAppOptions {
148
148
  * how they change, and the registry's documents.
149
149
  */
150
150
  skills?: AppApiOptions["skills"];
151
+ /** The extension commands plugins declared safe to run from chat. */
152
+ chatCommands?: AppApiOptions["chatCommands"];
151
153
  /** Present when the host has prompt documents: the main prompts the owner edits. */
152
154
  prompts?: AppApiOptions["prompts"];
153
155
  /** Present when the workspace pane is served. */
@@ -460,6 +462,7 @@ export class OwnerApp {
460
462
  directory: agents.directory,
461
463
  team: agents.team,
462
464
  ...(options.skills ? { skills: options.skills } : {}),
465
+ ...(options.chatCommands ? { chatCommands: options.chatCommands } : {}),
463
466
  ...(options.prompts ? { prompts: options.prompts } : {}),
464
467
  avatars: agents.avatars,
465
468
  reads,
@@ -0,0 +1,45 @@
1
+ import type { ChatCommand, Speaker } from "pi-roundtable";
2
+ import type { RoomCommandsView } from "../api-types.ts";
3
+ import { json } from "../http.ts";
4
+ import type { ResolvedRoom } from "./rooms.ts";
5
+
6
+ export interface CommandRoutesOptions {
7
+ /** The Pi extension commands plugins declared safe to run from chat. */
8
+ declared(): readonly ChatCommand[];
9
+ /** The skills an agent carries, built-in ones included; absent when the host has no skills addon. */
10
+ skillsOf?(agent: string): readonly { name: string; description: string }[];
11
+ }
12
+
13
+ /**
14
+ * `GET api/rooms/<room>/commands`: what the owner may run by typing `/` in the room's message box,
15
+ * beyond the commands the page runs itself (`/clear`, `/new`). An agent's room offers the skills the
16
+ * agent carries (`/skill:<name>`) and the extension commands plugins declared; a group, a thread
17
+ * and a room that cannot be written in offer none. Both kinds are sent as a normal message, and only
18
+ * an owner's message is ever read as a command, so the route is the owner's.
19
+ */
20
+ export class CommandRoutes {
21
+ readonly #options: CommandRoutesOptions;
22
+
23
+ constructor(options: CommandRoutesOptions) {
24
+ this.#options = options;
25
+ }
26
+
27
+ list(room: ResolvedRoom, _owner: Speaker): Response {
28
+ if (room.kind !== "agent" || room.readOnly)
29
+ return json({ commands: [] } satisfies RoomCommandsView);
30
+ const { declared, skillsOf } = this.#options;
31
+ const skills = (skillsOf?.(room.name) ?? []).map((skill) => ({
32
+ name: `skill:${skill.name}`,
33
+ description: skill.description,
34
+ source: "skill" as const,
35
+ }));
36
+ const extensions = declared().map((command) => ({
37
+ name: command.name,
38
+ description: command.description,
39
+ source: "extension" as const,
40
+ }));
41
+ return json({
42
+ commands: [...skills, ...extensions],
43
+ } satisfies RoomCommandsView);
44
+ }
45
+ }
package/src/app/routes.ts CHANGED
@@ -3,6 +3,7 @@ import type {
3
3
  AgentTeam,
4
4
  AvatarStudio,
5
5
  ChannelKey,
6
+ ChatCommand,
6
7
  ConversationModes,
7
8
  ConversationPort,
8
9
  IdentityService,
@@ -52,6 +53,7 @@ import type { PushMutes } from "../push/mutes.ts";
52
53
  import { viewerOf, type WebAppRegistry } from "../web-app.ts";
53
54
  import { bad, bodyOf, HttpError, notFound } from "./api-http.ts";
54
55
  import type { CardLog } from "./card-log.ts";
56
+ import { CommandRoutes } from "./command-routes.ts";
55
57
  import { type FileDir, fileResponse, isFileId } from "./files.ts";
56
58
  import { HelperRoutes } from "./helper-routes.ts";
57
59
  import type { LayoutStore } from "./layout.ts";
@@ -154,6 +156,8 @@ export interface AppApiOptions {
154
156
  /** Present when the host has the skills addon: the catalog an agent's skills are chosen from, and the change of what it carries. */
155
157
  skills?: {
156
158
  catalog(): SkillView[];
159
+ /** The skills an agent carries, built-in ones included: what `/skill:<name>` can name in its room. */
160
+ carried?(agent: string): readonly { name: string; description: string }[];
157
161
  attach(
158
162
  agent: string,
159
163
  add: readonly string[],
@@ -171,6 +175,8 @@ export interface AppApiOptions {
171
175
  /** The registry's skill groups: listed, saved and deleted. */
172
176
  groups: Pick<SkillRegistry, "groups" | "setGroup" | "deleteGroup">;
173
177
  };
178
+ /** The Pi extension commands plugins declared safe to run from chat (`PluginContext.chatCommands`). */
179
+ chatCommands?(): readonly ChatCommand[];
174
180
  /** Present when the host has prompt documents (the prompts plugin): the main prompts the owner edits. */
175
181
  prompts?: PromptApiOptions["prompts"];
176
182
  avatars: Pick<AvatarStudio, "serve">;
@@ -311,6 +317,7 @@ export class AppApi {
311
317
  readonly #team: TeamApi;
312
318
  readonly #layout: LayoutRoutes;
313
319
  readonly #helpers: HelperRoutes;
320
+ readonly #commands: CommandRoutes;
314
321
  readonly #prompts: PromptApi | undefined;
315
322
  readonly #skillDocs: SkillDocApi | undefined;
316
323
  readonly #skillGroups: SkillGroupApi | undefined;
@@ -331,6 +338,10 @@ export class AppApi {
331
338
  team: options.team,
332
339
  changed: () => options.changed(),
333
340
  });
341
+ this.#commands = new CommandRoutes({
342
+ declared: () => options.chatCommands?.() ?? [],
343
+ ...(options.skills?.carried ? { skillsOf: options.skills.carried } : {}),
344
+ });
334
345
  this.#prompts = options.prompts
335
346
  ? new PromptApi({ prompts: options.prompts })
336
347
  : undefined;
@@ -621,6 +632,8 @@ export class AppApi {
621
632
  if (!view) throw notFound();
622
633
  return json({ room: view } satisfies RoomOneView);
623
634
  }
635
+ if (action === "commands" && method === "GET" && parts.length === 4)
636
+ return this.#commands.list(room, await this.#owner(admission));
624
637
  if (action === "dismiss" && method === "POST" && parts.length === 4)
625
638
  return this.#dismiss(room, admission);
626
639
  if (action === "dismiss-threads" && method === "POST" && parts.length === 4)
package/src/i18n/zh-tw.ts CHANGED
@@ -288,7 +288,8 @@ export const ZH_TW: Readonly<Record<string, string>> = {
288
288
  "The table is empty": "圓桌空了",
289
289
  "There are no rooms to seat yet.": "還沒有可以入座的聊天室。",
290
290
  "All rooms": "所有聊天室",
291
- "Council: {name} ▾": "評議會:{name} ▾",
291
+ "Switch council": "換評議會",
292
+ "Who sits, or another council": "選誰上桌,或換另一個評議會",
292
293
  Council: "評議會",
293
294
  Councils: "評議會",
294
295
  "{count} knights": "{count} 位騎士",
@@ -681,6 +682,12 @@ export const ZH_TW: Readonly<Record<string, string>> = {
681
682
  "關閉開啟的選單或面板;都沒有時離開訊息輸入框",
682
683
  "Edit your latest message that is still waiting, from an empty message box":
683
684
  "在空的訊息輸入框編輯你最新一則還在排隊的訊息",
685
+ "In a message box, start the open room over (also /new)":
686
+ "在訊息輸入框裡讓目前的聊天室重新開始(/new 也行)",
687
+ "Start over: archive this conversation and begin a new one":
688
+ "重新開始:封存這段對話,開啟新的對話",
689
+ "This room cannot be started over from here; the host keeps its conversation.":
690
+ "這個聊天室無法在這裡重新開始,對話由主機保管。",
684
691
  "Show these shortcuts": "顯示這份快速鍵清單",
685
692
  "In a message box the arrow shortcuts switch rooms only when it is empty or the caret is at its very start (up) or very end (down).":
686
693
  "在訊息輸入框裡,方向鍵快速鍵只在框內沒有文字,或游標在最開頭(上)、最結尾(下)時才會切換聊天室。",
package/src/web-plugin.ts CHANGED
@@ -194,6 +194,7 @@ async function build(settings: ResolvedOptions, context: Context) {
194
194
  features?.skills
195
195
  ? features.skills.catalog()
196
196
  : skillRegistry.catalog(),
197
+ carried: (agent: string) => skillRegistry.carried(agent).skills,
197
198
  attach: (
198
199
  agent: string,
199
200
  add: readonly string[],
@@ -423,6 +424,7 @@ async function build(settings: ResolvedOptions, context: Context) {
423
424
  database: context.database(),
424
425
  agents: services.get(AGENTS),
425
426
  ...(skills ? { skills } : {}),
427
+ chatCommands: context.chatCommands,
426
428
  ...(prompts ? { prompts } : {}),
427
429
  ...(workspace ? { workspace } : {}),
428
430
  modes: services.get(MODES),
@@ -1 +0,0 @@
1
- import{p,T,v,e,x}from"./chunk-index-s356ybxk.js";var a={profile:v(()=>(p("9sjgayrx"),import("./chunk-profile-9sjgayrx.js")).then((o)=>({default:o.ProfilePage}))),notices:v(()=>(p("gkaqncqz"),import("./chunk-notices-gkaqncqz.js")).then((o)=>({default:o.NoticesPage}))),onboarding:v(()=>(p("fkq9ptcw"),import("./chunk-onboarding-fkq9ptcw.js")).then((o)=>({default:o.OnboardingPage})))};function n({pane:o}){let t=a[o];return t?e(T,{fallback:e(x,{}),children:e(t,{})}):null}export{n as default};
@@ -1 +0,0 @@
1
- import{s,e,X,u,x,Ke}from"./chunk-index-s356ybxk.js";function c({name:o}){let i=u((t)=>t.listed),r=u((t)=>Object.values(t.rooms).find((m)=>m.view?.kind==="agent"&&m.view.name===o)?.view?.key,o);return s(()=>{if(r)X("room",r,{replace:!0}),Ke(o);else if(i)X("rooms",void 0,{replace:!0})},[r,i,o]),e("div",{className:"page",children:e(x,{})})}export{c as AgentPage};
@@ -1 +0,0 @@
1
- import{p,T,v,ee,R,a,t,g,e,n,o,Le,u,k,_,Oe,Jt,_n,te,Ae,Pr,Ni,ao,It,Li,lo}from"./chunk-index-s356ybxk.js";import"./chunk-index-50w6yq2d.js";import"./chunk-index-qq86fxda.js";import{mn,rr}from"./chunk-index-y1xv3dxs.js";import{De}from"./chunk-index-axw4wkqq.js";import{_i}from"./chunk-index-p98tt12y.js";import{mi}from"./chunk-index-33cqx9v2.js";import{wi}from"./chunk-index-dpgn7kzp.js";import{Yt}from"./chunk-index-ddssgba9.js";import"./chunk-index-xx0kecz9.js";import"./chunk-index-6m25qpa7.js";import{lt}from"./chunk-index-6ycrvwzs.js";mn();var O=v(()=>(p("g7st6p1e"),import("./chunk-folder-list-g7st6p1e.js")).then((i)=>({default:i.FolderList}))),Z=ee(function(m){let{view:r}=m,h=Yt(()=>Jt(r.key),r.home?void 0:wi(r.key));return e(ao,{...m,press:h,item:{...r.home?{}:{"data-drop-item":"","data-key":r.key},...m.arranging?{"data-arranging":""}:{}},after:m.arranging?e("button",{type:"button",className:"icon-button row-more","aria-haspopup":"menu","aria-label":t("Room menu"),onClick:(s)=>{let c=s.currentTarget;Jt(r.key).then((l)=>{if(!l)return;let N=c.getBoundingClientRect();Oe({...l,at:{x:N.left,y:N.bottom},via:"key",source:c})},()=>{return})},children:e(o,{name:"more",size:18})}):null})});function L(i){let{now:m}=te(),{timeZone:r}=_(),h=It(i.rooms);return e("ul",{className:"room-list",children:h.map(({key:s,...c})=>{let l=i.threads[s];return e(Z,{...c,active:s===i.active,now:m,timeZone:r,arranging:i.arranging,...l?{threads:e(Li,{open:l.open,closed:l.closed,active:i.active,parent:s})}:{}},s)})})}function y(i){let r=It(i.rooms).length===0;if(r&&i.zone?.kind!=="pinned")return null;let h=i.zone?{"data-drop-zone":i.zone.kind,"data-zone-id":i.zone.id}:{},s=(c)=>e(L,{rooms:c,threads:i.threads,active:i.active,arranging:i.arranging});if(i.fold&&!r)return e(rr,{id:i.fold,title:i.title,rooms:i.rooms,active:i.active,attrs:h,children:s});return n("section",{className:"stack",...r?{"data-empty":""}:{},...h,children:[e("h2",{className:"section-title",children:i.title}),r?null:s(i.rooms)]})}function le(i){let m=Boolean(_().kinds?.length),r=u((d)=>JSON.stringify({listed:d.listed,...lt(d,(M)=>Le(d,M))})),h=_i(),s=a(r);if(!h)s.current=r;let c=s.current,{listed:l,...N}=R(()=>JSON.parse(c),[c]),{home:S,pinned:A,folders:w,restAgents:P,restGroups:D,rest:C,threads:F,orphans:f}=N,z=Pr(),K=S.length+A.length+C.length===0&&w.every((d)=>d.rooms.length===0)&&f.open.length+f.closed.length===0,b={threads:F,active:i.active,arranging:z};return n("div",{className:"page","data-column":i.active?"":void 0,"data-drop-root":"",children:[n("header",{className:"page-head",children:[e("h1",{children:t("Rooms")}),n("div",{className:"actions",children:[n("button",{type:"button",className:"header-button search-button",onClick:i.onSearch,children:[e(o,{name:"search",size:16}),e("span",{children:t("Find a room")}),e("kbd",{children:"⌘K"})]}),l?e("button",{type:"button",className:"header-button icon-button","aria-haspopup":"menu","aria-label":t("Folders and order"),onClick:(d)=>mi(d.currentTarget),children:e(o,{name:"more",size:18})}):null,e("button",{type:"button",className:"header-button icon-button","aria-label":t("Add"),"aria-haspopup":"menu",onClick:(d)=>_n(d.currentTarget),children:e(o,{name:"plus"})})]})]}),z?n("div",{className:"arrange-bar",children:[n("button",{type:"button",className:"secondary",onClick:()=>De({kind:"new"}),children:[e(o,{name:"plus",size:16}),e("span",{children:t("Add a folder")})]}),e("button",{type:"button",onClick:()=>Ni(!1),children:t("Done")})]}):null,l&&K&&!m?e(k,{children:t("No rooms yet. Rooms appear when the team has a knight.")}):null,!l?n("div",{className:"stack","aria-busy":"true",children:[e("div",{className:"skeleton"}),e("div",{className:"skeleton"}),e("div",{className:"skeleton"})]}):null,e(y,{title:t("Home"),rooms:S,...b}),e(y,{title:t("Pinned"),rooms:A,zone:{kind:"pinned",id:"pinned"},fold:Ae("pinned"),...b}),w.length>0?e("div",{className:"stack folder-list","data-folder-list":"",children:e(T,{fallback:e("div",{className:"skeleton","aria-busy":"true"}),children:e(O,{folders:w,active:i.active,listed:l,rooms:(d)=>e(L,{rooms:d,threads:F,active:i.active,arranging:z})})})}):null,w.length>0?e(y,{title:t("Ungrouped"),rooms:C,zone:{kind:"rest",id:"rest"},fold:Ae("rest"),...b}):n(g,{children:[e(y,{title:t("Knights"),rooms:P,zone:{kind:"rest",id:"rest-agents"},fold:Ae("agents"),...b}),e(y,{title:t("Groups"),rooms:D,zone:{kind:"rest",id:"rest-groups"},fold:Ae("groups"),...b})]}),f.open.length+f.closed.length>0?n("section",{className:"stack",children:[e("h2",{className:"section-title",children:t("Dispatch threads")}),e(Li,{open:f.open,closed:f.closed,active:i.active})]}):null,e(lo,{active:i.active})]})}export{le as ArrangedRoomsPage};
@@ -1 +0,0 @@
1
- import{t,B,O,l,f}from"./chunk-index-s356ybxk.js";import{ln}from"./chunk-index-qq86fxda.js";import"./chunk-index-50w6yq2d.js";import{En,mo}from"./chunk-index-qedt9szy.js";import{Ro}from"./chunk-index-xx0kecz9.js";import{re}from"./chunk-index-6q3dx093.js";import"./chunk-index-6m25qpa7.js";var s=500,c=(n)=>{let r=[];for(let e=0;e<n.length;e+=s)r.push(n.slice(e,e+s));return r},i=()=>O.dispatch({type:"changed"});async function w(n){let r=Ro(n),e=Object.keys(r);if(e.length===0)return;let a=[];try{for(let o of c(e))a.push(...(await En.readAll(o)).moved)}catch(o){f(l(o),"danger"),i();return}ln(Object.fromEntries(e.map((o)=>[o,0]))),f(B(e.length,"Marked {count} room as read","Marked {count} rooms as read"),"info",a.length?{label:t("Undo"),run:()=>void m(a,r)}:void 0)}async function m(n,r){try{for(let e of c(n)){let{restored:a}=await En.unreadAll(e);ln(Object.fromEntries(a.map((o)=>[o,r[o]??0])))}}catch(e){f(l(e),"danger")}i()}var P=(n)=>mo(n);async function d(n){try{await En.restoreHelpers(n)}catch(r){f(l(r),"danger")}i()}async function R(n){let r;try{r=(await En.archiveFinishedHelpers(n)).archived.flatMap((a)=>a.names)}catch(e){f(l(e),"danger"),i();return}if(i(),r.length===0)return;f(B(r.length,"Archived {count} temp knight","Archived {count} temp knights"),"info",{label:t("Undo"),run:()=>void d(r)})}async function T(n,r){try{await re.archiveAgent(n)}catch(e){f(l(e),"danger"),i();return}i(),f(t("Archived {name}",{name:r}),"info",{label:t("Undo"),run:()=>void d([n])})}export{T as archiveHelper,P as clearAllFinished,R as clearFinishedHelpers,w as markAllRead,d as putBackHelpers};
@@ -1 +0,0 @@
1
- import{D}from"./chunk-index-6cs1wvhy.js";import"./chunk-index-e8535c4h.js";export{D as Confirm};
@@ -1,2 +0,0 @@
1
- import{s,A,R,r,t,g,e,n,X,l,f,m,qe}from"./chunk-index-s356ybxk.js";import"./chunk-index-nncy9wxw.js";import"./chunk-index-tasbd41t.js";import"./chunk-index-5fyqxh0r.js";import"./chunk-index-qq86fxda.js";import{yi}from"./chunk-index-qdtmetsy.js";import{Zt}from"./chunk-index-n2v2bz8d.js";import{C}from"./chunk-index-e8535c4h.js";import{rn,ni,ko,Di,qs,Bs,Fs,Gs,Zs}from"./chunk-index-g0sdxjxr.js";import{re,ze}from"./chunk-index-6q3dx093.js";var Q=(a)=>X("table",a.name,{replace:!0});function W(a){let{view:i}=a;return e("li",{children:n("button",{type:"button",className:"menu-item council-row","aria-current":a.current||void 0,onClick:a.onPick,children:[e(qe,{view:i,size:40}),n("span",{className:"menu-text",children:[e("strong",{children:i.displayName}),e("span",{className:"meta",children:t("{count} knights",{count:i.members?.length??0})})]})]})})}function Y(a){let{council:i}=a,w=Di(),d=yi(),[v,M]=r([]),[y,O]=r(),[D,S]=r(""),[I,j]=r(!1),[P,z]=r(""),[b,k]=r(!1),[E,G]=r(),F=A(),x=i?.name,H=i?.members?.join(`
2
- `);s(()=>{if(!a.open)return;if(G(void 0),j(i===void 0),z(""),k(!1),O(void 0),S(""),M(i?[...i.members??[]]:qs(d)),!x)return;let o=!0;return re.group(x).then((c)=>{if(!o)return;O(c),S(c.host)},()=>{return}),()=>{o=!1}},[a.open,x,H]);let L=R(()=>new Set(d.map((o)=>o.name)),[d]),U=d.find((o)=>o.home)?.name,u=Fs(v,(o)=>L.has(o)),h=Gs(u,D||void 0,U),_=(o)=>d.find((c)=>c.name===o)?.displayName??o,T=u.length>=rn,N=u.length>=ni,q=i===void 0||u.join(",")!==(i.members??[]).join(",")||y!==void 0&&h!==y.host,B=async(o)=>{k(!0),G(void 0);try{await o(),await ze()}catch(c){return G(l(c)),k(!1),!1}return k(!1),!0},J=async()=>{if(!i)return;if(!await B(async()=>{await re.updateGroup(i.name,{...u.join(",")!==(i.members??[]).join(",")?{members:u}:{},...y&&h!==y.host?{host:h}:{}})}))return;f(t("Saved.")),a.onClose()},K=async()=>{let o=P.trim();if(o==="")return;let c=new Set([...d.map((V)=>V.name),...w.map((V)=>V.name)]),p;if(!await B(async()=>{p=await re.createGroup({name:Zs(o,c),displayName:o,members:u,host:h})})||!p)return;ko(p.room),a.go({key:p.room,name:p.name}),f(t("Made {name}.",{name:p.displayName})),a.onClose()};return n("div",{className:"stack council-sheet",children:[w.length>0?n("section",{className:"stack","aria-label":t("Councils"),children:[e("h3",{children:t("Councils")}),e("ul",{className:"menu",children:w.map((o)=>e(W,{view:o,current:o.key===i?.key,onPick:()=>{ko(o.key),a.go(o),a.onClose()}},o.key))})]}):null,n("fieldset",{className:"field council-pick",children:[e("legend",{children:i?t("Edit this council"):t("Pick who sits")}),n("span",{className:"meta council-count","aria-live":"polite",children:[t("{count} of {max} picked",{count:u.length,max:rn}),T?` · ${t("At most {max} knights",{max:rn})}`:""]}),e("ul",{className:"menu",children:d.map((o)=>{let c=v.includes(o.name);return e("li",{children:n("label",{className:"menu-item menu-toggle seat-row",children:[e("input",{type:"checkbox",checked:c,disabled:!c&&T,onChange:()=>M(Bs(v,o.name,rn))}),e(qe,{view:o,size:32}),e("span",{className:"menu-text",children:e("strong",{children:o.displayName})})]})},o.key)})})]}),N?e(Zt,{label:t("Host"),value:h,onChange:S,options:u.map((o)=>({value:o,label:_(o)}))}):e("span",{className:"meta",children:t("A council needs at least {min} knights.",{min:ni})}),I?n("label",{htmlFor:F,children:[t("Council name"),e("input",{id:F,value:P,autoComplete:"off",onChange:(o)=>z(o.target.value)})]}):null,E?e(m,{message:E}):null,e("div",{className:"actions",children:i&&!I?n(g,{children:[e("button",{type:"button",className:"secondary",disabled:!N||b,onClick:()=>j(!0),children:t("Save as a new council")}),e("button",{type:"button",disabled:!N||!q||b,onClick:J,children:b?t("Saving…"):t("Done")})]}):e("button",{type:"button",disabled:!N||P.trim()===""||b,onClick:K,children:b?t("Saving…"):i?t("Save as a new council"):t("Make council")})})]})}function fe(a){return e(C,{open:a.open,title:t("Council"),onClose:a.onClose,size:"default",children:e(Y,{open:a.open,council:a.council,onClose:a.onClose,go:a.go??Q})})}export{fe as CouncilSheet};
@@ -1 +0,0 @@
1
- import{ji,Ki,zr}from"./chunk-index-qdtmetsy.js";import"./chunk-index-5fyqxh0r.js";import"./chunk-index-tasbd41t.js";import"./chunk-index-e8535c4h.js";import"./chunk-index-nncy9wxw.js";import"./chunk-index-qq86fxda.js";export{ji as CouncilChip,zr as CouncilView,Ki as useCouncilSheet};
@@ -1 +0,0 @@
1
- import{Ae,zt,io,Kn,ro,oo}from"./chunk-index-s356ybxk.js";export{io as collapsedNow,ro as expandFolder,oo as pruneCollapsed,Ae as sectionFold,Kn as toggleCollapsed,zt as useCollapsed};
@@ -1 +0,0 @@
1
- import{t,e,n,o,S}from"./chunk-index-s356ybxk.js";import{Un,dn}from"./chunk-index-1tkzdy4s.js";function l({steps:s}){return n("div",{className:"page",children:[e("header",{className:"page-head",children:e("h1",{children:t("Finish setting up")})}),e("p",{className:"meta",children:t("These steps come first. The rest of the app opens when they are done.")}),e("ul",{className:"menu",children:s.map((a)=>e("li",{children:n("a",{className:"menu-item menu-link",href:S(a.open.page),children:[n("span",{className:"menu-text",children:[e("strong",{children:Un(a)}),dn(a)?e("span",{className:"meta",children:dn(a)}):null]}),e(o,{name:"chevron",size:16})]})},a.id))})]})}export{l as GatePage};
@@ -1 +0,0 @@
1
- import"./chunk-index-yn1vvxj2.js";
@@ -1 +0,0 @@
1
- import{ut}from"./chunk-index-7p31pda8.js";export{ut as HostPicture};
@@ -1 +0,0 @@
1
- import{Eo,me,Rr,Ao,$o,No,Lo,ln,Cr,Xo,Da}from"./chunk-index-qq86fxda.js";export{Xo as keepCards,Cr as keepReads,Lo as noCards,No as noReads,Da as onFrame,ln as seedUnread,Eo as subscribeHost,Ao as totalUnread,$o as unreadCounts,Rr as unreadOf,me as useHost};
@@ -1 +0,0 @@
1
- import{ee,E,s,A,Pe,R,a,r,t,B,g,e,n,o,S,yn,O,u,fe,l,f,x,m,k,P,jt,Wn,At,_,Kr,ke,Kt,xn,$t,fr,Re,Sn,Xt,no,te,Qn,vr,xr,Sr,Xe}from"./chunk-index-s356ybxk.js";import{Bn}from"./chunk-index-tasbd41t.js";import{or,ps,He,sr}from"./chunk-index-5fyqxh0r.js";import{D}from"./chunk-index-6cs1wvhy.js";import{me,No,Lo,ln,Cr,Xo}from"./chunk-index-qq86fxda.js";import{ct,ut}from"./chunk-index-7p31pda8.js";import{Br}from"./chunk-index-7gk2sdf4.js";import"./chunk-index-yn1vvxj2.js";import{Ee}from"./chunk-index-sk8cvb4e.js";import{H}from"./chunk-index-9ehqccfe.js";import"./chunk-index-e8535c4h.js";function Ke(c){let i={};for(let d of c)if(d.type==="multiselect")i[d.name]=[...Oe(d.initial)];else i[d.name]=Oe(d.initial)[0]??"";return i}var Oe=(c)=>c===void 0?[]:typeof c==="string"?[c]:[...c];function et(c,i){let d={};for(let p of c){let y=i[p.name];if(y===void 0||y===""||y.length===0)continue;d[p.name]=y}return d}function tt(c){let{field:i,value:d}=c,[p,y]=r(""),w=i.search?i.options.filter((h)=>h.label.toLowerCase().includes(p.trim().toLowerCase())):i.options,N=i.search?e("input",{type:"search",value:p,placeholder:t("Search…"),"aria-label":t("Search {name}",{name:i.label}),onChange:(h)=>y(h.target.value)}):null;if(i.type==="select")return n(g,{children:[N,n(Ee,{id:c.id,value:String(d),required:i.required===!0,"aria-describedby":c.described,...i.search?{size:6}:{},onChange:(h)=>c.onChange(h.target.value),children:[i.required?null:e("option",{value:"",children:t("None")}),w.map((h)=>e("option",{value:h.value,children:h.label},h.value))]})]});let b=new Set(Array.isArray(d)?d:[]);return n(g,{children:[N,e("fieldset",{"aria-describedby":c.described,children:w.map((h)=>n("label",{children:[e("input",{type:"checkbox",checked:b.has(h.value),onChange:(T)=>{let v=new Set(b);if(T.target.checked)v.add(h.value);else v.delete(h.value);c.onChange(i.options.filter((V)=>v.has(V.value)).map((V)=>V.value))}}),h.label]},h.value))})]})}function nt(c){let{field:i,value:d}=c,p=A(),y="hint"in i?i.hint:void 0,w=c.error||y?`${p}-note`:void 0,N;if("options"in i)N=e(tt,{field:i,id:p,value:d,described:w,onChange:c.onChange});else if(i.type==="textarea")N=e("textarea",{id:p,rows:5,value:String(d),maxLength:i.max??8000,required:i.required===!0,"aria-describedby":w,onChange:(b)=>c.onChange(b.target.value)});else N=e("input",{id:p,type:i.type==="url"?"url":"text",value:String(d),maxLength:i.max??500,required:i.required===!0,"aria-describedby":w,onChange:(b)=>c.onChange(b.target.value)});return n("div",{className:"host-field",children:[i.type==="multiselect"?e("span",{className:"field-label",children:i.label}):e("label",{htmlFor:p,children:i.label}),N,c.error||y?e("span",{id:`${p}-note`,className:c.error?"field-error":"hint",role:c.error?"alert":void 0,children:c.error??y}):null]})}function pe(c){let{spec:i}=c,[d,p]=r(()=>Ke(i.fields)),[y,w]=r(!1),[N,b]=r();return n("form",{className:"host-form",onSubmit:async(T)=>{if(T.preventDefault(),y)return;w(!0),b(void 0);try{b(await c.onSubmit(et(i.fields,d)))}catch(v){b({error:l(v)})}finally{w(!1)}},children:[i.fields.map((T)=>e(nt,{field:T,value:d[T.name]??"",error:N?.field===T.name?N.error:void 0,onChange:(v)=>p((V)=>({...V,[T.name]:v}))},T.name)),N&&!i.fields.some((T)=>T.name===N.field)?e(m,{message:N.error}):null,n("div",{className:"actions",children:[c.onCancel?e("button",{type:"button",className:"secondary",disabled:y,onClick:c.onCancel,children:t("Cancel")}):null,e("button",{type:"submit",disabled:y,children:i.submit})]})]})}function rt(c){if(!c.ok)return{error:or(c.error),...c.field?{field:c.field}:{}};if(c.notice)f(c.notice);if(c.open)sr(c.open);return}function oe(c){let[i,d]=r(),[p,y]=r(!1),w=async(b,h)=>rt(await c.run(b,h)),N=async(b)=>{if(b.form||b.confirm){d(b);return}y(!0);try{let h=await w(b,{});if(h)f(h.error,"danger")}catch(h){f(l(h),"danger")}finally{y(!1)}};if(c.actions.length===0)return null;return n("div",{className:c.className??"host-actions",children:[c.actions.map((b)=>e("button",{type:"button",className:b.style==="danger"?"danger":b.style==="secondary"?"secondary":"",disabled:p,onClick:()=>N(b),children:b.label},b.id)),i?.form?e(H,{open:!0,title:i.form.title,onClose:()=>d(void 0),children:e(pe,{spec:i.form,onCancel:()=>d(void 0),onSubmit:async(b)=>{let h=await w(i,b);if(!h)d(void 0);return h}})}):i?e(D,{open:!0,title:i.label,confirmLabel:i.label,tone:i.style==="danger"?"danger":"primary",onConfirm:async()=>{let b=await w(i,{});if(b)throw Error(b.error)},onClose:()=>d(void 0),children:e("p",{children:i.confirm})}):null]})}var _e=/^file:([A-Za-z0-9_-]{1,64})$/;function qe(c){let i=URL.parse(c,document.baseURI);return i!==null&&i.origin===window.location.origin}function ot({id:c,alt:i}){return e("img",{className:"file-image",src:`api/files/${encodeURIComponent(c)}`,alt:i,loading:"lazy",decoding:"async",onError:(d)=>{let p=document.createElement("span");p.textContent=i||t("Image"),d.currentTarget.replaceWith(p)}})}var re=ee(function({source:i}){return e("div",{className:"prose",children:e(jt,{remarkPlugins:[At],urlTransform:(d)=>_e.test(d)?d:Wn(d),components:{a:({href:d,children:p})=>d&&/^https?:\/\//.test(d)&&!qe(d)?e("a",{href:d,target:"_blank",rel:"noreferrer noopener",children:p}):d&&qe(d)?e("a",{href:d,children:p}):e("span",{children:p}),img:({src:d,alt:p})=>{let y=typeof d==="string"?_e.exec(d):null;return y?.[1]?e(ot,{id:y[1],alt:p??""}):e("span",{children:p})},pre:Kr,table:({children:d})=>e("div",{className:"table-wrap",children:e("table",{children:d})})},children:i})})});function st(c){switch(c??"open"){case"working":return t("Working…");case"done":return t("Done");case"superseded":return t("Replaced");case"expired":return t("Expired");default:return""}}var Se=(c)=>(c.state??"open")==="open";function ae(c){let{card:i}=c,d=st(i.state);return n("article",{className:"host-card","data-tone":i.tone??"note","data-state":i.state??"open",children:[n("header",{children:[e("h3",{children:i.title}),d?e(P,{tone:i.state==="working"?"busy":"plain",children:d}):null]}),i.body?e(re,{source:i.body}):null,i.links?.length?e("div",{className:"host-card-links",children:i.links.map((p)=>e("a",{href:p.url,...p.url.startsWith("/")?{}:{target:"_blank",rel:"noreferrer noopener"},children:p.label},`${p.url}`))}):null,Se(i)&&i.buttons?.length?e(oe,{actions:i.buttons,run:c.run}):null]})}ct();function it(){let[c,i]=r(()=>Bn().toString());return s(()=>{let d=()=>i(Bn().toString());return window.addEventListener("popstate",d),window.addEventListener("hashchange",d),()=>{window.removeEventListener("popstate",d),window.removeEventListener("hashchange",d)}},[]),c}function at(c){if(!c.ok)return{error:or(c.error),...c.field?{field:c.field}:{}};if(c.notice)f(c.notice);if(c.open)sr(c.open);return}function lt(c){let{section:i}=c;switch(i.kind){case"markdown":return e(re,{source:i.text});case"card":return e(ae,{card:i.card,run:c.run});case"form":return n("section",{className:"stack",children:[e("h2",{className:"section-title",children:i.form.title}),e(pe,{spec:i.form,onSubmit:(d)=>c.submit(i.action,d)})]});case"list":return n("section",{className:"stack",children:[i.title?e("h2",{className:"section-title",children:i.title}):null,i.rows.length===0?e(k,{children:t("Nothing here.")}):null,e("ul",{className:"host-list",children:mt(i.rows).map(([d,p])=>n("li",{children:[p.attention?e("span",{className:"attention-dot",role:"img","aria-label":t("Needs attention")}):null,n("div",{className:"host-list-main",children:[p.open?e("a",{href:p.open,...p.open.startsWith("/")?{}:{target:"_blank",rel:"noreferrer noopener"},children:p.title}):e("strong",{children:p.title}),p.subtitle?e("span",{children:p.subtitle}):null]}),p.actions?.length?e(oe,{actions:p.actions,run:c.run}):null]},d))})]})}}function dt({routeKey:c}){let i=c??"",d=it(),p=me((v)=>v.pages[i]??0),[y,w]=r(0),[N,b]=r({});s(()=>{let v=!0;return He.page(i,Object.fromEntries(new URLSearchParams(d))).then((V)=>v&&b({page:V}),(V)=>{if(!v)return;let q=V instanceof fe&&V.status===404;b((z)=>({...q||!z.page?{}:{page:z.page},error:l(V),gone:q}))}),()=>{v=!1}},[i,d,p,y]);let h=async(v,V)=>{let q=await He.pageAct(i,{action:v,input:V}),z=at(q);if(!z)w((I)=>I+1);return z},T=async(v,V)=>{let q=await He.pageAct(i,{action:v.id,input:V});if(q.ok)w((z)=>z+1);return q};if(N.gone)return e("div",{className:"page",children:e(k,{children:t("This page is not available.")})});if(!N.page)return e("div",{className:"page",children:N.error?e(m,{message:N.error}):e(x,{})});return n("div",{className:"page",children:[e("header",{className:"page-head",children:e("h1",{children:N.page.title})}),N.error?e(m,{message:N.error}):null,N.page.sections.map((v,V)=>e(lt,{section:v,run:T,submit:h},V))]})}function mt(c){let i=new Map;return c.map((d)=>{let p=i.get(d.title)??0;return i.set(d.title,p+1),[`${d.title}:${p}`,d]})}function ze(c){let i=me((T)=>T.cards[c.room]??Lo),d=Re("(min-width: 720px) and (min-height: 760px)"),[p,y]=r();if(i.length===0)return null;let w=i.filter((T)=>Se(T)||T.state==="working"),N=i.filter((T)=>!w.includes(T)),b=p??(d&&w.length>0),h=w[0];return n("div",{className:"host-cards","data-open":b||void 0,children:[n("button",{type:"button",className:"host-cards-toggle","aria-expanded":b,onClick:()=>y(!b),children:[e(o,{name:"chevron",size:14}),h?n("span",{children:[e("strong",{children:B(w.length,"{count} card waiting","{count} cards waiting")}),`: ${h.title}`]}):e("span",{children:t("Earlier cards ({count})",{count:N.length})})]}),b?n("div",{className:"host-cards-body",children:[w.map((T)=>e(ae,{card:T,run:c.run(T.id)},T.id)),N.length?n("details",{className:"host-cards-older",children:[e("summary",{children:t("Earlier cards ({count})",{count:N.length})}),N.map((T)=>e(ae,{card:T,run:c.run(T.id)},T.id))]}):null]}):null]})}var ft=/https?:\/\/[^\s<>"']+/g,pt=/[.,;:!?)\]}\u3001\u3002\uff0c\uff1b\uff1a\uff01\uff1f\uff09\u300d\u300f]+$/;function gt(c){let i=c.replace(pt,""),d=URL.parse(i);return d&&(d.protocol==="https:"||d.protocol==="http:")?i:""}function De({text:c}){let i=[],d=0;for(let p of c.matchAll(ft)){let y=gt(p[0]);if(y==="")continue;let w=p.index;if(w>d)i.push(c.slice(d,w));i.push(e("a",{href:y,target:"_blank",rel:"noreferrer noopener",children:y},`${w}`)),d=w+y.length}if(d<c.length)i.push(c.slice(d));return e("span",{className:"plain",children:i})}var Ue=ee(function(i){let{message:d}=i,p=d.authorKind??"external";if(p==="notice")return n("li",{className:"host-notice","data-mid":d.id,"data-highlight":i.highlighted||void 0,"data-enter":i.enter||void 0,children:[e(o,{name:"bell",size:14}),e(re,{source:d.text}),e("time",{dateTime:d.at,children:Kt(d.at,i.timeZone)})]});let y=p==="member"&&d.principalId!==void 0&&d.principalId===i.me;return n("li",{className:"message","data-mid":d.id,"data-author":p,"data-mine":y||void 0,"data-header":i.header||void 0,"data-enter":i.enter||void 0,"data-unread":i.unread||void 0,"data-highlight":i.highlighted||void 0,children:[y?null:e("span",{className:"message-avatar",children:i.header?e(ut,{picture:d.picture,name:d.author}):null}),n("div",{className:"message-main",children:[i.header?n("div",{className:"message-meta",children:[e("strong",{children:d.author}),d.authorLabel?e("span",{className:"label-chip",children:d.authorLabel}):null,e("time",{dateTime:d.at,children:Kt(d.at,i.timeZone)})]}):null,n("div",{className:"bubble",children:[e(no,{files:d.files}),d.text?p==="assistant"?e(re,{source:d.text}):e(De,{text:d.text}):null,e(Xt,{files:d.files,message:d}),d.expiredFiles?e("p",{className:"message-expired",children:B(d.expiredFiles,"{count} file was removed","{count} files were removed")}):null]}),d.edited?e("span",{className:"message-edited",children:t("edited")}):null]})]})});var ht=1500,bt=96,ge=new Set,Ae=new Map;function yt(c){if(document.visibilityState!=="visible")return!1;return!c||c.scrollHeight-c.scrollTop-c.clientHeight<bt}function $e(c){if(!(c instanceof Element))return;let i=c.closest("[data-unread][data-mid]");return i?Number(i.dataset.mid):void 0}function Be(c){let{room:i,scroller:d,messages:p,began:y,enterAfter:w,me:N,shared:b}=c,h=a({seen:void 0,watched:new Set}),[,T]=r(0),v=Ae.get(i)??ge;if(w!==void 0&&p){let M=h.current;M.seen??=w;let F=yt(d.current),Z=M.seen;for(let L of p){if(L.id<=M.seen)continue;if(F)M.watched.add(L.id);Z=Math.max(Z,L.id)}M.seen=Z}let V=R(()=>{if(y===void 0||w===void 0||!p)return ge;let M=new Set;for(let F of p){if(F.id===0||F.id<=y)continue;if(F.kind==="system"||F.note)continue;if(F.authorKind==="notice")continue;if(F.principalId===void 0?F.kind==="owner"&&!b:F.principalId===N)continue;if(h.current.watched.has(F.id)||v.has(F.id))continue;M.add(F.id)}return M.size===0?ge:M},[p,y,w,N,b,v]),q=E((M)=>{let F=Ae.get(i)??ge;if(F.has(M))return;Ae.set(i,new Set(F).add(M)),T((Z)=>Z+1)},[i]),z=V.size>0;s(()=>{let M=d.current;if(!M||!z)return;let F=(L)=>{if(L.pointerType==="touch")return;let W=$e(L.target);if(W!==void 0)q(W)},Z=(L)=>{let W=$e(L.target);if(W!==void 0)q(W)};return M.addEventListener("pointerover",F,{passive:!0}),M.addEventListener("focusin",Z,{passive:!0}),M.addEventListener("click",Z,{passive:!0}),()=>{M.removeEventListener("pointerover",F),M.removeEventListener("focusin",Z),M.removeEventListener("click",Z)}},[d,q,z]);let I=a(new Map),G=[...V].join(",");return s(()=>{let M=d.current,F=I.current;for(let[Q,Y]of F)if(!V.has(Q))clearTimeout(Y),F.delete(Q);if(!M||!z||typeof IntersectionObserver!=="function"||!matchMedia("(pointer: coarse)").matches)return;let Z=(Q)=>{let Y=F.get(Q);if(Y===void 0)return;clearTimeout(Y),F.delete(Q)},L=new IntersectionObserver((Q)=>{for(let Y of Q){let ne=Number(Y.target.dataset.mid),le=Y.rootBounds;if(!(Y.isIntersecting&&(Y.intersectionRatio>=0.5||le!==null&&Y.intersectionRect.height>=le.height*0.5))){Z(ne);continue}if(F.has(ne))continue;F.set(ne,setTimeout(()=>{if(F.delete(ne),document.visibilityState==="visible")q(ne)},ht))}},{root:M,threshold:[0,0.25,0.5,0.75,1]}),W=[...M.querySelectorAll("[data-unread][data-mid]")];for(let Q of W)L.observe(Q);let j=()=>{if(document.visibilityState!=="visible")return;for(let Q of W)L.unobserve(Q),L.observe(Q)};return document.addEventListener("visibilitychange",j),()=>{document.removeEventListener("visibilitychange",j),L.disconnect()}},[d,q,z,G]),s(()=>{let M=I.current;return()=>{for(let F of M.values())clearTimeout(F);M.clear()}},[]),V}ct();var vt=3;function wt({marks:c}){let[i,d]=r(!1);return n("li",{className:"seen",children:[n("button",{type:"button",className:"seen-toggle","aria-expanded":i,onClick:()=>d((p)=>!p),children:[c.slice(0,vt).map((p)=>e(ut,{picture:{principal:p.principal},name:p.name,size:16},p.principal)),e("span",{children:t("Seen by {count}",{count:c.length})})]}),i?e("span",{className:"seen-names",children:c.map((p)=>p.name).join(t(", "))}):null]})}function kt(c,i){let d=Xe(),p=u((y)=>y.connects);s(()=>{let y=i.current;if(!y)return;let w=0,N=0,b,h,T=()=>{if(h=void 0,document.visibilityState!=="visible")return;let q=y.getBoundingClientRect(),z=0;for(let G of y.querySelectorAll("[data-mid]")){let M=G.getBoundingClientRect();if(M.bottom>q.top&&M.top<q.bottom-4)z=Math.max(z,Number(G.dataset.mid))}if(z<=w)return;let I=N+1000-Date.now();if(I>0){clearTimeout(b),b=setTimeout(v,I);return}if(d.send({type:"read",room:c,upTo:z}))w=z,N=Date.now()},v=()=>{if(h===void 0)h=requestAnimationFrame(T)};y.addEventListener("scroll",v,{passive:!0}),document.addEventListener("visibilitychange",v),window.addEventListener("resize",v);let V=new MutationObserver(v);return V.observe(y,{childList:!0,subtree:!0}),v(),()=>{if(y.removeEventListener("scroll",v),document.removeEventListener("visibilitychange",v),window.removeEventListener("resize",v),V.disconnect(),clearTimeout(b),h!==void 0)cancelAnimationFrame(h)}},[d,c,i,p])}function he(c){let{roomKey:i}=c;kt(i,c.scroller);let d=u((v)=>v.principal?.id),p=u((v)=>v.rooms[i]?.messages),y=me((v)=>v.reads[i]??No),w=me((v)=>v.cursor[i]),N=a(void 0);if(N.current===void 0&&w!==void 0)N.current=w;let b=u((v)=>v.rooms[i]?.view?.notes===!0),h=Be({room:i,scroller:c.scroller,messages:p,began:N.current,enterAfter:c.enterAfter,me:d,shared:c.host===!0||b}),T=R(()=>{let V=(p??[]).filter((I)=>I.kind!=="system"),q=N.current===void 0?void 0:V.find((I)=>I.id>(N.current??0)&&(I.principalId===void 0||I.principalId!==d))?.id,z=new Map;for(let I of y){if(I.principal===d)continue;let G=V.findLast((M)=>M.id<=I.upTo);if(G)z.set(G.id,[...z.get(G.id)??[],I])}return{before:(I)=>I.id===q?e("li",{className:"new-divider",children:e("span",{children:t("New messages")})}):null,after:(I)=>{let G=z.get(I.id);return G?e(wt,{marks:G}):null},unread:(I)=>h.has(I.id),...c.host?{message:(I,G)=>I.kind==="system"&&I.authorKind===void 0?void 0:e(Ue,{message:I,header:G.header,enter:G.enter,unread:G.unread,timeZone:G.timeZone,me:d,highlighted:c.highlight===I.id})}:{}}},[p,y,d,c.host,c.highlight,h]);return e(Qn,{roomKey:i,enterAfter:c.enterAfter,quotable:c.quotable,decor:T})}ct();var Nt=20,Ht=2600,Ge;function Rt(c,i,d){let p=u((b)=>b.connects),y=me((b)=>b.rooms[c]??0),[w,N]=r({view:void 0,error:void 0,gone:!1});return s(()=>{let b=!0;return He.open(i,d).then((h)=>{if(!b)return;O.dispatch({type:"history_loaded",room:c,messages:h.messages,more:h.more,older:!1}),Cr(c,h.reads,h.cursor),Xo(c,h.cards),N({view:h,error:void 0,gone:!1})},(h)=>{if(!b)return;let T=h instanceof fe&&h.status===404;N((v)=>({view:T?void 0:v.view,error:l(h),gone:T}))}),()=>{b=!1}},[c,i,d,p,y]),w}function St(c){let{header:i}=c;return n(g,{children:[i.banner?e("p",{className:"host-banner","data-tone":i.banner.tone,role:"status",children:i.banner.text}):null,i.fields.length?e("dl",{className:"host-head-fields",children:i.fields.map((d)=>n("div",{children:[e("dt",{children:d.label}),e("dd",{children:d.link?e("a",{href:d.link,...d.link.startsWith("/")?{}:{target:"_blank",rel:"noreferrer noopener"},children:d.value}):d.value})]},`${d.label}:${d.value}`))}):null,e(oe,{className:"host-actions bar",actions:i.actions,run:c.run})]})}function Et({roomKey:c}){let i=Xe(),d=ps(c),p=d?.kind??"",y=d?.id??"",{view:w,error:N,gone:b}=Rt(c,p,y),h=u((C)=>C.rooms[c]),T=u((C)=>C.limits),v=u((C)=>C.connects),V=u((C)=>C.connection==="open"),q=a(null),z=a(null),{away:I,onScroll:G,onGrow:M,toEnd:F}=Sr(q),[Z,L]=r(!1),[W,j]=r(),[Q,Y]=r(Ge),[ne,le]=r(!1),[Le,Te]=r(),ye=a(void 0),se=a(void 0),J=w!==void 0,ce=vr(!Re("(min-width: 1024px)"));if(s(()=>{if(!d||b||!J)return;return i.send({type:"subscribe",room:c}),i.focus(c),()=>{i.focus(void 0),i.send({type:"unsubscribe",room:c})}},[i,c,v,b,J]),J&&ye.current===void 0)ye.current=h?.messages.at(-1)?.id??0;Pe(()=>{if(J)F(!1)},[J]),Pe(()=>{let C=q.current;if(C&&se.current!==void 0)C.scrollTop+=C.scrollHeight-se.current,se.current=void 0},[h?.messages[0]?.id]),s(()=>{let C=z.current;if(!C||typeof ResizeObserver>"u")return;let U=new ResizeObserver(M);return U.observe(C),()=>U.disconnect()},[M]);let ve=E(async()=>{let C=O.getState().rooms[c]?.messages[0];if(!C)return!1;let U=await He.older(p,y,C.id,yn);return O.dispatch({type:"history_loaded",room:c,messages:U.messages,more:U.more,older:!0}),Cr(c,U.reads,void 0),U.more},[c,p,y]),de=a(void 0);s(()=>{let C=()=>{let U=Number(Bn().get("message"));de.current=Number.isSafeInteger(U)&&U>0?U:void 0};return C(),window.addEventListener("popstate",C),()=>window.removeEventListener("popstate",C)},[]);let we=h?.messages[0]?.id,Me=h?.more===!0;s(()=>{let C=de.current,U=q.current;if(!J||C===void 0||!U)return;let X=U.querySelector(`[data-mid="${C}"]`);if(X){de.current=void 0,X.scrollIntoView({block:"center"}),Te(C),requestAnimationFrame(()=>U.dispatchEvent(new Event("scroll"))),setTimeout(()=>Te(void 0),Ht);return}if(we!==void 0&&C<we&&Me){let ie=0;(async()=>{if(ie+=1,!await ve().catch(()=>!1)||ie>=Nt)de.current=void 0})()}},[J,we,Me,h?.messages.length,ve]);let Fe=(C,U={},X)=>He.act(p,y,{action:C.id,...X===void 0?{}:{card:X},input:U}),Qe=(C,U)=>Fe(C,U),Ye=(C)=>(U,X)=>Fe(U,X,C);if(b||!J&&!N&&!d)return e("section",{className:"room",children:n("div",{className:"page",children:[e(k,{children:t("This room is not available.")}),e("a",{className:"back",href:S("rooms"),children:t("Back to rooms")})]})});let K=w?.access.send??[],Ne=K.length>1,xe=Ne&&ne,Ie=Q&&K.includes(Q)?Q:K.includes("turn")?"turn":K[0],Ve=xe||Ie==="turn",Je=Ve?w?.wording?.turn?.placeholder??t("Ask AI…"):w?.wording?.note?.placeholder??t("Write an internal note…"),ue=w?.header.title??c,je=h?.messages??[];return n("section",{className:"room",...ce.surface,onDragOver:(C)=>{if(K.length&&C.dataTransfer.types.includes("Files"))C.preventDefault()},onDrop:(C)=>{if(!K.length||!C.dataTransfer.files.length)return;C.preventDefault(),j([...C.dataTransfer.files])},children:[n("header",{className:"room-head",children:[e("a",{className:"icon-button room-back",href:S("rooms"),"aria-label":t("Back to rooms"),children:e(o,{name:"back"})}),e(fr,{open:ce.enabled?ce.show:void 0,children:e(ut,{name:ue,size:40})}),n("div",{className:"room-title",children:[e("h1",{children:ue}),e("span",{className:"room-status","data-working":h?.typing||void 0,children:h?.typing?t("Working…"):t("Host room")})]})]}),!V?n("div",{className:"offline-banner",role:"status",children:[e("span",{className:"spinner","aria-hidden":"true"}),t("Reconnecting… messages wait here until it is back.")]}):null,w?e(St,{header:w.header,run:Qe}):null,e("div",{className:"room-scroll",ref:q,onScroll:G,children:n("div",{className:"room-content",ref:z,children:[N?e(m,{message:N}):null,!J&&!N?e(x,{}):null,h?.more?e("button",{type:"button",className:"secondary older",disabled:Z,onClick:async()=>{L(!0),se.current=q.current?.scrollHeight;try{await ve()}catch(C){se.current=void 0,f(l(C),"danger")}finally{L(!1)}},children:Z?t("Loading…"):t("Load earlier messages")}):null,J&&je.length===0?e(k,{children:t("No messages yet.")}):null,e(he,{roomKey:c,enterAfter:ye.current,quotable:!1,scroller:q,host:!0,highlight:Le}),h?.typing?e(Sn,{name:ue,progress:h.progress}):null]})}),I?n("button",{type:"button",className:"to-end",onClick:()=>F(!0),children:[e(o,{name:"send",size:16,style:{transform:"rotate(180deg)"}}),t("Latest")]}):null,w?e(ze,{room:c,run:Ye}):null,w&&K.length===0?e("p",{className:"room-note",children:t("You can read this room but not write in it.")}):null,w&&K.length>0?e(g,{children:e($t,{draftKey:c,name:ue,placeholder:Je,onAddressed:le,...Ne?{above:e(Br,{on:Ve,label:w?.wording?.turn?.label??t("@AI"),...xe?{locked:t("The message starts with @AI, so the knight answers.")}:{},onChange:(C)=>{let U=C?"turn":"note";Ge=U,Y(U)}})}:{},limits:T,stoppable:Boolean(h?.stoppable),onSend:(C,U,X)=>{if(Ne&&X){let ie=xn(C);i.say(c,ie===""&&U.length===0?C:ie,U,"turn")}else i.say(c,C,U,Ie);F(!0)},onStop:()=>i.send({type:"stop",room:c}),...W?{incoming:W,onIncomingTaken:()=>j(void 0)}:{}},c)}):null,e(xr,{...ce.drawer,current:c})]})}ct();function be({room:c}){let i=me((d)=>d.unread[c]??0);if(i<=0)return null;return e("span",{className:"unread-mark",role:"img","aria-label":B(i,"{count} unread message","{count} unread messages"),children:i>99?"99+":i})}ct();var Ct=6,Lt=250;function Ce(c){let{kind:i}=c,{timeZone:d}=_(),{now:p}=te(),y=u((L)=>L.connects),w=me((L)=>L.lists[i]??0),[N,b]=r(""),[h,T]=r(""),[v,V]=r(),[q,z]=r(),[I,G]=r(),[M,F]=r(!1);s(()=>{let L=setTimeout(()=>T(N.trim()),Lt);return()=>clearTimeout(L)},[N]),s(()=>{let L=!0;return He.list(i,h||void 0).then((W)=>{if(!L)return;ln(Object.fromEntries(W.rooms.map((j)=>[j.key,j.unread??0]))),V(W.rooms),z(W.cursor),G(void 0)},(W)=>L&&G(l(W))),()=>{L=!1}},[i,h,y,w]);let Z=async()=>{if(!q||M)return;F(!0);try{let L=await He.list(i,h||void 0,q);ln(Object.fromEntries(L.rooms.map((W)=>[W.key,W.unread??0]))),V((W)=>[...W??[],...L.rooms]),z(L.cursor)}catch(L){G(l(L))}finally{F(!1)}};return n("section",{className:"stack",children:[n("h2",{className:"section-title",children:[c.icon?e(o,{name:c.icon,size:14,className:"section-icon"}):null,c.label]}),v&&(v.length>=Ct||h||N)?e("input",{type:"search",className:"kind-filter",value:N,placeholder:t("Search {name}",{name:c.label}),"aria-label":t("Search {name}",{name:c.label}),onChange:(L)=>b(L.target.value)}):null,I?e(m,{message:I}):null,!v&&!I?n("div",{className:"stack","aria-busy":"true",children:[e("div",{className:"skeleton"}),e("div",{className:"skeleton"})]}):null,v&&v.length===0?e(k,{children:h?t("Nothing matches."):t("No rooms yet.")}):null,v&&v.length>0?e("ul",{className:"room-list",children:v.map((L)=>e("li",{children:n("a",{className:"room-row",href:S("room",L.key),"aria-current":L.key===c.active?"page":void 0,children:[n("span",{className:"kind-row-picture",children:[e(ut,{picture:L.picture,name:L.title,size:44}),L.attention?e("span",{className:"attention-dot",role:"img","aria-label":t("Needs attention")}):null]}),n("span",{className:"room-row-main",children:[n("span",{className:"room-row-top",children:[e("strong",{children:L.title}),e(be,{room:L.key}),e("span",{className:"room-row-time",children:L.lastAt?ke(L.lastAt,p,d):""})]}),e("span",{className:"room-row-preview",children:e("span",{children:L.subtitle??""})})]}),e(o,{name:"chevron",size:16,className:"room-row-chevron"})]})},L.key))}):null,q?e("button",{type:"button",className:"secondary",disabled:M,onClick:Z,children:M?t("Loading…"):t("Show more")}):null]})}function We(c){return c.kinds.map((i)=>e(Ce,{kind:i.kind,label:i.label,...i.icon?{icon:i.icon}:{},active:c.active},i.kind))}function Ze(){let c=(_().pages??[]).filter((i)=>i.place==="settings");if(c.length===0)return null;return n("section",{className:"card stack",children:[e("h2",{children:t("More settings")}),c.map((i)=>n("a",{className:"menu-item menu-link",href:S("p",i.id),children:[e("span",{className:"menu-text",children:e("strong",{children:i.label})}),e(o,{name:"chevron",size:16})]},i.id))]})}export{We as HostKinds,dt as HostPage,Et as HostRoomPage,Ze as HostSettingsPages,he as ReadLog,be as UnreadMark};
@@ -1,2 +0,0 @@
1
- import{M,h}from"./chunk-index-s356ybxk.js";var Qo={page:(e,t,o,c=50)=>h(`rooms/${encodeURIComponent(e)}/messages?archive=${t}&limit=${c}${o===void 0?"":`&before=${o}`}`)},n,{emit:r,use:s}=M();function sa(e,t){n={room:e,until:t},r()}function aa(){if(!n)return;n=void 0,r()}var la=()=>s(()=>n),i;function ca(e,t){i={author:e,text:t},r()}function Mo(){if(!i)return;i=void 0,r()}var ua=()=>s(()=>i);
2
- export{Qo,sa,aa,la,ca,Mo,ua};
@@ -1,2 +0,0 @@
1
- import{t,Oe,Cs,Ni}from"./chunk-index-s356ybxk.js";import{De}from"./chunk-index-axw4wkqq.js";import{qi}from"./chunk-index-xx0kecz9.js";function mi(e){let r=e.getBoundingClientRect(),o=Cs();Oe({title:t("Rooms"),items:[...qi(),{id:"new-folder",label:t("Add a folder"),icon:"plus",run:()=>De({kind:"new"})},{id:"arrange",label:o?t("Done"):t("Arrange"),icon:o?"check":"list",run:()=>Ni(!o)}],at:{x:r.left,y:r.bottom},via:"key",source:e})}
2
- export{mi};
@@ -1,2 +0,0 @@
1
- import{ms,O,M,kr}from"./chunk-index-s356ybxk.js";var t=()=>kr(ms);function zi(e){return e.kind==="owner"&&e.delivery==="queued"&&e.principalId!==void 0&&e.principalId===O.getState().principal?.id}function zs(e){t().send({type:"cancel_queued",room:e.room,message:e.id})}function Is(e,i){t().send({type:"edit_queued",room:e.room,message:e.id,text:i})}var o,{emit:n,use:r}=M();function Ii(e){o=e,n()}function So(){if(!o)return;o=void 0,n()}var Ds=()=>r(()=>o);
2
- export{zi,zs,Is,Ii,So,Ds};
@@ -1 +0,0 @@
1
- import{Je,co,tn,uo,W,ae,Xi,fo,va,xa,ho,Sa,wa,ka,Cn}from"./chunk-index-50syrmaq.js";export{tn as AVATAR_STATES,W as CATALOG,Je as CLASS_IDS,ae as CharacterError,xa as EAST_ASIAN_SKINS,co as EXPRESSIONS,uo as STATE_EXPRESSION,wa as accentOf,ka as characterCss,ho as checkSkins,Sa as composeSvg,fo as parseCharacter,va as readCharacter,Xi as resolveCharacter,Cn as suggestCharacter};
@@ -1,2 +0,0 @@
1
- import{e}from"./chunk-index-s356ybxk.js";import{C}from"./chunk-index-e8535c4h.js";function H(t){return e(C,{open:t.open,title:t.title,onClose:t.onClose,...t.size&&t.size!=="default"?{size:t.size}:{},children:t.children})}
2
- export{H};
@@ -1,2 +0,0 @@
1
- import{oi}from"./chunk-index-hsc9yz2x.js";var f=12;function m(r,e){let t=r.find((u)=>e>=u.top&&e<=u.bottom);if(t)return t;let n,o=f+1;for(let u of r){let i=e<u.top?u.top-e:e-u.bottom;if(i<o)n=u,o=i}return n}function d(r,e,t){for(let n of r)if(n.key!==e&&n.top+n.height/2>t)return n.key;return null}function As(r,e,t){let n=m(r,t);return n?{zone:n,before:d(n.items,e,t)}:void 0}function $s(r,e,t){let{zone:n,before:o}=t;if(n.kind==="rest")return r.kind==="rest"?void 0:{kind:"unplace"};if(n.kind==="pinned"&&r.kind==="pinned"||n.kind==="folder"&&r.kind==="folder"&&r.folder===n.folder){let i=r.siblings;if(oi(i,e,o).every((s,l)=>s===i[l]))return}return n.kind==="pinned"?{kind:"pin",before:o}:{kind:"folder",folder:n.folder,before:o}}function Ns(r,e,t,n){if(n<e.top-f*3||n>e.bottom+f*3)return;return{before:d(r,t,n)}}function vo(r,e,t,n=0){let o=(r[e]?.height??0)+n;return r.map((u,i)=>{if(i===e)return 0;if(e<t&&i>e&&i<=t)return-o;if(e>t&&i>=t&&i<e)return o;return 0})}function xo(r,e,t){return oi(r,e,t).indexOf(e)}function Ls(r,e,t,n=64,o=18){if(r<e+n)return-Math.min(1,(e+n-r)/n)*o;if(r>t-n)return Math.min(1,(r-(t-n))/n)*o;return 0}var Xs=600;
2
- export{As,$s,Ns,vo,xo,Ls,Xs};
@@ -1,2 +0,0 @@
1
- import{M}from"./chunk-index-s356ybxk.js";var e,{emit:o,use:n}=M();function De(i){e=i,o()}function Ui(){if(!e)return;e=void 0,o()}var Ws=()=>n(()=>e);
2
- export{De,Ui,Ws};
@@ -1,2 +0,0 @@
1
- import{s,r,l,te}from"./chunk-index-s356ybxk.js";function Se(f,e){let{version:o}=te(),[t,a]=r({data:void 0,error:void 0,subject:e});return s(()=>{let n=!0;return f().then((d)=>{if(n)a({data:d,error:void 0,subject:e})},(d)=>{if(n)a((i)=>({data:i.subject===e?i.data:void 0,error:l(d),subject:e}))}),()=>{n=!1}},[e,o]),t.subject===e?{data:t.data,error:t.error}:{data:void 0,error:void 0}}
2
- export{Se};
@@ -1,2 +0,0 @@
1
- import{t,e,n,o}from"./chunk-index-s356ybxk.js";import{Vn}from"./chunk-index-5x3h176v.js";function bi({auth:r}){if(r!=="password"&&r!=="oidc")return null;return e("form",{method:"post",action:"auth/logout",onSubmit:(s)=>{s.preventDefault();let i=s.currentTarget;Vn().catch(()=>{return}).finally(()=>i.submit())},children:e("div",{className:"actions",children:n("button",{type:"submit",className:"secondary",children:[e(o,{name:"logout",size:16}),t("Log out")]})})})}
2
- export{bi};
@@ -1,2 +0,0 @@
1
- import{p,s,a,Oe,pr,$i}from"./chunk-index-s356ybxk.js";var D=6,g=()=>(p("sw692nr3"),import("./chunk-drag-sw692nr3.js"));var h=()=>{return},L=0;function Vr(){if(L++===0)window.addEventListener("touchmove",h,{passive:!1});return()=>{if(--L===0)window.removeEventListener("touchmove",h)}}function Yt(T,m){let d=a(m);d.current=m;let E=m!==void 0;s(()=>E?Vr():void 0,[E]);let t=a(void 0),f=a(void 0),c=a(!1),v=(e,n,r)=>T(e).then((i)=>{if(i)Oe({...i,at:n,via:r,source:e})},()=>{return}),y=(e,n,r,i)=>{let u=d.current,M=u?.item(e),P=u?.root(e);if(!u||!M||!P)return!1;return f.current??=g(),f.current.then(({lift:x})=>{if(t.current?.id!==n)return i();x({mode:u.mode,key:u.key,item:M,root:P,pointerId:n,y:r(),open:u.open,done:(l)=>{if(l.type==="tap")i();else if(l.type!=="cancel")u.onDrop(l)}})},i),!0},o=pr((e)=>{let n=()=>v(e.source,e.at,e.via),r=t.current;if(!(e.via==="hold"||e.via==="contextmenu"&&r?.touch)||!r)return void n();if(!y(e.source,r.id,()=>r.y,n))return void n();if(e.via==="contextmenu")c.current=!0});return{...o,onPointerDown(e){if(c.current=!1,t.current={id:e.pointerId,x:e.clientX,y:e.clientY,touch:e.pointerType!=="mouse"},e.pointerType!=="mouse"&&$i(e.clientX,window.innerWidth))t.current=void 0;else if(d.current)f.current??=g();o.onPointerDown(e)},onPointerMove(e){let n=t.current;if(n?.id===e.pointerId){if(e.pointerType==="mouse"&&e.buttons===1&&!c.current&&d.current&&Math.hypot(e.clientX-n.x,e.clientY-n.y)>D)c.current=y(e.currentTarget,e.pointerId,()=>e.clientY,()=>{return});n.y=e.clientY}o.onPointerMove(e)},onPointerUp(e){if(t.current?.id===e.pointerId)t.current=void 0;o.onPointerUp(e)},onPointerCancel(e){if(t.current?.id===e.pointerId)t.current=void 0;o.onPointerCancel(e)},onContextMenu:o.onContextMenu,onKeyDown:o.onKeyDown,onClickCapture(e){if(c.current){c.current=!1,e.preventDefault(),e.stopPropagation();return}o.onClickCapture(e)},onDragStart(e){e.preventDefault()}}}
2
- export{Vr,Yt};
@@ -1,2 +0,0 @@
1
- import{p}from"./chunk-index-s356ybxk.js";var e=()=>(p("rw5myg2t"),import("./chunk-layout-actions-rw5myg2t.js")),wi=(r)=>({mode:"room",key:r,item:(o)=>o.closest("[data-drop-item]"),root:(o)=>o.closest("[data-drop-root]"),onDrop:(o)=>{if(o.type==="room")e().then((t)=>t.dropRoom(r,o.drop))},open:(o)=>void (p("rb1b069h"),import("./chunk-folds-rb1b069h.js")).then((t)=>t.expandFolder(o))});
2
- export{wi};
@@ -1,2 +0,0 @@
1
- import{E,s,r,l,te}from"./chunk-index-s356ybxk.js";function un(n){let{version:i}=te(),[a,u]=r(0),[f,d]=r(),[c,o]=r();s(()=>{let e=!0;return n().then((t)=>{if(!e)return;d(t),o(void 0)},(t)=>{if(e)o(l(t))}),()=>{e=!1}},[a,i]);let m=E(()=>u((e)=>e+1),[]);return{data:f,error:c,reload:m}}
2
- export{un};
@@ -1,2 +0,0 @@
1
- import{M}from"./chunk-index-s356ybxk.js";var o=!1,{emit:e,use:t}=M();function Jo(){if(o)return;o=!0,e()}function pi(){if(!o)return;o=!1,e()}var es=()=>t(()=>o),ts=()=>o,ns=()=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);
2
- export{Jo,pi,es,ts,ns};
@@ -1,2 +0,0 @@
1
- import{O,h,l,f}from"./chunk-index-s356ybxk.js";import{$s}from"./chunk-index-ar1x9fhw.js";import{zo,Nn}from"./chunk-index-kvztbfqj.js";import{tt,pa,ma,ga,Oa,ya}from"./chunk-index-hsc9yz2x.js";import{Ut}from"./chunk-index-6ycrvwzs.js";var n={createFolder:(e)=>h("folders",{method:"POST",body:JSON.stringify({name:e})}),changeFolder:(e,t)=>h(`folders/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),deleteFolder:(e)=>h(`folders/${encodeURIComponent(e)}`,{method:"DELETE"}),muteFolder:(e,t)=>h(`folders/${encodeURIComponent(e)}/mute`,{method:"PUT",body:JSON.stringify({muted:t})}),placeRoom:(e,t,o)=>h(`rooms/${encodeURIComponent(e)}/folder`,{method:"PUT",body:JSON.stringify({folder:t,before:o})}),pinRoom:(e,t,o)=>h(`rooms/${encodeURIComponent(e)}/pin`,{method:"PUT",body:JSON.stringify({pinned:t,before:o})})};var a=(e)=>f(e,"danger"),d=(e)=>O.dispatch({type:"layout_loaded",pins:e.pins,folders:e.folders});async function i(e,t,o=a){let r=zo();try{d(e(r))}catch{}try{let s=await t();return d(s),s}catch(s){d(r),O.dispatch({type:"changed"}),o(l(s));return}}var Es=(e,t,o=null)=>i((r)=>ya(r,e,t,o),()=>n.pinRoom(e,t,o)),nn=(e,t,o=null)=>i((r)=>Oa(r,e,t,o),()=>n.placeRoom(e,t,o));function Qr(e,t){let o=Ut(Nn(),e);if(o.kind==="rest")return;let r=tt(o.siblings,e,t);if(!r)return;return o.kind==="pinned"?Es(e,!0,r.before):nn(e,o.folder,r.before)}async function Oo(e,t=a){try{let o=await n.createFolder(e);return d(o),o.folders.at(-1)?.id}catch(o){t(l(o));return}}var yo=(e,t,o)=>i((r)=>pa(r,e,t),()=>n.changeFolder(e,{name:t}),o),_a=(e,t)=>i((o)=>ma(o,e,t),()=>n.changeFolder(e,{before:t}));function Ma(e,t){let o=tt(zo().folders.map((r)=>r.id),e,t);return o?_a(e,o.before):void 0}var bo=(e,t)=>i((o)=>ga(o,e),()=>n.deleteFolder(e),t);async function Ra(e,t){try{let o=await n.muteFolder(e,t);for(let r of o.rooms)O.dispatch({type:"room_muted",room:r,muted:o.muted});return!0}catch(o){return a(l(o)),!1}}function Ca(e,t){let o=$s(Ut(Nn(),e),e,t);if(!o)return;if(o.kind==="pin")return Es(e,!0,o.before);if(o.kind==="folder")return nn(e,o.folder,o.before);return nn(e,null)}
2
- export{Es,nn,Qr,Oo,yo,_a,Ma,bo,Ra,Ca};
@@ -1,2 +0,0 @@
1
- import{rt,u}from"./chunk-index-s356ybxk.js";import{An}from"./chunk-index-nncy9wxw.js";var rn=An,ni=2,l="rt-table-council",i,s=!1,f=new Set;function c(){try{return globalThis.localStorage?.getItem(l)??void 0}catch{return}}function g(){if(!s)i=c(),s=!0;return i}function ko(n){i=n,s=!0;try{globalThis.localStorage?.setItem(l,n)}catch{}for(let e of f)e()}var a=(n)=>(f.add(n),()=>f.delete(n)),Us=()=>rt(a,g,()=>{return});function Di(){return u((n)=>n.order.map((e)=>n.rooms[e]?.view).filter((e)=>e!==void 0&&e.kind==="group"),"councils")}function Vs(n,e,r){let t=(o)=>o===void 0?void 0:n.find((d)=>d.key===o||d.name===o);return t(r)??t(e)??n[0]}function qs(n){return[...n].filter((e)=>e.muted!==!0&&!e.helper).sort((e,r)=>Number(r.home)-Number(e.home)).slice(0,rn).map((e)=>e.name)}function Bs(n,e,r=rn){if(n.includes(e))return n.filter((t)=>t!==e);return n.length>=r?[...n]:[...n,e]}function Fs(n,e){return n.filter(e).slice(0,rn)}function Gs(n,e,r){if(e!==void 0&&n.includes(e))return e;if(r!==void 0&&n.includes(r))return r;return n[0]??""}function Zs(n,e){let r=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,28)||"council";if(!e.has(r))return r;for(let t=2;;t+=1){let o=`${r}-${t}`;if(!e.has(o))return o}}
2
- export{rn,ni,ko,Us,Di,Vs,qs,Bs,Fs,Gs,Zs};
@@ -1,2 +0,0 @@
1
- var ha=40;class l extends Error{code;constructor(e){super(e);this.code=e;this.name="LayoutError"}}function oi(e,n,r){if(r===n&&e.includes(n))return[...e];let t=e.filter((o)=>o!==n),i=r===null||r===void 0?-1:t.indexOf(r);if(i<0)return[...t,n];return[...t.slice(0,i),n,...t.slice(i)]}function tt(e,n,r){let t=e.indexOf(n);if(t<0)return;if(r==="up")return t===0?void 0:{before:e[t-1]??null};return t===e.length-1?void 0:{before:e[t+2]??null}}function Io(e){let n=e.trim(),r=Array.from(n).length;if(r<1||r>40||/\p{Cc}/u.test(n))throw new l("bad-name");return n}var c=(e,n)=>e.toLocaleLowerCase()===n.toLocaleLowerCase();function u(e,n){let r=e.folders.findIndex((t)=>t.id===n);if(r<0)throw new l("no-folder");return r}var f=(e,n)=>({pins:e.pins,folders:n});function pa(e,n,r){let t=u(e,n),i=Io(r);if(e.folders.some((o)=>o.id!==n&&c(o.name,i)))throw new l("duplicate");return f(e,e.folders.map((o,s)=>s===t?{...o,name:i}:o))}function ma(e,n,r){let t=u(e,n),i=e.folders[t],o=oi(e.folders.map((s)=>s.id),n,r);return f(e,o.map((s)=>s===n?i:e.folders.find((a)=>a.id===s)))}function ga(e,n){return u(e,n),f(e,e.folders.filter((r)=>r.id!==n))}var d=(e,n)=>({pins:e.pins.filter((r)=>r!==n),folders:e.folders.map((r)=>r.rooms.includes(n)?{...r,rooms:r.rooms.filter((t)=>t!==n)}:r)});function Oa(e,n,r,t){if(r!==null)u(e,r);let i=d(e,n);if(r===null)return i;return f(i,i.folders.map((o)=>o.id===r?{...o,rooms:oi(o.rooms,n,t)}:o))}function ya(e,n,r,t){let i=d(e,n);if(!r)return i;return{pins:oi(e.pins.filter((o)=>o!==n),n,t),folders:i.folders}}
2
- export{ha,oi,tt,Io,pa,ma,ga,Oa,ya};
@@ -1,2 +0,0 @@
1
- import{Le,O}from"./chunk-index-s356ybxk.js";import{lt}from"./chunk-index-6ycrvwzs.js";var zo=()=>{let{pins:t,folders:o}=O.getState();return{pins:t,folders:o}};function Nn(){let t=O.getState();return lt(t,(o)=>Le(t,o))}
2
- export{zo,Nn};
@@ -1,2 +0,0 @@
1
- var sn=Math.PI*2,An=8;function $n(n){let t=((n+Math.PI)%sn+sn)%sn-Math.PI;return t===-Math.PI?Math.PI:t}var ii=(n,t)=>$n(t-n);function Mr(n){let t=Math.min(Math.max(n,0),8);return{count:1+t,seated:t}}var y=0.62,E=(n)=>Math.min(sn/Math.max(n,1),y),an=(n,t)=>n===0?0:$n(Math.PI+(n-t/2)*E(t)),Dt=(n)=>Math.max(4.2,2.6/(2*Math.sin(E(n)/2)));function z(n,t){let o=0,e=Number.POSITIVE_INFINITY;for(let r=0;r<t;r+=1){let u=Math.abs(ii(n,an(r,t)));if(u<e-0.000000001)e=u,o=r}return o}var _o=(n,t)=>an(z(n,t),t);function Ys(n,t){if(t.seated===0)return;let o=$n(n+Math.PI),e,r=Number.POSITIVE_INFINITY;for(let u=1;u<=t.seated;u+=1){let s=Math.abs(ii(o,an(u,t.count)));if(s<r-0.000000001)r=s,e=u}return e}var x=1.65,R=1.06,T=44,N=390,v=4.8,p=0.07,d=3;function H(n,t,o){let{position:e,target:r}=To(n),u=S([r[0]-e[0],r[1]-e[1],r[2]-e[2]]),s=S(P(u,[0,1,0])),i=P(s,u),m=[o[0]-e[0],o[1]-e[1],o[2]-e[2]],a=h(m,u),c=Math.tan(Po(n.fov,t)*Math.PI/360),l=a>0.000001?a:Number.NaN;return{x:h(m,s)/(l*c*t),y:h(m,i)/(l*c),depth:a}}var h=(n,t)=>n[0]*t[0]+n[1]*t[1]+n[2]*t[2],P=(n,t)=>[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]],S=(n)=>{let t=Math.hypot(n[0],n[1],n[2])||1;return[n[0]/t,n[1]/t,n[2]/t]};function Y(n){let t=Dt(n),o=[];for(let e=1;e<n;e+=1){let r=an(e,n),u=Math.cos(r),s=-Math.sin(r);for(let i of[-1,1])for(let m of[0,v])o.push([Math.sin(r)*t+u*i*x,m,Math.cos(r)*t+s*i*x])}return o}function A(n,t,o,e=p,r=e){let u=1-r,s=1-e;return o.every((i)=>{let m=H(n,t,i);return Math.abs(m.x)<=u&&Math.abs(m.y)<=s})}var bt=2.9,D=0.7,X=0.2,w=0.8;function Hs(n,t,o){let e=o[0]-n[0],r=o[2]-n[2],u=Math.hypot(e,r)||1,s=r/u,i=-e/u,m=bt*D/2,a=bt*t,c=n[1]+a/2-a*X,l=n[1]+a/2-a*w,M=[];for(let f of[-1,1])for(let k of[c,l])M.push([n[0]+s*f*m,k,n[2]+i*f*m]);return M}function O(n){let t=Dt(n),o=[];for(let e=1;e<n;e+=1){let r=an(e,n);o.push([Math.sin(r)*t,R,Math.cos(r)*t])}return o}function g(n,t){return{...n,r:n.lookR+(n.r-n.lookR)*t,y:n.lookY+(n.y-n.lookY)*t}}function ri(n,t,o=1.6,e=N){let r=Dt(t),u={az:n,r:r+4.4,y:4.4+r*0.1,aim:0,lookR:-1.6,lookY:2.5,roll:0,fov:46};if(!(o>0))return u;let s=Y(t),i=O(t),m=p+T/(Math.max(e,1)/2);for(let a=1;a<=d;a+=0.02){let c=g(u,a);if(A(c,o,s)&&A(c,o,i,p,m))return c}return g(u,d)}function js(n,t){let o=Dt(t),e=0.18;return{az:$n(n+0.18),r:Math.max(o-3.9,0.5),y:1.8,aim:-0.18,lookR:o+0.1,lookY:1.7,roll:-0.16,fov:58}}var b=(n,t,o)=>n+(t-n)*o;function Ks(n,t,o){return{az:$n(n.az+ii(n.az,t.az)*o),r:b(n.r,t.r,o),y:b(n.y,t.y,o),aim:b(n.aim,t.aim,o),lookR:b(n.lookR,t.lookR,o),lookY:b(n.lookY,t.lookY,o),roll:b(n.roll,t.roll,o),fov:b(n.fov,t.fov,o)}}var Vi=(n)=>{let t=Math.min(1,Math.max(0,n));return t<0.5?4*t*t*t:1-(-2*t+2)**3/2},Js=(n)=>{let t=Math.min(1,Math.max(0,n)),o=(u,s,i)=>3*(1-u)*(1-u)*u*s+3*(1-u)*u*u*i+u*u*u,e=0,r=1;for(let u=0;u<24;u++){let s=(e+r)/2;if(o(s,0.7,0.84)<t)e=s;else r=s}return o((e+r)/2,0,0)},F=420,I=450,V=650;function ea(n,t,o,e=!1){if(o)return{ms:0,cut:!0};if(e)return{ms:F,cut:!1,dive:!0};let r=Math.abs(ii(n.az,t.az))/Math.PI;return{ms:Math.round(I+(V-I)*r),cut:!1}}function To(n){let t=n.az+n.aim;return{position:[Math.sin(n.az)*n.r,n.y,Math.cos(n.az)*n.r],target:[Math.sin(t)*n.lookR,n.lookY,Math.cos(t)*n.lookR]}}function ta(n,t){let o=an(n,t),e=Dt(t);return{x:Math.sin(o)*e,z:Math.cos(o)*e,yaw:o+Math.PI}}var na=(n,t)=>-n/Math.max(t,1)*(Math.PI/2),ia=(n)=>n<0?-1:1,_=32;function ra(n,t,o,e){let r=(u,s,i)=>u-s<_||i-u<_;return r(n,0,e.width)||r(t,0,e.height)||r(n,o.left,o.left+o.width)||r(t,o.top,o.top+o.height)}function oa(n,t){if(Math.abs(n)<0.000001)return"none";if(n<0)return t?"none":"in";return t?"out":"none"}function Po(n,t){if(!(t>0)||t>=1.2)return n;return Math.min(n*(1+(1.2-t)*0.55),95)}
2
- export{sn,An,$n,ii,Mr,an,Dt,_o,Ys,bt,Hs,ri,js,Ks,Vi,Js,ea,To,ta,na,ia,ra,oa,Po};
@@ -1,2 +0,0 @@
1
- import{we,X,O,M}from"./chunk-index-s356ybxk.js";var{emit:i,use:s}=M(),o=!1,n;function gn(t){return t.cardOrder.flatMap((e)=>{let r=t.cards[e];return r&&!r.outcome?[{id:e,card:r}]:[]})}function Qa(){let t=gn(O.getState()),[e]=t;if(t.length===1&&e)lr(e.id);else if(t.length>1)o=!0,i()}function ar(){if(!o)return;o=!1,i()}var Gr=()=>s(()=>o);function lr(t){let e=O.getState().cards[t];if(!e)return;o=!1,n=t,i(),X("room",e.room)}var Zr=()=>s(()=>n);function Wr(t){if(n!==t)return;n=void 0,i()}var Ti=(t,e)=>[...t?.querySelectorAll("[data-card]")??[]].find((r)=>r.dataset.card===e),c=1600;function cr(t,e){let r=Ti(t,e);if(!r)return!1;r.scrollIntoView?.({block:"center",behavior:we()?"auto":"smooth"});let a=r.querySelector(".prompt")??r;return a.tabIndex=-1,a.focus({preventScroll:!0}),r.dataset.lit="",setTimeout(()=>delete r.dataset.lit,c),!0}
2
- export{gn,Qa,ar,Gr,lr,Zr,Wr,Ti,cr};
@@ -1,2 +0,0 @@
1
- import{M}from"./chunk-index-s356ybxk.js";var o=!1,{emit:e,use:i}=M(),_i=()=>i(()=>o);function qr(t){if(o===t)return;o=t,e()}
2
- export{_i,qr};
@@ -1,120 +0,0 @@
1
- import{p,T,v,Te,s,Pe,R,Fn,a,r,t,c,g,e,n,o,we,X,u,M,bn,Zn,ot,_,je,ys,xn,$t,Re,at,Hn,Sn,Oe,_e,Ts,Tn,he,Xt,et,Ve,Qs,gr,Or,yr,Qn,Be,Xe,Mn,_r,Tr}from"./chunk-index-s356ybxk.js";import{He}from"./chunk-index-5fyqxh0r.js";import{me}from"./chunk-index-qq86fxda.js";import{An}from"./chunk-index-nncy9wxw.js";import{C}from"./chunk-index-e8535c4h.js";import{Y}from"./chunk-index-d941ae7c.js";var Me=(i)=>`roundtable-console:council-mode:${i}`,qe=(i)=>`rt-table-mode:${i}`,ze="roundtable-console:table-mode",ke=new Map,{emit:Ln,use:Nn}=M(),Ce=(i)=>i==="scene"||i==="chat"?i:void 0;function be(i){try{return globalThis.localStorage?.getItem(i)??void 0}catch{return}}function Ee(i,d){try{if(d===void 0)globalThis.localStorage?.removeItem(i);else globalThis.localStorage?.setItem(i,d)}catch{}}function On(i){let d=be(qe(i)),m=d==="1"?"scene":d==="0"?"chat":void 0,h=m??Ce(be(ze))??"scene";if(m!==void 0||Ce(be(ze)))Ee(Me(i),h),Ee(qe(i),void 0);return h}function Vn(i){let d=ke.get(i);if(d!==void 0)return d;let m=Ce(be(Me(i)))??On(i);return ke.set(i,m),m}function Pn(i,d){ke.set(i,d),Ee(Me(i),d),Ln()}function We(i){return[Nn(()=>Vn(i)),(d)=>Pn(i,d)]}var Kn=`
2
- /* The box's fold button says what it does, in words beside its chevron. */
3
- .scene-collapse {
4
- width: auto;
5
- flex: none;
6
- gap: var(--space-1);
7
- padding-inline: var(--space-2);
8
- font-size: var(--text-xs);
9
- }
10
- .scene-collapse span {
11
- white-space: nowrap;
12
- }
13
- /* Folded, the box is one bar: who speaks, the start of their newest line, and the button that opens it. */
14
- .scene-bar {
15
- display: flex;
16
- align-items: center;
17
- gap: var(--space-2);
18
- min-height: var(--touch);
19
- padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2);
20
- cursor: pointer;
21
- }
22
- .scene-bar .scene-chip {
23
- width: 2rem;
24
- height: 2rem;
25
- margin: 0;
26
- border-width: 2px;
27
- flex: none;
28
- }
29
- .scene-bar-name {
30
- flex: 0 1 auto;
31
- min-width: 3ch;
32
- max-width: 35%;
33
- overflow: hidden;
34
- text-overflow: ellipsis;
35
- white-space: nowrap;
36
- }
37
- .scene-bar-preview {
38
- flex: 1 1 0;
39
- min-width: 0;
40
- overflow: hidden;
41
- text-overflow: ellipsis;
42
- white-space: nowrap;
43
- color: var(--muted);
44
- font-size: var(--text-sm);
45
- }
46
- .scene-bar-asking {
47
- flex: none;
48
- padding: 0 var(--space-2);
49
- border-radius: var(--radius-full);
50
- background: color-mix(in srgb, var(--accent) 16%, transparent);
51
- font-size: var(--text-xs);
52
- white-space: nowrap;
53
- }
54
- .scene-composer[hidden] {
55
- display: none;
56
- }
57
-
58
- /* On a phone the tab's tools are narrow, but the fold button keeps its words. */
59
- @media (max-width: 719px) {
60
- .scene-tools .scene-collapse,
61
- .scene-bar .scene-collapse {
62
- width: auto;
63
- min-width: 0;
64
- padding-inline: var(--space-1);
65
- }
66
- }
67
- /* Phones held upright: folded, the box is only its bar and the scene takes the rest. */
68
- @media (max-width: 719px) and (orientation: portrait) {
69
- .table-frame[data-focused][data-folded] {
70
- grid-template-rows: minmax(0, 1fr) auto;
71
- }
72
- }
73
- `,_n=`
74
- /* The header's tools wrap under the title on a narrow screen rather than overflow it. */
75
- .table-tools {
76
- flex-wrap: wrap;
77
- justify-content: flex-end;
78
- }
79
- /* The switch between the scene and the chat: two short choices that sit beside the council chip. */
80
- .table-mode {
81
- flex: none;
82
- margin: 0;
83
- }
84
- .table-mode label {
85
- min-height: 2rem;
86
- padding: 0 var(--space-2);
87
- font-size: var(--text-sm);
88
- white-space: nowrap;
89
- }
90
- /* A council's header: on a phone its tools take a row of their own under the title. */
91
- @media (max-width: 719px) {
92
- .council-head {
93
- flex-wrap: wrap;
94
- }
95
- .council-head .table-tools {
96
- order: 3;
97
- flex-basis: 100%;
98
- min-width: 0;
99
- }
100
- .council-head .council-chip {
101
- flex: 1 1 0;
102
- min-width: 0;
103
- }
104
- }
105
- /* The council's messages as a chat fill the view under its header, like a room's own list. */
106
- .table-chat {
107
- position: relative;
108
- flex: 1;
109
- min-height: 0;
110
- display: flex;
111
- flex-direction: column;
112
- }
113
- `,Ye=()=>Y("dialogue-fold",Kn),Hi=()=>Y("table-page",_n);function Ue(i,d,m,h){if(!i)return;let l=i.pending.at(-1);if(l&&!l.failed)return{id:`p${l.id}`,who:"owner",author:d,text:l.text,files:[],live:!1,pending:!0};if(i.typing&&i.progress.text!==""){let f=i.agent??h;return{id:`s${i.messages.at(-1)?.id??0}`,who:"agent",agent:f,author:m(f),text:i.progress.text,files:[],live:!0,pending:!1}}let b=i.live.at(-1);if(b)return{id:`l${b.live??b.id}`,who:"agent",agent:b.agent,author:b.author,text:b.text,files:b.files,live:!0,pending:!1};for(let f=i.messages.length-1;f>=0;f-=1){let y=i.messages[f];if(!y||y.kind==="system")continue;return Ze(y)}return}function Ze(i){return{id:`m${i.id}`,who:i.kind==="owner"?"owner":"agent",agent:i.agent,author:i.author,text:i.text,files:i.files,live:!1,pending:!1}}var $n=(i,d)=>i.id===d.id||i.who===d.who&&i.agent===d.agent&&i.text!==""&&d.text!==""&&(d.text.startsWith(i.text)||i.text.startsWith(d.text));function Je(){let i=[],d,m=(h)=>{let l=i.length-1,b=i[l];if(b&&$n(b,h))i[l]=h;else i.push(h)};return{get line(){return i[0]},get waiting(){return Math.max(0,i.length-1)},feed(h,l){let b=h.at(-1)?.id??0;if(!d){d=b,i=l?[l]:[];return}if(!l){d=Math.max(d,b),i=[];return}for(let f of h)if(f.id>d&&f.kind!=="system")m(Ze(f));if(d=Math.max(d,b),l&&!l.id.startsWith("m"))m(l)},advance(){if(i.length<2)return!1;return i=i.slice(1),!0}}}function Qe(i,d,m){if(i!==void 0&&m.includes(i))return i;return qn(d,m)}function en(i,d,m){return i.cardOrder.map((l)=>({id:l,card:i.cards[l]})).filter((l)=>l.card?.room===d).filter((l)=>l.card.outcome===void 0||m===void 0||l.card.after>=m)}var Bn=90;function Gn(i,d,m,h={}){if(h.instant)return d;let l=i+m/1000*(h.cps??Bn);return Math.min(d,Math.max(i,l))}function nn(){let i,d="",m=0,h=0;return{get shown(){return Math.floor(h)},get done(){return Math.floor(h)>=m},feed(l,b){if(l!==i){let f=d!==""&&(b.startsWith(d)||d.startsWith(b));if(i=l,!f)h=0}if(d=b,m=Array.from(b).length,h>m)h=m},step(l,b){h=Gn(h,m,l,{instant:b})},finish(){h=m}}}function tn(i,d,m){if(i?.who!=="agent")return;if(i.live&&m!==void 0)return m;return d?i.agent:void 0}function on(i,d=80){let m=i.split(`
114
- `).map((l)=>l.replace(/^\s*(?:#{1,6}\s|>\s?|[-*+]\s|\d+\.\s)+/,"").replace(/[*_`~]/g,"").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim()).find((l)=>l!=="")??"",h=Array.from(m);return h.length>d?`${h.slice(0,d-1).join("")}…`:m}var rn=(i,d)=>Array.from(i).slice(0,d).join("");function qn(i,d){if(!i||i.who!=="agent"||i.agent===void 0)return null;return d.includes(i.agent)?i.agent:null}function sn(i,d,m){return m&&m.lineId===d?m.member:i}var an="roundtable-console:dialogue-folded",Le=new Map,{emit:zn,use:Wn}=M();function jn(i){let d=Le.get(i);if(d!==void 0)return d;try{let m=globalThis.localStorage?.getItem(i)??void 0;if(m!==void 0)Le.set(i,m);return m}catch{return}}function Yn(i,d){Le.set(i,d);try{globalThis.localStorage?.setItem(i,d)}catch{}zn()}var Un=()=>jn(an)==="1";function Xn(i){Yn(an,i?"1":"0")}function ye(){return[Wn(Un),Xn]}var ve={},{emit:Jn,use:nt}=M();function Ne(i,d){if(ve[i]===d)return;let m={...ve};if(d===void 0)delete m[i];else m[i]=d;ve=m,Jn()}var tt=()=>ve;function Se(){return nt(tt)}var rt=24;function cn(i,d,m){let h=a(!0);s(()=>{let l=i.current;if(!l)return;let b=()=>{h.current=l.scrollHeight-l.scrollTop-l.clientHeight<=rt};return l.addEventListener("scroll",b,{passive:!0}),()=>l.removeEventListener("scroll",b)},[i]),Pe(()=>{let l=i.current;if(!d){h.current=!0;return}if(l&&h.current)l.scrollTop=l.scrollHeight},[i,d,m])}var st=["①","②","③","④","⑤","⑥","⑦","⑧"];function dn(i){if(!i)return[];return[...i.spoken.map((d)=>({name:d,place:"spoken"})),...i.current===void 0?[]:[{name:i.current,place:"current"}],...i.next.map((d,m)=>({name:d,place:"next",order:m+1}))]}function ln(i){let d={};if(i?.state!=="running")return d;for(let h of i.spoken)d[h]="✓";let m=new Set;if(i.next.forEach((h,l)=>{let b=st[l];if(b===void 0||m.has(h))return;m.add(h),d[h]=b}),i.current!==void 0)delete d[i.current];return d}var xe=(i)=>i?.state==="running"?i.current:void 0;function un(i){let d=i.current===void 0?i.replies:i.replies+1;return Math.min(Math.max(d,0),i.limit)}function it(i){if(i.ended==="limit")return t("Limit reached");if(i.ended==="stopped")return t("Round stopped");if(i.ended==="done")return t("{count} of {limit} replies",{count:i.replies,limit:i.limit});return t("Reply {n} of {limit}",{n:i.n,limit:i.limit})}var Ae=(i)=>it({...i,n:un(i)});function mn(i){let d=u((f)=>f.rooms[i.roomKey]?.round),m=u((f)=>{let y={};for(let S of Object.values(f.rooms))if(S.view?.kind==="agent")y[S.view.name]=S.view.displayName;return y}),h=Ve();if(!d)return null;let l=dn(d),b=(f)=>m[f]??f;return n("div",{className:"order-strip","data-state":d.state,children:[e("ol",{className:"order-faces","aria-label":t("Speaking order"),children:l.map((f,y)=>n("li",{className:"order-face","data-place":f.place,title:b(f.name),children:[e(he,{spec:h[f.name],name:f.name,size:f.place==="current"?36:26,live:!1}),e("span",{className:"order-badge","aria-hidden":"true",children:f.place==="spoken"?"✓":f.place==="next"?f.order:null}),e("span",{className:"visually-hidden",children:`${b(f.name)}, ${f.place==="spoken"?t("has spoken"):f.place==="current"?t("speaking"):t("next")}`})]},`${f.name}:${y}`))}),e("span",{className:"order-chip","aria-live":"polite",children:Ae(d)}),d.state==="running"&&(d.queued??0)>0?e("span",{className:"order-queued",children:t("Your message waits for the next round")}):null]})}Ye();function ct(i){let d=a(nn()),[,m]=Fn((f)=>f+1,0),h=we();d.current.feed(i?.id??"",i?.text??"");let l=i?.text??"",b=i?.id;return s(()=>{let f=d.current;if(h||l===""||b===void 0){f.finish(),m();return}let y=performance.now(),S=0,x=()=>{let L=performance.now();if(f.step(L-y,!1),y=L,m(),!f.done)S=requestAnimationFrame(x)};if(!f.done)S=requestAnimationFrame(x);return()=>cancelAnimationFrame(S)},[h,b,l]),{shown:d.current.shown,done:d.current.done,finish(){d.current.finish(),m()}}}function De(i){let d=u((y)=>y.rooms[i]),m=u((y)=>y.principal?.name)??t("You"),h=u((y)=>{let S={};for(let x of Object.values(y.rooms))if(x.view?.kind==="agent")S[x.view.name]=x.view.displayName;return S}),l=d?.view,b=(y)=>(y===void 0?void 0:h[y])??y??l?.displayName??i,f=Ue(d,m,b,l?.kind==="agent"?l.name:void 0);return{room:d,view:l,line:f,displayOf:b}}function dt(i){let{loaded:d,error:m}=i,h=u((y)=>y.rooms[i.roomKey]),[l,b]=r(!1),f=a(null);return s(()=>{if(i.open&&d)f.current?.scrollTo({top:f.current.scrollHeight})},[i.open,d]),e(C,{open:i.open,title:`${i.name} · ${t("Log")}`,onClose:i.onClose,children:n("div",{className:"scene-log",ref:f,children:[m?e("p",{className:"failure-text",children:m}):null,h?.more?e("button",{type:"button",className:"secondary older",disabled:l,onClick:async()=>{b(!0),await yr(i.roomKey),b(!1)},children:l?t("Loading…"):t("Load earlier messages")}):null,e(Qn,{roomKey:i.roomKey,enterAfter:void 0,quotable:!0})]})})}function fn(i){let{roomKey:d}=i,m=Xe(),h=_(),l=Or(d),b=i.streams!==!1;s(()=>{if(!b)return;return m.focus(d),()=>m.focus(void 0)},[m,d,b]);let f=u((A)=>A.limits),y=u((A)=>en(A,d,A.rooms[d]?.messages.at(-1)?.id)),S=Ve(),{room:x,view:L,line:V,displayOf:Q}=De(d),z=a(void 0);if(z.current?.room!==d)z.current={room:d,stage:Je()};let{stage:H}=z.current;H.feed(x?.messages??[],V);let{line:E,waiting:P}=H,F=L?.kind==="agent"?L:void 0,I=F?F.name:E?.who==="agent"?E.agent:void 0,te=et(I?S[I]:void 0),G=F?F.displayName:E?E.author:L?.displayName??d,{shown:oe,done:q,finish:B}=ct(E),[,ee]=Fn((A)=>A+1,0);s(()=>{if(q&&P>0&&H.advance())ee()},[q,P,H]);let re=xe(x?.round),se=Boolean(x?.typing&&x.progress.text!==""&&P===0),ae=tn(E,!q,se?re??E?.agent:void 0);s(()=>{Ne(d,ae)},[d,ae]),s(()=>()=>Ne(d,void 0),[d]);let W=a(null);cn(W,!q,oe);let[U,Z]=r(!1),[D,K]=ye(),ce=E?.who==="owner"&&!F?{["--agent-accent"]:"var(--accent)"}:te,ne=Boolean(x?.typing),w=q&&P===0&&E?.who==="agent"&&re!==void 0&&re!==E.agent,k=ne&&(!E||E.who==="owner"||w),N=E?rn(E.text,oe):"",ie=F||E?.who==="agent"?e("span",{className:"scene-chip",children:e(he,{spec:I?S[I]:void 0,name:I??G,size:34,live:!1})}):null,j=y.some(({card:A})=>A.outcome===void 0),de=n("button",{type:"button",className:"icon-button scene-collapse","aria-expanded":!D,onClick:(A)=>{A.stopPropagation(),K(!D)},children:[e(o,{name:"chevron",style:{rotate:D?"-90deg":"90deg"}}),e("span",{children:D?t("Expand dialogue"):t("Collapse dialogue")})]});return n("section",{className:"scene-box","data-open":i.open||void 0,"data-collapsed":D||void 0,"data-who":E?.who,style:ce,"aria-label":t("Log"),children:[D?n("div",{className:"scene-bar",onClick:()=>K(!1),children:[ie,e("strong",{className:"scene-bar-name",children:G}),e("span",{className:"scene-bar-preview",children:E?on(E.text):x?.round?Ae(x.round):""}),j?e("span",{className:"scene-bar-asking",children:t("Waiting for your answer")}):null,de]}):n("header",{className:"scene-tab",children:[ie,e("strong",{className:"scene-name",children:G}),n("span",{className:"scene-tools",children:[i.onBack?e("button",{type:"button",className:"icon-button","aria-label":t("Back to the whole table"),onClick:i.onBack,children:e(o,{name:"back"})}):null,i.onMenu?e("button",{type:"button",className:"icon-button scene-more","aria-label":t("More"),"aria-haspopup":"menu",onClick:(A)=>i.onMenu?.(A.currentTarget),children:e(o,{name:"more"})}):null,n("button",{type:"button",className:"icon-button scene-log-button","aria-label":t("Log"),"aria-haspopup":"dialog",onClick:()=>Z(!0),children:[e(o,{name:"conversations"}),e("span",{children:t("Log")})]}),de]})]}),D?null:i.strip,D?null:n("div",{className:"scene-body",ref:W,children:[e("div",{className:"scene-line","data-live":E?.live||void 0,"aria-live":"polite",...q?{}:{role:"button",tabIndex:0,title:t("Tap to show the whole message"),onClick:B,onKeyDown:(A)=>{if(A.key==="Enter"||A.key===" ")A.preventDefault(),B()}},children:E?n(g,{children:[F&&E.who==="owner"?e("span",{className:"scene-from",children:E.author}):null,e(je,{source:N}),q?e(Xt,{files:E.files}):null]}):null}),k&&x?e(Sn,{name:w?Q(re):G,progress:x.progress}):null,y.map(({id:A,card:O})=>e("div",{className:"scene-card",children:e(gr,{card:O,timeZone:h.timeZone})},A))]}),L?.readOnly?null:e("div",{className:"scene-composer",hidden:D,children:e($t,{draftKey:d,name:L?.displayName??d,limits:f,stoppable:Boolean(x?.stoppable),blurAfterSend:i.blurAfterSend===!0,...L?.kind==="group"?{stopLabel:t("Stop the round")}:{},onSend:(A,O)=>m.say(d,A,O),onStop:()=>m.send({type:"stop",room:d})},d)}),e(dt,{roomKey:d,open:U,loaded:l.loaded,error:l.error,name:L?.displayName??d,onClose:()=>Z(!1)})]})}var lt=8,ut={views:[],attention:{},loaded:!1},pn=ut,{emit:mt,use:ft}=M(),In=()=>ft(()=>pn);function gi(){let i=Te(ot)?.tier;return i!==void 0&&i!=="owner"}function pt(i,d){return{key:i.key,kind:"agent",name:`${d}.${i.id}`,displayName:i.title,home:!1,readOnly:!1,mode:{yolo:!1,longRunning:!1},typing:!1,stoppable:!1}}var gt=(i)=>i.attention===!0,ht=(i,d)=>(d.lastAt??"").localeCompare(i.lastAt??"");async function bt(i){let d=await Promise.allSettled(i.map((l)=>He.list(l))),m=[];d.forEach((l,b)=>{let f=i[b];if(l.status!=="fulfilled"||f===void 0)return;for(let y of l.value.rooms)m.push({room:y,kind:f})}),m.sort((l,b)=>ht(l.room,b.room));let h={};for(let{room:l}of m)if(gt(l))h[l.key]=!0;return{views:m.map(({room:l,kind:b})=>pt(l,b)),attention:h,loaded:!0}}function is(i){let d=Xe(),m=u((x)=>x.connects),h=me((x)=>x.lists),l=a(0),b=a(0),f=i.join(`
115
- `),{views:y}=In();s(()=>{l.current+=1;let x=l.current,L=!0;return bt(f===""?[]:f.split(`
116
- `)).then((V)=>{if(!L||x<b.current)return;b.current=x,pn=V,mt()}),()=>{L=!1}},[f,m,h]);let S=y.slice(0,lt).map((x)=>x.key).join(`
117
- `);s(()=>{let x=S===""?[]:S.split(`
118
- `);for(let L of x)d.send({type:"subscribe",room:L});return()=>{for(let L of x)d.send({type:"unsubscribe",room:L})}},[d,S,m])}var yt=380,vt="cubic-bezier(0.7, 0, 0.84, 0)",wt=2.4,gn=0.35,St=260,xt="cubic-bezier(0.2, 0.8, 0.2, 1)",kt=1.06,Rt=700,J;function hn(i){if(J?.host===i&&J.phase==="diving")J.abort()}var Ct=(i)=>{if(!i||typeof i.animate!=="function")return;i.animate([{transform:`scale(${kt})`,opacity:gn},{transform:"scale(1)",opacity:1}],{duration:St,easing:xt})};function yn(i,d,m,h){if(J)return;let l=i.closest("main.route")??i;if(we()||typeof l.animate!=="function"){m();return}h?.();let b=l.getBoundingClientRect(),f=`${d.x-b.left}px ${d.y-b.top}px`,y={overflow:l.style.overflow,events:l.style.pointerEvents};l.style.overflow="hidden",l.style.pointerEvents="none";let S=l.animate([{transformOrigin:f,transform:"scale(1)",opacity:1},{transformOrigin:f,transform:`scale(${wt})`,opacity:gn}],{duration:yt,easing:vt,fill:"forwards"}),x=document.documentElement,L,V,Q=()=>{l.style.overflow=y.overflow,l.style.pointerEvents=y.events,S.cancel()},z=()=>{window.removeEventListener("popstate",E),window.removeEventListener("hashchange",E)},H={host:i,phase:"diving",abort:E};function E(){if(J!==H||H.phase!=="diving")return;z(),Q(),J=void 0}let P=(F)=>{if(J!==H)return;if(V?.disconnect(),clearTimeout(L),x.removeAttribute("data-dive"),Q(),J=void 0,F)Ct(document.querySelector("main.route"))};J=H,window.addEventListener("popstate",E),window.addEventListener("hashchange",E),S.finished.then(()=>{if(J!==H||H.phase!=="diving")return;if(H.phase="committing",z(),x.setAttribute("data-dive",""),m(),!i.isConnected){P(!0);return}V=new MutationObserver(()=>{if(!i.isConnected)P(!0)}),V.observe(l.parentElement??document.body,{childList:!0,subtree:!0}),L=setTimeout(()=>P(!i.isConnected),Rt)},()=>{return})}var Et=(i)=>i==="sleepy"?"idle":i;function vn(i,d){let m={};for(let[l,b]of Object.entries(i))m[l]=Et(b);let h=(l)=>l!==void 0&&(l in m)&&m[l]!=="waiting"&&m[l]!=="error";for(let l of d){let b=l.agent;if(l.typing&&h(b)){let f=m[b];if(f!=="thinking"&&f!=="working")m[b]="thinking"}}for(let l of d)if(h(l.voice))m[l.voice]="speaking";return m}function Ie(i,d){if(i==="speaking")return"happy";return(d?.STATE_EXPRESSION??Mt)[i]}var Mt={idle:"neutral",thinking:"thinking",working:"determined",waiting:"curious",done:"proud",error:"apologetic",sleepy:"sleepy"};function Ke(i,d){return`s${i}${d.toLowerCase().replace(/[^a-z0-9]/g,"")}`.slice(0,16)}var Tt={x:-7,y:-3,w:114,h:100},ue=256;function Fe(i,d,m,h,l,b,f){let y=i.composeSvg(d,{bare:!0,look:m,expr:Ie(h,i),...f?{mouth:f}:{},state:"idle",still:!0,size:ue,uid:l,skins:b}),{x:S,y:x,w:L,h:V}=Tt;return y.replace('viewBox="0 0 100 100"',`viewBox="${S} ${x} ${L} ${V}"`).replace(`width="${ue}" height="${ue}"`,`width="${ue}" height="${Math.round(ue*V/L)}"`)}function $e(i,d,m,h,l,b){if(h!=="speaking")return{avatarSvg:Fe(i,d,m,h,l,b)};return{avatarSvg:Fe(i,d,m,h,l,b,"closed"),talkSvg:Fe(i,d,m,h,l,b,"open")}}function wn(i){let d=i.delayMs??300,m=i.timers??{set:(f,y)=>setTimeout(f,y),clear:(f)=>clearTimeout(f)},h=new Map,l=new Map,b=(f)=>{let y=l.get(f);if(y===void 0)return;m.clear(y),l.delete(f)};return{seed(f,y){b(f),h.set(f,Ie(y))},update(f,y){let S=Ie(y);if(!h.has(f)){h.set(f,S);return}if(b(f),h.get(f)===S)return;l.set(f,m.set(()=>{l.delete(f),h.set(f,S),i.setAvatar(f,y)},d))},forget(f){b(f),h.delete(f)},dispose(){for(let f of[...l.keys()])b(f);h.clear()}}}var Lt={idle:c("idle"),thinking:c("thinking"),working:c("working"),waiting:c("waiting"),speaking:c("speaking"),done:c("done"),error:c("error")},Nt=()=>({table:t("Round table"),seat:(i,d)=>t("{name} ({state})",{name:i,state:t(Lt[d])})}),At=()=>{Be().catch(()=>{return})};function Oi(i){let d=gi(),{views:m}=In(),h=u((l)=>{let b=l.order.map((y)=>l.rooms[y]?.view).filter((y)=>y!==void 0&&y.kind==="agent"&&!y.helper);return[...i?i.slice(0,An).map((y)=>b.find((S)=>S.name===y)).filter((y)=>y!==void 0):b].sort((y,S)=>Number(S.home)-Number(y.home)).slice(0,An)},i?.join(`
119
- `)??"");return d?m.slice(0,An):h}function yi(){return u((i)=>i.order.map((d)=>i.rooms[d]?.view).filter((d)=>d!==void 0&&d.kind==="agent"&&!d.helper),"agents")}function Ot(i){let d=Se(),m=u((h)=>Object.values(h.rooms).filter((l)=>i?l.key===i:l.view?.kind==="group").map((l)=>{let b=xe(l.round),f=b??l.agent,y=l.typing&&l.progress.text!=="";return{key:l.key,typing:l.typing||b!==void 0,...f===void 0?{}:{agent:f},...y&&f!==void 0?{streamer:f}:{}}}),i??"");return R(()=>m.map(({key:h,streamer:l,...b})=>{let f=d[h]??l;return f===void 0?b:{...b,voice:f}}),[m,d])}function Ht(i){return u((d)=>ln(i?d.rooms[i]?.round:void 0),i??"")}function Dn(i){let{variant:d="full",onHandle:m}=i,h=Zn(),l=at(),b=Hn(),f=Tn(),y=Ve(),S=Oi(i.members),x=Qs(S.map((w)=>w.key)),L=Ot(i.groupRoom),V=Ht(i.groupRoom),Q=In().attention,z=gi(),H=a(z);H.current=z;let E=d==="full"&&i.list===!0,P=R(()=>vn(Object.fromEntries(S.map((w)=>{let k=x[w.key]??"idle";return[w.name,Q[w.key]&&(k==="idle"||k==="sleepy")?"waiting":k]})),L),[S,x,L,Q]),F=a(P);F.current=P;let I=R(()=>{if(!h)return[];return S.map((w,k)=>{let N=y[w.name]??w.character??bn(h,w);return{id:w.name,name:w.displayName,color:h.accentOf(N,b.look),...$e(h,N,b.look,F.current[w.name]??"idle",Ke(k,w.name),f)}})},[h,S,y,b.look,f]),te=a(I);te.current=I;let G=a(S);G.current=S;let oe=a({look:l,scheme:b.scheme});oe.current={look:l,scheme:b.scheme};let q=a(null),B=a(void 0),[ee,re]=r(0),se=a(void 0),ae=a(()=>{return});ae.current=(w)=>{let k=S.find((N)=>N.name===w);if(!h||!k)return;return y[w]??k.character??bn(h,k)};let W=a(b);W.current=b;let U=a(f);U.current=f;let Z=a(h);Z.current=h;let D=a(m);D.current=m;let K=a(i);K.current=i;let ce=h!==void 0&&I.length>0;s(()=>{let w=q.current;if(!ce||!w)return;let k=!0,N,ie=wn({setAvatar:(j,de)=>{let A=ae.current(j),O=Z.current,le=G.current.findIndex((ge)=>ge.name===j);if(!A||!O||le<0)return;let{avatarSvg:fe,talkSvg:pe}=$e(O,A,W.current.look,de,Ke(le,j),U.current);N?.setAvatar(j,fe,pe)}});return se.current=ie,(async()=>{let{mountRoundTable:j}=await (p("mb6jd983"),import("./chunk-entry-mb6jd983.js")),de=te.current.map((O)=>({...O,state:F.current[O.id]??"idle"})),A=await j(w,{theme:oe.current.look,scheme:oe.current.scheme,seats:de,onSeatClick:({id:O,at:le})=>{let fe=K.current.onSeat;if(fe){fe(O);return}let pe=G.current.find((En)=>En.name===O);if(!pe)return;let ge=()=>X("room",pe.key),Ge=q.current;if(le&&Ge)yn(Ge,le,ge,H.current?At:void 0);else ge()},...K.current.onSeatMenu?{onSeatMenu:(O)=>K.current.onSeatMenu?.(O)}:{},ownerName:K.current.ownerName??t("You"),focus:K.current.focus??null,onFocus:(O)=>K.current.onFocus?.(O),reducedMotion:"auto",lowPower:"auto",variant:d,listBelow:E,labels:Nt()});if(!k){A.dispose();return}N=A,B.current=A;for(let O of de)ie.seed(O.id,O.state??"idle");D.current?.(A),re((O)=>O+1)})(),()=>{k=!1,hn(w),ie.dispose(),se.current=void 0,B.current=void 0,D.current?.(void 0),N?.dispose()}},[ce,d,E]);let ne=i.focus??null;if(s(()=>{let w=B.current;if(w&&w.focused()!==ne)w.focus(ne)},[ne,ee]),s(()=>{let w=B.current;if(!w||I.length===0)return;let k=F.current;w.setSeats(I.map((N)=>({...N,state:k[N.id]??"idle"})));for(let N of I)se.current?.seed(N.id,k[N.id]??"idle")},[I,ee]),s(()=>{let w=B.current;if(!w)return;for(let k of te.current)w.setMark(k.id,V[k.id]??null)},[V,I,ee]),s(()=>{let w=B.current;if(w)w.setTheme(l,b.scheme)},[l,b.scheme,ee]),s(()=>{let w=B.current;if(!w)return;for(let k of te.current){let N=P[k.id]??"idle";w.setState(k.id,N),se.current?.update(k.id,N)}},[P,ee]),S.length===0)return e("p",{className:"table-empty",children:t("No knights are seated yet.")});return e("section",{className:"table-host",ref:q,"aria-label":t("Round table")})}function kn(i,d){let{line:m}=De(i),h=Se()[i],[l,b]=r(),f=Qe(h,m,d),y=`${m?.id??""}|${f??""}`;return{focus:sn(f,y,l),look:(L)=>b({lineId:y,member:L})}}function Rn(i){let{roomKey:d,members:m}=i,[h]=ye();return n("div",{className:"table-frame room-scene","data-focused":"","data-folded":h||void 0,children:[e(Dn,{members:m,groupRoom:d,variant:"full",focus:i.focus,onFocus:i.onLook,onSeat:i.onLook,...i.onHandle?{onHandle:i.onHandle}:{},...i.onSeatMenu?{onSeatMenu:i.onSeatMenu}:{}}),e(fn,{roomKey:d,open:!0,streams:i.streams??!1,blurAfterSend:i.blurAfterSend===!0,strip:e(mn,{roomKey:d})})]})}Hi();var Dt=v(()=>(p("7m884s44"),import("./chunk-council-sheet-7m884s44.js")).then((i)=>({default:i.CouncilSheet}))),Vt=v(()=>(p("yk2t0tcy"),import("./chunk-mode-toggle-yk2t0tcy.js")).then((i)=>({default:i.ModeToggle}))),Pt=v(()=>(p("pkd0487m"),import("./chunk-room-menu-pkd0487m.js")).then((i)=>({default:i.RoomMenu})));function Cn(i,d,m,h,l){Ts(i,d).then((b)=>{if(b)Oe({...b,at:m,via:h,source:l})},()=>{return})}function Ft(){let i=Re("(max-width: 719px)"),d=Re("(pointer: coarse)");return i||d}function ji(i){return e("button",{type:"button",className:"secondary council-chip","aria-haspopup":"dialog",onClick:i.onOpen,children:i.council?t("Council: {name} ▾",{name:i.council.displayName}):t("Pick who sits")})}function Ki(i,d){let[m,h]=r(!1),[l,b]=r(!1),f=()=>{h(!0),b(!0)},y=m?e(T,{fallback:null,children:e(Dt,{open:l,onClose:()=>b(!1),council:i,...d?{go:d}:{}})}):null;return{ask:f,sheet:y}}function It(i){let d=(m,h)=>n("label",{"data-checked":i.mode===m,children:[e("input",{type:"radio",name:"table-mode",value:m,checked:i.mode===m,onChange:()=>i.onMode(m)}),h]});return n("fieldset",{className:"segmented table-mode",children:[e("legend",{className:"visually-hidden",children:t("Show the council as")}),d("scene",t("Animation mode")),d("chat",t("Chat mode"))]})}function zr(i){let{roomKey:d}=i,m=Xe(),h=u((w)=>w.rooms[d]),l=u((w)=>w.connection==="open"),b=u((w)=>w.limits),f=at(),y=Ft(),S=h?.view,x=S?.members??[],L=Oi(x),[V,Q]=We(d),[z,H]=r(),{focus:E,look:P}=kn(d,x),{ask:F,sheet:I}=Ki(S,i.go),[te,G]=r(!1),[oe,q]=r(!1),B=a(null),[ee,re]=r(),[se,ae]=r(!1);s(()=>(m.focus(d),()=>m.focus(void 0)),[m,d]);let W=S?.displayName??d,U=h?.mode,Z=L.length>0||i.empty===void 0,D=Z&&V==="scene",K=S?.notes===!0,ce=K&&se,ne=K&&ee===d&&!ce;return n(g,{children:[n("header",{className:"room-head council-head",children:[i.lead,n("div",{className:"table-tools",children:[D&&z?.kind==="webgl"?e("button",{type:"button",className:"icon-button","aria-label":t("Reset view"),title:t("Reset view"),onClick:()=>P(null),children:e(o,{name:"reset"})}):null,Z?e(It,{mode:V,onMode:Q}):null,e(ji,{council:S,onOpen:F})]}),e(Mn,{}),e("button",{ref:B,type:"button",className:"icon-button","aria-label":t("Room menu"),"aria-haspopup":"dialog",onClick:()=>{q(!0),G(!0)},children:e(o,{name:"menu"})})]}),f==="camelot"&&Z&&!D?e("div",{className:"group-strip",onMouseDown:(w)=>w.preventDefault(),children:e(Dn,{members:x,groupRoom:d,variant:"compact",onSeat:(w)=>{let k=L.find((N)=>N.name===w);if(k)ys(d,k.displayName)},onSeatMenu:(w)=>{let k=L.find((N)=>N.name===w.id);if(k)Cn(k.key,d,w.at,w.via,w.source)}})}):null,!l?n("div",{className:"offline-banner",role:"status",children:[e("span",{className:"spinner","aria-hidden":"true"}),t("Reconnecting… messages wait here until it is back.")]}):null,e(_r,{room:d,mode:U&&(U.yolo||U.longRunning)?U:void 0,approved:h?.autoApproved??0}),!Z?e("div",{className:"table-frame",children:i.empty}):D?e(Rn,{roomKey:d,members:x,focus:E,onLook:P,blurAfterSend:y,onHandle:H,onSeatMenu:(w)=>{let k=L.find((N)=>N.name===w.id);if(k)Cn(k.key,d,w.at,w.via,w.source)}}):e("div",{className:"table-chat",children:e(Tr,{roomKey:d,name:W,composer:(w)=>S?.readOnly?null:e($t,{draftKey:d,name:W,onAddressed:ae,...K?{placeholder:ne?t("Write an internal note…"):t("Ask AI…"),above:e(T,{fallback:null,children:e(Vt,{on:!ne,label:t("@AI"),...ce?{locked:t("The message starts with @AI, so the knight answers.")}:{},onChange:(k)=>re(k?void 0:d)})})}:{},limits:b,stoppable:Boolean(h?.stoppable),stopLabel:t("Stop the round"),blurAfterSend:y,onSend:(k,N,ie)=>{if(K&&ie){let j=xn(k);m.say(d,j===""&&N.length===0?k:j,N,"turn")}else m.say(d,k,N,ne?"note":void 0);w(!0)},onStop:()=>m.send({type:"stop",room:d}),...i.incoming&&i.onIncomingTaken?{incoming:i.incoming,onIncomingTaken:i.onIncomingTaken}:{}},d)})}),I,oe?e(T,{fallback:null,children:e(Pt,{open:te,room:d,mode:U,muted:S?.muted===!0,agent:void 0,group:S?.name,coordinator:S?.coordinator===!0,displayName:W,readOnly:S?.readOnly??!1,parent:void 0,onClose:()=>G(!1),onAskYolo:()=>{G(!1),_e({kind:"yolo",room:d,name:W,restoreFocus:()=>B.current})},onAskStartOver:()=>{G(!1),_e({kind:"start-over",room:d,name:W,restoreFocus:()=>B.current})}})}):null]})}
120
- export{Hi,In,gi,is,Oi,yi,Dn,ji,Ki,zr};