@songsid/agend 2.3.2-beta.1 → 2.3.2-beta.11

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 (298) hide show
  1. package/THIRD_PARTY_NOTICES.md +40 -0
  2. package/dist/agent-cli.js +69 -2
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/agent-endpoint.js +11 -0
  5. package/dist/agent-endpoint.js.map +1 -1
  6. package/dist/agent-whats-new.js +3 -0
  7. package/dist/agent-whats-new.js.map +1 -1
  8. package/dist/antigravity-usage-scan.d.ts +58 -0
  9. package/dist/antigravity-usage-scan.js +257 -0
  10. package/dist/antigravity-usage-scan.js.map +1 -0
  11. package/dist/antigravity-usage-worker.d.ts +1 -0
  12. package/dist/antigravity-usage-worker.js +10 -0
  13. package/dist/antigravity-usage-worker.js.map +1 -0
  14. package/dist/auth-api.js +4 -0
  15. package/dist/auth-api.js.map +1 -1
  16. package/dist/backend/kiro-classic-archive.d.ts +52 -0
  17. package/dist/backend/kiro-classic-archive.js +444 -0
  18. package/dist/backend/kiro-classic-archive.js.map +1 -0
  19. package/dist/backend/kiro-identity.d.ts +83 -0
  20. package/dist/backend/kiro-identity.js +144 -0
  21. package/dist/backend/kiro-identity.js.map +1 -1
  22. package/dist/backend/kiro-migration-verify.d.ts +10 -0
  23. package/dist/backend/kiro-migration-verify.js +52 -0
  24. package/dist/backend/kiro-migration-verify.js.map +1 -0
  25. package/dist/backend/kiro-retired-model.d.ts +62 -0
  26. package/dist/backend/kiro-retired-model.js +160 -0
  27. package/dist/backend/kiro-retired-model.js.map +1 -0
  28. package/dist/backend/kiro-v2-store-worker.js +21 -1
  29. package/dist/backend/kiro-v2-store-worker.js.map +1 -1
  30. package/dist/backend/kiro-v2-store.d.ts +8 -0
  31. package/dist/backend/kiro-v2-store.js.map +1 -1
  32. package/dist/backend/kiro.d.ts +169 -2
  33. package/dist/backend/kiro.js +703 -28
  34. package/dist/backend/kiro.js.map +1 -1
  35. package/dist/backend/types.d.ts +108 -0
  36. package/dist/backend/types.js +9 -0
  37. package/dist/backend/types.js.map +1 -1
  38. package/dist/backend-signin-guide.d.ts +1 -0
  39. package/dist/backend-signin-guide.js +9 -0
  40. package/dist/backend-signin-guide.js.map +1 -0
  41. package/dist/backend-signin-pending.d.ts +10 -0
  42. package/dist/backend-signin-pending.js +44 -0
  43. package/dist/backend-signin-pending.js.map +1 -0
  44. package/dist/browser-backend-signins.d.ts +56 -0
  45. package/dist/browser-backend-signins.js +189 -0
  46. package/dist/browser-backend-signins.js.map +1 -0
  47. package/dist/cache-ledger.d.ts +38 -2
  48. package/dist/cache-ledger.js +133 -8
  49. package/dist/cache-ledger.js.map +1 -1
  50. package/dist/cache-prices.d.ts +2 -1
  51. package/dist/cache-prices.js +5 -2
  52. package/dist/cache-prices.js.map +1 -1
  53. package/dist/cache-service.d.ts +68 -0
  54. package/dist/cache-service.js +355 -13
  55. package/dist/cache-service.js.map +1 -1
  56. package/dist/channel/adapters/discord.d.ts +11 -0
  57. package/dist/channel/adapters/discord.js +71 -14
  58. package/dist/channel/adapters/discord.js.map +1 -1
  59. package/dist/channel/ipc-timeouts.js +3 -0
  60. package/dist/channel/ipc-timeouts.js.map +1 -1
  61. package/dist/channel/mcp-tools.js +41 -2
  62. package/dist/channel/mcp-tools.js.map +1 -1
  63. package/dist/channel/tool-router.js +2 -1
  64. package/dist/channel/tool-router.js.map +1 -1
  65. package/dist/classic-channel-manager.d.ts +11 -0
  66. package/dist/classic-channel-manager.js +39 -1
  67. package/dist/classic-channel-manager.js.map +1 -1
  68. package/dist/cli.js +54 -2
  69. package/dist/cli.js.map +1 -1
  70. package/dist/config-validator.d.ts +7 -1
  71. package/dist/config-validator.js +55 -10
  72. package/dist/config-validator.js.map +1 -1
  73. package/dist/config.d.ts +19 -0
  74. package/dist/config.js +33 -1
  75. package/dist/config.js.map +1 -1
  76. package/dist/cpu-quota.d.ts +23 -0
  77. package/dist/cpu-quota.js +86 -0
  78. package/dist/cpu-quota.js.map +1 -0
  79. package/dist/daemon.d.ts +68 -0
  80. package/dist/daemon.js +448 -26
  81. package/dist/daemon.js.map +1 -1
  82. package/dist/dashboard-permissions.d.ts +31 -6
  83. package/dist/dashboard-permissions.js +84 -9
  84. package/dist/dashboard-permissions.js.map +1 -1
  85. package/dist/doctor.js +2 -1
  86. package/dist/doctor.js.map +1 -1
  87. package/dist/fleet-control-audit.d.ts +1 -1
  88. package/dist/fleet-control-audit.js +3 -0
  89. package/dist/fleet-control-audit.js.map +1 -1
  90. package/dist/fleet-manager.d.ts +133 -2
  91. package/dist/fleet-manager.js +905 -94
  92. package/dist/fleet-manager.js.map +1 -1
  93. package/dist/forged-envelope-scan.d.ts +9 -0
  94. package/dist/forged-envelope-scan.js +30 -5
  95. package/dist/forged-envelope-scan.js.map +1 -1
  96. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +5 -2
  97. package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +24 -1
  98. package/dist/general-knowledge/skills/web-appearance/SKILL.canvas-worker-off.md +49 -1
  99. package/dist/general-knowledge/skills/web-appearance/SKILL.md +49 -1
  100. package/dist/general-knowledge/skills/web-dashboard/SKILL.canvas-worker-off.md +47 -9
  101. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +54 -11
  102. package/dist/instance-config-impact.js +10 -5
  103. package/dist/instance-config-impact.js.map +1 -1
  104. package/dist/instance-lifecycle.d.ts +23 -0
  105. package/dist/instance-lifecycle.js +62 -12
  106. package/dist/instance-lifecycle.js.map +1 -1
  107. package/dist/kiro-db-reader.d.ts +5 -0
  108. package/dist/kiro-db-reader.js +18 -0
  109. package/dist/kiro-db-reader.js.map +1 -1
  110. package/dist/kiro-engine-status.d.ts +2 -0
  111. package/dist/kiro-engine-status.js +9 -0
  112. package/dist/kiro-engine-status.js.map +1 -1
  113. package/dist/kiro-migrate.d.ts +60 -0
  114. package/dist/kiro-migrate.js +160 -0
  115. package/dist/kiro-migrate.js.map +1 -0
  116. package/dist/kiro-session-proof.d.ts +41 -0
  117. package/dist/kiro-session-proof.js +89 -0
  118. package/dist/kiro-session-proof.js.map +1 -0
  119. package/dist/kiro-transcript-lane.d.ts +2 -0
  120. package/dist/kiro-transcript-lane.js.map +1 -1
  121. package/dist/kiro-transcript-worker.js +1 -0
  122. package/dist/kiro-transcript-worker.js.map +1 -1
  123. package/dist/kiro-tui-forensic.d.ts +12 -0
  124. package/dist/kiro-tui-forensic.js +110 -0
  125. package/dist/kiro-tui-forensic.js.map +1 -0
  126. package/dist/kiro-usage-run.d.ts +7 -0
  127. package/dist/kiro-usage-run.js +39 -0
  128. package/dist/kiro-usage-run.js.map +1 -0
  129. package/dist/kiro-usage-scan.d.ts +49 -0
  130. package/dist/kiro-usage-scan.js +223 -0
  131. package/dist/kiro-usage-scan.js.map +1 -0
  132. package/dist/kiro-usage-worker.d.ts +1 -0
  133. package/dist/kiro-usage-worker.js +10 -0
  134. package/dist/kiro-usage-worker.js.map +1 -0
  135. package/dist/kiro-usage.d.ts +58 -0
  136. package/dist/kiro-usage.js +310 -0
  137. package/dist/kiro-usage.js.map +1 -0
  138. package/dist/locale.js +230 -8
  139. package/dist/locale.js.map +1 -1
  140. package/dist/log-service.js +1 -1
  141. package/dist/log-service.js.map +1 -1
  142. package/dist/login-url.d.ts +4 -0
  143. package/dist/login-url.js +22 -0
  144. package/dist/login-url.js.map +1 -0
  145. package/dist/needs-you-hub.d.ts +2 -1
  146. package/dist/needs-you-hub.js +1 -1
  147. package/dist/needs-you-hub.js.map +1 -1
  148. package/dist/needs-you.d.ts +10 -2
  149. package/dist/needs-you.js +10 -2
  150. package/dist/needs-you.js.map +1 -1
  151. package/dist/notice-delivery.d.ts +16 -0
  152. package/dist/notice-delivery.js +35 -0
  153. package/dist/notice-delivery.js.map +1 -0
  154. package/dist/office-share-page.d.ts +16 -0
  155. package/dist/office-share-page.js +85 -0
  156. package/dist/office-share-page.js.map +1 -0
  157. package/dist/office-share-service.d.ts +91 -0
  158. package/dist/office-share-service.js +176 -0
  159. package/dist/office-share-service.js.map +1 -0
  160. package/dist/office-share.d.ts +268 -0
  161. package/dist/office-share.js +574 -0
  162. package/dist/office-share.js.map +1 -0
  163. package/dist/opencode-usage-scan.d.ts +28 -0
  164. package/dist/opencode-usage-scan.js +92 -0
  165. package/dist/opencode-usage-scan.js.map +1 -0
  166. package/dist/opencode-usage-worker.d.ts +1 -0
  167. package/dist/opencode-usage-worker.js +10 -0
  168. package/dist/opencode-usage-worker.js.map +1 -0
  169. package/dist/outbound-handlers.js +22 -2
  170. package/dist/outbound-handlers.js.map +1 -1
  171. package/dist/outbound-schemas.d.ts +65 -2
  172. package/dist/outbound-schemas.js +56 -2
  173. package/dist/outbound-schemas.js.map +1 -1
  174. package/dist/public-web-gateway.js +7 -1
  175. package/dist/public-web-gateway.js.map +1 -1
  176. package/dist/quickstart-api.js +13 -2
  177. package/dist/quickstart-api.js.map +1 -1
  178. package/dist/quickstart.js +2 -1
  179. package/dist/quickstart.js.map +1 -1
  180. package/dist/remote-card-answer.d.ts +83 -0
  181. package/dist/remote-card-answer.js +208 -0
  182. package/dist/remote-card-answer.js.map +1 -0
  183. package/dist/remote-card-prompt.d.ts +38 -0
  184. package/dist/remote-card-prompt.js +86 -0
  185. package/dist/remote-card-prompt.js.map +1 -0
  186. package/dist/reply-triggers.d.ts +2 -0
  187. package/dist/reply-triggers.js +3 -0
  188. package/dist/reply-triggers.js.map +1 -0
  189. package/dist/settings-api.d.ts +2 -0
  190. package/dist/settings-api.js +41 -16
  191. package/dist/settings-api.js.map +1 -1
  192. package/dist/settings-change.js +20 -14
  193. package/dist/settings-change.js.map +1 -1
  194. package/dist/settings-effect.js +7 -1
  195. package/dist/settings-effect.js.map +1 -1
  196. package/dist/settings-instance-patch.js +4 -1
  197. package/dist/settings-instance-patch.js.map +1 -1
  198. package/dist/setup-form.d.ts +1 -1
  199. package/dist/setup-form.js +55 -6
  200. package/dist/setup-form.js.map +1 -1
  201. package/dist/setup-host.d.ts +9 -0
  202. package/dist/setup-host.js +127 -6
  203. package/dist/setup-host.js.map +1 -1
  204. package/dist/setup-signin-assets.d.ts +2 -0
  205. package/dist/setup-signin-assets.js +6 -0
  206. package/dist/setup-signin-assets.js.map +1 -0
  207. package/dist/setup-wizard.js +2 -0
  208. package/dist/setup-wizard.js.map +1 -1
  209. package/dist/structured-signin-transport.d.ts +8 -0
  210. package/dist/structured-signin-transport.js +79 -0
  211. package/dist/structured-signin-transport.js.map +1 -0
  212. package/dist/structured-signin.d.ts +131 -0
  213. package/dist/structured-signin.js +388 -0
  214. package/dist/structured-signin.js.map +1 -0
  215. package/dist/tool-permissions.js +29 -0
  216. package/dist/tool-permissions.js.map +1 -1
  217. package/dist/topic-commands.js +6 -2
  218. package/dist/topic-commands.js.map +1 -1
  219. package/dist/transcript-sources.d.ts +27 -2
  220. package/dist/transcript-sources.js +104 -40
  221. package/dist/transcript-sources.js.map +1 -1
  222. package/dist/turn-reply-guard.d.ts +1 -1
  223. package/dist/turn-reply-guard.js +1 -1
  224. package/dist/turn-reply-guard.js.map +1 -1
  225. package/dist/types.d.ts +33 -8
  226. package/dist/ui/backend-signin.js +63 -10
  227. package/dist/ui/chat-store.js +3 -2
  228. package/dist/ui/chat-strings.js +4 -4
  229. package/dist/ui/fleet-office-editor.js +68 -11
  230. package/dist/ui/fleet-office-layout.js +110 -35
  231. package/dist/ui/fleet-office-model.js +6 -3
  232. package/dist/ui/fleet-office-overview.js +167 -0
  233. package/dist/ui/fleet-office-pack.d.ts +13 -3
  234. package/dist/ui/fleet-office-pack.js +214 -24
  235. package/dist/ui/fleet-office-skin.js +98 -23
  236. package/dist/ui/fleet-office-store.js +82 -5
  237. package/dist/ui/fleet-office-view.js +5 -4
  238. package/dist/ui/fleet-office-zones.js +232 -21
  239. package/dist/ui/fleet-office.js +549 -186
  240. package/dist/ui/fleet-usage.js +19 -15
  241. package/dist/ui/office-share-dialog.js +145 -0
  242. package/dist/ui/office-share-page.js +164 -0
  243. package/dist/ui/panel-chat.js +22 -3
  244. package/dist/ui/panel-log.js +4 -4
  245. package/dist/ui/panel-needs.js +5 -5
  246. package/dist/ui/panel-settings.js +38 -12
  247. package/dist/ui/settings-dialogs.js +8 -1
  248. package/dist/ui/settings-guests.js +17 -7
  249. package/dist/ui/settings-model.js +22 -6
  250. package/dist/ui/settings-registry.js +4 -0
  251. package/dist/ui/settings-strings.js +18 -2
  252. package/dist/ui/shared/app-i18n.js +4 -2
  253. package/dist/ui/shared/app-shell.js +14 -6
  254. package/dist/ui/shared/app-stream.js +2 -1
  255. package/dist/ui/shared/app.css +85 -4
  256. package/dist/ui/shared/office/cozy.png +0 -0
  257. package/dist/ui/shared/side-panel.js +95 -0
  258. package/dist/ui/structured-signin.js +115 -0
  259. package/dist/usage-report.d.ts +20 -0
  260. package/dist/usage-report.js +54 -17
  261. package/dist/usage-report.js.map +1 -1
  262. package/dist/usage-rollup.d.ts +9 -1
  263. package/dist/usage-rollup.js +20 -4
  264. package/dist/usage-rollup.js.map +1 -1
  265. package/dist/web-api.d.ts +23 -1
  266. package/dist/web-api.js +292 -3
  267. package/dist/web-api.js.map +1 -1
  268. package/dist/web-auth.js +1 -1
  269. package/dist/web-auth.js.map +1 -1
  270. package/dist/web-backend-login.d.ts +1 -7
  271. package/dist/web-backend-login.js +2 -24
  272. package/dist/web-backend-login.js.map +1 -1
  273. package/dist/web-office-acts.d.ts +173 -0
  274. package/dist/web-office-acts.js +285 -0
  275. package/dist/web-office-acts.js.map +1 -0
  276. package/dist/web-office-pack-read.d.ts +35 -0
  277. package/dist/web-office-pack-read.js +252 -0
  278. package/dist/web-office-pack-read.js.map +1 -0
  279. package/dist/web-office-pack-tools.d.ts +232 -0
  280. package/dist/web-office-pack-tools.js +754 -0
  281. package/dist/web-office-pack-tools.js.map +1 -0
  282. package/dist/web-office-skins.d.ts +71 -6
  283. package/dist/web-office-skins.js +321 -35
  284. package/dist/web-office-skins.js.map +1 -1
  285. package/dist/web-office-store.d.ts +5 -2
  286. package/dist/web-office-store.js +69 -10
  287. package/dist/web-office-store.js.map +1 -1
  288. package/dist/web-settings-patch.d.ts +2 -1
  289. package/dist/web-settings-patch.js +4 -1
  290. package/dist/web-settings-patch.js.map +1 -1
  291. package/dist/working-recovery.d.ts +2 -2
  292. package/dist/working-recovery.js +43 -8
  293. package/dist/working-recovery.js.map +1 -1
  294. package/dist/working-state-journal.d.ts +2 -0
  295. package/dist/working-state-journal.js +16 -1
  296. package/dist/working-state-journal.js.map +1 -1
  297. package/package.json +3 -2
  298. package/templates/windows-shortcuts.ps1 +155 -140
@@ -4,13 +4,23 @@
4
4
  // overridesBetween), saved with the whole list and the rev read (PUT /ui/offices; a change made meanwhile is a 409).
5
5
  // Reset goes back to the pack's own positions. A "show coordinates" overlay draws the 1280×720 logical grid.
6
6
  //
7
+ // #2665: an item with a `night` (#2568) has a night handle too — its night strip drawn faint on the canvas (as the
8
+ // seats' figures, #2558), a moon, and a thin line to its day place. One that sleeps in place shows it on its day place
9
+ // (and it follows the item); dragged away, the item has its own night place; its Reset puts back the pack's.
10
+ //
11
+ // #2691: a selected seat lists the office's members under "Reserved for" (several may be picked) and "Lend when
12
+ // away": whoever it is for takes it first, and nobody else does unless it is lent while they are all elsewhere
13
+ // (fleet-office-zones.js assignSeats). Saved as the overrides' `seatFor` by area and slot; a reserved seat's handle
14
+ // is ringed.
15
+ //
7
16
  // Every handle is a button for the keyboard too: Tab to it, the arrow keys move it (Shift: by 10), Delete removes a
8
17
  // waypoint; the selected waypoint's corridors are listed with a way to join or unjoin each. Never offered to a guest,
9
18
  // the public link or a read-only session (the host refuses their saves too).
10
19
  //
11
20
  // The pure part (handles, moving, adding and removing) is exported for tests; LayoutEditor is the overlay.
12
- import { html, useEffect, useLayoutEffect, useRef, useState } from "/assets/app-html.js";
21
+ import { html, useEffect, useLayoutEffect, useMemo, useRef, useState } from "/assets/app-html.js";
13
22
  import { t, register } from "/assets/app-i18n.js";
23
+ import { SidePanel } from "/assets/side-panel.js";
14
24
  import { LOGICAL, overridesBetween, own } from "./fleet-office-pack.js";
15
25
 
16
26
  register("orgl", {
@@ -18,7 +28,9 @@ register("orgl", {
18
28
  edit: "Edit layout", title: "Edit layout", coords: "Show coordinates", addWaypoint: "Add waypoint", removeWaypoint: "Remove waypoint",
19
29
  joinTo: "Join to", join: "Join", unjoin: "Unjoin {0}", corridors: "Corridors", none: "Nothing selected: pick a seat, an item, the door or a waypoint.",
20
30
  reset: "Reset to the pack's layout", save: "Save layout", cancel: "Cancel", saved: "Layout saved.", hint: "Drag, or use the arrow keys (Shift: by 10).",
21
- seat: "Seat {0} in {1}", furniture: "Item {0}", door: "Door", waypoint: "Waypoint {0}", at: "{0} at {1}, {2}",
31
+ seat: "Seat {0} in {1}", furniture: "Item {0}", night: "Item {0} (night)", door: "Door", waypoint: "Waypoint {0}", at: "{0} at {1}, {2}",
32
+ nightReset: "Back to the pack's night place",
33
+ seatFor: "Seat {0} in {1}, reserved for {2}", reservedFor: "Reserved for", lend: "Lend when away", nobody: "No members to pick.",
22
34
  changed: "Someone changed the offices meanwhile. Your layout is kept: Save again puts it on the current list.",
23
35
  failed: "The layout was not saved ({0}).", rateLimited: "Too many saves. Try again in a minute.",
24
36
  stale: "This office was removed or its style changed meanwhile: this layout can no longer be saved. Cancel closes it.",
@@ -27,7 +39,9 @@ register("orgl", {
27
39
  edit: "編輯配置", title: "編輯配置", coords: "顯示座標", addWaypoint: "新增路徑點", removeWaypoint: "移除路徑點",
28
40
  joinTo: "連到", join: "連接", unjoin: "取消連接 {0}", corridors: "走道", none: "尚未選取:請選座位、家具、門或路徑點。",
29
41
  reset: "還原成 pack 的配置", save: "儲存配置", cancel: "取消", saved: "配置已儲存。", hint: "拖曳,或用方向鍵移動(Shift:一次 10)。",
30
- seat: "{1} 的座位 {0}", furniture: "家具 {0}", door: "門", waypoint: "路徑點 {0}", at: "{0},位置 {1}, {2}",
42
+ seat: "{1} 的座位 {0}", furniture: "家具 {0}", night: "家具 {0}(夜間)", door: "門", waypoint: "路徑點 {0}", at: "{0},位置 {1}, {2}",
43
+ nightReset: "回到 pack 的夜間位置",
44
+ seatFor: "{1} 的座位 {0},保留給 {2}", reservedFor: "保留給", lend: "不在時借給別人", nobody: "沒有可選的成員。",
31
45
  changed: "有人在這期間修改了辦公室。你的配置已保留:再按一次儲存,會套用到目前的清單。",
32
46
  failed: "配置沒有儲存({0})。", rateLimited: "儲存太頻繁,請一分鐘後再試。",
33
47
  stale: "這個辦公室在這期間被移除,或它的風格已改變:這份配置無法再儲存。按取消關閉。",
@@ -38,11 +52,24 @@ const tl = (k, ...v) => t(`orgl.${k}`, ...v);
38
52
  // ── The pure part ──
39
53
 
40
54
  const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, Math.round(v)));
41
- /** Every handle on a pack: { key, kind, label, x, y } — seats by area, furniture, the door, the waypoints. */
55
+ /** An item's night place (#2665): its own, or (in place) its day place; `own` whether it has one. */
56
+ const nightAt = (f) => (f.night.x !== null && f.night.x !== undefined && f.night.y !== null && f.night.y !== undefined ? { x: f.night.x, y: f.night.y, own: true } : { x: f.x, y: f.y, own: false });
57
+ /**
58
+ * Every handle on a pack: { key, kind, label, x, y } — seats by area (#2691: `for` and `lend` when reserved),
59
+ * furniture, each item's night place (#2665: an item with a `night`; `day` its day place, `inPlace` while it sleeps
60
+ * there), the door, the waypoints.
61
+ */
42
62
  export function handlesOf(pack) {
43
63
  const out = [];
44
- for (const [name, a] of Object.entries(pack.areas)) a.seats.forEach((s, i) => out.push({ key: `seat:${name}:${i}`, kind: "seat", label: tl("seat", i + 1, name), x: s.x, y: s.y }));
64
+ for (const [name, a] of Object.entries(pack.areas)) a.seats.forEach((s, i) => out.push({ key: `seat:${name}:${i}`, kind: "seat",
65
+ label: s.for && s.for.length ? tl("seatFor", i + 1, name, s.for.join(", ")) : tl("seat", i + 1, name), x: s.x, y: s.y,
66
+ ...(s.for && s.for.length ? { for: [...s.for], lend: s.lend === true } : {}) }));
45
67
  for (const f of pack.furniture) out.push({ key: `furn:${f.id}`, kind: "furniture", label: tl("furniture", f.id), x: f.x, y: f.y });
68
+ for (const f of pack.furniture) {
69
+ if (!f.night) continue;
70
+ const n = nightAt(f);
71
+ out.push({ key: `night:${f.id}`, kind: "night", label: tl("night", f.id), x: n.x, y: n.y, day: { x: f.x, y: f.y }, inPlace: !n.own });
72
+ }
46
73
  out.push({ key: "door", kind: "door", label: tl("door"), x: pack.door.x, y: pack.door.y });
47
74
  for (const w of pack.waypoints) out.push({ key: `wp:${w.id}`, kind: "waypoint", label: tl("waypoint", w.id), x: w.x, y: w.y });
48
75
  return out;
@@ -55,9 +82,10 @@ export function moveHandle(pack, key, x, y) {
55
82
  const area = own(pack.areas, a), i = Number(b);
56
83
  if (!area || !area.seats[i]) return pack;
57
84
  const r = area.rect, p = { x: clamp(x, Math.ceil(r.x), Math.floor(r.x + r.w)), y: clamp(y, Math.ceil(r.y), Math.floor(r.y + r.h)) };
58
- return { ...pack, areas: { ...pack.areas, [a]: { ...area, seats: area.seats.map((s, j) => (j === i ? p : s)) } } };
85
+ return { ...pack, areas: { ...pack.areas, [a]: { ...area, seats: area.seats.map((s, j) => (j === i ? { ...s, ...p } : s)) } } };
59
86
  }
60
87
  if (kind === "furn") return { ...pack, furniture: pack.furniture.map((f) => (f.id === a ? { ...f, ...inCanvas() } : f)) };
88
+ if (kind === "night") return { ...pack, furniture: pack.furniture.map((f) => (f.id === a && f.night ? { ...f, night: { ...f.night, ...inCanvas() } } : f)) };
61
89
  if (kind === "door") return { ...pack, door: inCanvas() };
62
90
  if (kind === "wp") return { ...pack, waypoints: pack.waypoints.map((w) => (w.id === a ? { ...w, ...inCanvas() } : w)) };
63
91
  return pack;
@@ -80,12 +108,35 @@ export function toggleEdge(pack, a, b) {
80
108
  const has = (e) => (e[0] === a && e[1] === b) || (e[0] === b && e[1] === a);
81
109
  return { ...pack, edges: pack.edges.some(has) ? pack.edges.filter((e) => !has(e)) : [...pack.edges, [a, b]] };
82
110
  }
111
+ /** #2665: item `id`'s night place back to the pack's (`base`): its own x/y, or in place again. */
112
+ export function resetNight(pack, base, id) {
113
+ const o = base.furniture.find((f) => f.id === id);
114
+ if (!o || !o.night) return pack;
115
+ return { ...pack, furniture: pack.furniture.map((f) => (f.id === id && f.night ? { ...f, night: { ...f.night, x: o.night.x, y: o.night.y } } : f)) };
116
+ }
117
+ /**
118
+ * #2691: seat `key` ("seat:<area>:<i>") reserved for `names` (in that order, none twice), lent while they are all
119
+ * elsewhere when `lend`; no names: a plain seat again.
120
+ */
121
+ export function reserveSeat(pack, key, names, lend = false) {
122
+ const [kind, a, b] = key.split(":");
123
+ const area = kind === "seat" ? own(pack.areas, a) : null, i = Number(b);
124
+ if (!area || !area.seats[i]) return pack;
125
+ const list = [...new Set(names)];
126
+ const seat = (s) => { const { for: _f, lend: _l, ...p } = s; return list.length ? { ...p, for: list, lend: lend === true } : p; };
127
+ return { ...pack, areas: { ...pack.areas, [a]: { ...area, seats: area.seats.map((s, j) => (j === i ? seat(s) : s)) } } };
128
+ }
83
129
  /** What Save keeps: the overrides between the pack and the edited layout (null: the pack's own). */
84
130
  export const layoutOverrides = (base, edited) => overridesBetween(base, edited);
85
131
 
86
132
  // ── The overlay ──
87
133
 
88
134
  const GRID = 80, LABEL = 160;
135
+ /**
136
+ * A night handle's moon (#2665): a crescent centred near (x, y). Night handles are drawn under the others: one in place
137
+ * is a wider ring round its item's square (the item stays grabbable), its moon at the ring's corner.
138
+ */
139
+ const moonPath = (x, y) => `M ${x + 1} ${y - 5} A 5 5 0 1 0 ${x + 1} ${y + 5} A 4 4 0 1 1 ${x + 1} ${y - 5} Z`;
89
140
  const KEY_STEP = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] };
90
141
 
91
142
  /**
@@ -94,9 +145,10 @@ const KEY_STEP = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], Arr
94
145
  * zoomed; the page sets its box through the CSSOM, never a style attribute: #1300) — a pointer is read back through
95
146
  * the overlay's own box, so a drag lands on the logical point under it at any zoom; `onChange(edited)` as anything
96
147
  * moves (the canvas redraws it); `onSave(overrides | null)` → { ok } or { ok: false, message }; `onClose()`. `stale` (a message): the
97
- * office or its style changed underneath the session — no handles, nothing to save, only Cancel.
148
+ * office or its style changed underneath the session — no handles, nothing to save, only Cancel. `members` (#2691):
149
+ * the office's instances' names, offered under a selected seat's "Reserved for".
98
150
  */
99
- export function LayoutEditor({ base, start, place = null, stale = "", onChange, onSave, onClose }) {
151
+ export function LayoutEditor({ base, start, place = null, stale = "", dock = true, members = [], onChange, onSave, onClose }) {
100
152
  const [edited, setEdited] = useState(start);
101
153
  const [sel, setSel] = useState(null);
102
154
  const [coords, setCoords] = useState(true);
@@ -130,6 +182,14 @@ export function LayoutEditor({ base, start, place = null, stale = "", onChange,
130
182
  };
131
183
  const add = () => { const at = selected ? { x: selected.x + 40, y: selected.y } : { x: LOGICAL.w / 2, y: LOGICAL.h / 2 }; const r = addWaypoint(edited, at.x, at.y); change(r.pack); setSel(`wp:${r.id}`); };
132
184
  const wpSel = selected && selected.kind === "waypoint" ? selected.key.slice(3) : null;
185
+ const nightSel = selected && selected.kind === "night" ? selected.key.slice(6) : null;
186
+ const seatSel = selected && selected.kind === "seat" ? selected : null;
187
+ // #2691: the members to pick from, and anyone the seat is already for who is not one now (so they can be unpicked).
188
+ const pickable = seatSel ? [...new Set([...members, ...(seatSel.for || [])])] : [];
189
+ const pickFor = (name) => {
190
+ const now = seatSel.for || [], next = now.includes(name) ? now.filter((n) => n !== name) : [...now, name];
191
+ change(reserveSeat(edited, seatSel.key, next, next.length ? seatSel.lend === true : false));
192
+ };
133
193
  const save = async () => {
134
194
  if (busy) return;
135
195
  setBusy(true); setMsg("");
@@ -149,49 +209,64 @@ export function LayoutEditor({ base, start, place = null, stale = "", onChange,
149
209
  }
150
210
  const at = new Map(edited.waypoints.map((w) => [w.id, w]));
151
211
  const edgeKey = (e) => `${e[0]}\u0000${e[1]}`;
212
+ // #2585: the controls dock in the side panel on a wide desk (the canvas left whole for the handles), else they are
213
+ // the bar over the canvas as before. Esc (in the panel, or on the canvas's handles) is Cancel, never mid-save.
214
+ const esc = (e) => { if (e.key === "Escape" && !e.defaultPrevented && !busy) { e.preventDefault(); onClose(); } };
215
+ const dirty = useMemo(() => JSON.stringify(edited) !== JSON.stringify(start), [edited, start]);
216
+ const panel = (controls, actions, tail) => html`<${SidePanel} title=${tl("title")} dock=${dock} busy=${busy} dirty=${dirty} onClose=${onClose} actions=${actions}
217
+ fallback=${html`<div class="ol-bar">${controls}<span class="ol-actions">${actions}</span>${tail}</div>`}>
218
+ <div class="ol-side">${controls}${tail}</div>
219
+ </${SidePanel}>`;
152
220
  if (stale) {
153
- return html`<div class="ol" role="group" aria-label=${tl("title")}><div class="ol-bar">
154
- <p class="note ol-msg ol-stale" role="status">${stale}</p>
155
- <span class="ol-actions"><button type="button" class="btn btn-sm ol-cancel" onClick=${onClose} disabled=${busy}>${tl("cancel")}</button></span>
156
- </div></div>`;
221
+ return html`<div class="ol" role="group" aria-label=${tl("title")} onKeyDown=${esc}>
222
+ ${panel(null, html`<button type="button" class="btn btn-sm ol-cancel" onClick=${onClose} disabled=${busy}>${tl("cancel")}</button>`,
223
+ html`<p class="note ol-msg ol-stale" role="status">${stale}</p>`)}
224
+ </div>`;
157
225
  }
158
- return html`<div class="ol" role="group" aria-label=${tl("title")}>
226
+ const controls = html`<label class="check"><input type="checkbox" class="ol-coords" checked=${coords} onChange=${() => setCoords((v) => !v)} /><span>${tl("coords")}</span></label>
227
+ <button type="button" class="btn btn-sm ol-add" onClick=${add} disabled=${busy}>${tl("addWaypoint")}</button>
228
+ <span class="muted ol-sel" aria-live="polite">${selected ? tl("at", selected.label, selected.x, selected.y) : tl("none")}</span>
229
+ ${seatSel ? html`<fieldset class="ol-for"><legend class="oo-pick-label">${tl("reservedFor")}</legend>
230
+ ${pickable.length ? pickable.map((n) => html`<label key=${n} class="check"><input type="checkbox" class="ol-for-pick" value=${n} checked=${(seatSel.for || []).includes(n)}
231
+ disabled=${busy} onChange=${() => pickFor(n)} /><span>${n}</span></label>`) : html`<span class="muted">${tl("nobody")}</span>`}
232
+ </fieldset>
233
+ <label class="check"><input type="checkbox" class="ol-lend" checked=${seatSel.lend === true} disabled=${busy || !(seatSel.for || []).length}
234
+ onChange=${() => change(reserveSeat(edited, seatSel.key, seatSel.for || [], !(seatSel.lend === true)))} /><span>${tl("lend")}</span></label>` : null}
235
+ ${nightSel ? html`<button type="button" class="btn btn-sm ol-night-reset" onClick=${() => change(resetNight(edited, base, nightSel))} disabled=${busy}>${tl("nightReset")}</button>` : null}
236
+ ${wpSel ? html`<button type="button" class="btn btn-sm btn-danger ol-remove" onClick=${() => { change(removeWaypoint(edited, wpSel)); setSel(null); }} disabled=${busy}>${tl("removeWaypoint")}</button>
237
+ <label class="oo-pick"><span class="oo-pick-label">${tl("joinTo")}</span>
238
+ <select class="tb-select ol-join-to" value=${joinTo} onChange=${(e) => setJoinTo(e.target.value)}>
239
+ <option value="">—</option>
240
+ ${edited.waypoints.filter((w) => w.id !== wpSel).map((w) => html`<option key=${w.id} value=${w.id}>${w.id}</option>`)}
241
+ </select></label>
242
+ <button type="button" class="btn btn-sm ol-join" disabled=${busy || !joinTo || joinTo === wpSel} onClick=${() => { change(toggleEdge(edited, wpSel, joinTo)); setJoinTo(""); }}>${tl("join")}</button>
243
+ <span class="ol-corridors">${edited.edges.filter((e) => e[0] === wpSel || e[1] === wpSel).map((e) => { const other = e[0] === wpSel ? e[1] : e[0];
244
+ return html`<button key=${edgeKey(e)} type="button" class="btn btn-sm ol-unjoin" data-other=${other} disabled=${busy} onClick=${() => change(toggleEdge(edited, wpSel, other))}>${tl("unjoin", other)}</button>`; })}</span>` : null}`;
245
+ const actions = html`<button type="button" class="btn btn-sm ol-reset" onClick=${reset} disabled=${busy}>${tl("reset")}</button>
246
+ <button type="button" class="btn btn-sm ol-cancel" onClick=${onClose} disabled=${busy}>${tl("cancel")}</button>
247
+ <button type="button" class="btn btn-sm btn-primary ol-save" onClick=${save} disabled=${busy}>${tl("save")}</button>`;
248
+ const tail = html`<span class="muted oo-note">${tl("hint")}</span>
249
+ ${msg ? html`<p class="note ol-msg" role="status">${msg}</p>` : null}`;
250
+ return html`<div class="ol" role="group" aria-label=${tl("title")} onKeyDown=${esc}>
159
251
  <div class="ol-overlay" ref=${overlay}>
160
252
  <svg ref=${svg} class="ol-svg" viewBox=${`0 0 ${LOGICAL.w} ${LOGICAL.h}`} width="100%" height="100%"
161
253
  onPointerMove=${move} onPointerUp=${up} onPointerCancel=${up} onPointerLeave=${up}>
162
254
  ${grid}
163
255
  ${Object.values(edited.areas).map((a) => html`<rect key=${`a:${a.name}`} class="ol-area" x=${a.rect.x} y=${a.rect.y} width=${a.rect.w} height=${a.rect.h} />`)}
164
256
  ${edited.edges.map((e) => { const p = at.get(e[0]), q = at.get(e[1]); return p && q ? html`<line key=${`e:${edgeKey(e)}`} class="ol-edge" x1=${p.x} y1=${p.y} x2=${q.x} y2=${q.y} />` : null; })}
165
- ${handles.map((h) => html`<g key=${h.key} class=${`ol-handle ol-${h.kind}${sel === h.key ? " on" : ""}`} data-handle=${h.key} tabindex="0" role="button"
257
+ ${handles.filter((h) => h.kind === "night" && !h.inPlace).map((h) => html`<line key=${`nl:${h.key}`} class="ol-night-line" x1=${h.day.x} y1=${h.day.y} x2=${h.x} y2=${h.y} />`)}
258
+ ${[...handles.filter((h) => h.kind === "night"), ...handles.filter((h) => h.kind !== "night")].map((h) => html`<g key=${h.key} class=${`ol-handle ol-${h.kind}${h.for ? " reserved" : ""}${sel === h.key ? " on" : ""}`} data-handle=${h.key} tabindex="0" role="button"
166
259
  aria-label=${tl("at", h.label, h.x, h.y)} aria-pressed=${sel === h.key ? "true" : "false"}
167
260
  onPointerDown=${down(h.key)} onKeyDown=${keyOn(h)} onFocus=${() => setSel(h.key)}>
168
261
  ${h.kind === "door" ? html`<rect x=${h.x - 9} y=${h.y - 9} width="18" height="18" transform=${`rotate(45 ${h.x} ${h.y})`} />`
169
262
  : h.kind === "furniture" ? html`<rect x=${h.x - 8} y=${h.y - 8} width="16" height="16" />`
263
+ : h.kind === "night" ? html`<circle cx=${h.x} cy=${h.y} r=${h.inPlace ? 15 : 8} /><path class="ol-moon" d=${h.inPlace ? moonPath(h.x + 10, h.y - 10) : moonPath(h.x, h.y)} />`
264
+ : h.kind === "seat" && h.for ? html`<circle class="ol-for-ring" cx=${h.x} cy=${h.y} r="13" /><circle cx=${h.x} cy=${h.y} r="9" />`
170
265
  : html`<circle cx=${h.x} cy=${h.y} r=${h.kind === "seat" ? 9 : 7} />`}
171
266
  ${coords && sel === h.key ? html`<text class="ol-coord" x=${h.x + 12} y=${h.y - 10}>${h.x}, ${h.y}</text>` : null}
172
267
  </g>`)}
173
268
  </svg>
174
269
  </div>
175
- <div class="ol-bar">
176
- <label class="check"><input type="checkbox" class="ol-coords" checked=${coords} onChange=${() => setCoords((v) => !v)} /><span>${tl("coords")}</span></label>
177
- <button type="button" class="btn btn-sm ol-add" onClick=${add} disabled=${busy}>${tl("addWaypoint")}</button>
178
- <span class="muted ol-sel" aria-live="polite">${selected ? tl("at", selected.label, selected.x, selected.y) : tl("none")}</span>
179
- ${wpSel ? html`<button type="button" class="btn btn-sm btn-danger ol-remove" onClick=${() => { change(removeWaypoint(edited, wpSel)); setSel(null); }} disabled=${busy}>${tl("removeWaypoint")}</button>
180
- <label class="oo-pick"><span class="oo-pick-label">${tl("joinTo")}</span>
181
- <select class="tb-select ol-join-to" value=${joinTo} onChange=${(e) => setJoinTo(e.target.value)}>
182
- <option value="">—</option>
183
- ${edited.waypoints.filter((w) => w.id !== wpSel).map((w) => html`<option key=${w.id} value=${w.id}>${w.id}</option>`)}
184
- </select></label>
185
- <button type="button" class="btn btn-sm ol-join" disabled=${busy || !joinTo || joinTo === wpSel} onClick=${() => { change(toggleEdge(edited, wpSel, joinTo)); setJoinTo(""); }}>${tl("join")}</button>
186
- <span class="ol-corridors">${edited.edges.filter((e) => e[0] === wpSel || e[1] === wpSel).map((e) => { const other = e[0] === wpSel ? e[1] : e[0];
187
- return html`<button key=${edgeKey(e)} type="button" class="btn btn-sm ol-unjoin" data-other=${other} disabled=${busy} onClick=${() => change(toggleEdge(edited, wpSel, other))}>${tl("unjoin", other)}</button>`; })}</span>` : null}
188
- <span class="ol-actions">
189
- <button type="button" class="btn btn-sm ol-reset" onClick=${reset} disabled=${busy}>${tl("reset")}</button>
190
- <button type="button" class="btn btn-sm ol-cancel" onClick=${onClose} disabled=${busy}>${tl("cancel")}</button>
191
- <button type="button" class="btn btn-sm btn-primary ol-save" onClick=${save} disabled=${busy}>${tl("save")}</button>
192
- </span>
193
- <span class="muted oo-note">${tl("hint")}</span>
194
- ${msg ? html`<p class="note ol-msg" role="status">${msg}</p>` : null}
195
- </div>
270
+ ${panel(controls, actions, tail)}
196
271
  </div>`;
197
272
  }
@@ -199,7 +199,9 @@ export function autoLayout(rooms, { width = 960 } = {}) {
199
199
  }
200
200
  });
201
201
  const right = out.length ? Math.max(...out.map((r) => r.x + r.w)) : 0, bottom = out.length ? Math.max(...out.map((r) => r.y + r.h)) : 0;
202
- return { rooms: out, waypoints, edges, width: Math.max(width, right + M), height: bottom + GAP / 2 + M };
202
+ // As wide as its rooms (rows wrap at `width`): a scene narrower than the stage is centred in it (clampPan), never
203
+ // left at the stage's left edge with the rest of the stage empty (#2585 B).
204
+ return { rooms: out, waypoints, edges, width: out.length ? right + M : width, height: bottom + GAP / 2 + M };
203
205
  }
204
206
 
205
207
  /**
@@ -318,7 +320,8 @@ const MAX_SEEN = 2000;
318
320
  * The items in the air. `sync(items, now, still)` takes fleet-traffic.js's store items: each new one (a message, a
319
321
  * delegation's work, its report coming back) starts one trip from its sender's desk to its receiver's; a delegation with
320
322
  * no report (stale) and anything seen before start none; `still` (reduced motion) starts none. `frame(now, L)` the
321
- * trips under way on layout L: { id, hue, kind, x, y, t }, finished ones dropped; a trip whose desks are not drawn goes.
323
+ * trips under way on layout L: { id, hue, kind, from, x, y, t } (from: who sent it — a pack can draw it as theirs),
324
+ * finished ones dropped; a trip whose desks are not drawn goes.
322
325
  */
323
326
  export function createFlights({ max = FLIGHT.MAX } = {}) {
324
327
  const seen = new Set();
@@ -344,7 +347,7 @@ export function createFlights({ max = FLIGHT.MAX } = {}) {
344
347
  if (!f.pts) return false;
345
348
  const t = (now - f.start) / f.ms;
346
349
  if (t >= 1) return false;
347
- if (t >= 0) { const p = along(f.pts, t); out.push({ id: f.id, hue: f.hue, kind: f.kind, x: p.x, y: p.y, t }); }
350
+ if (t >= 0) { const p = along(f.pts, t); out.push({ id: f.id, hue: f.hue, kind: f.kind, from: f.from, x: p.x, y: p.y, t }); }
348
351
  return true;
349
352
  });
350
353
  return out;
@@ -0,0 +1,167 @@
1
+ // #2554: the Office view's "All offices" — every stored office as a tile on one canvas, side by side, each drawn exactly
2
+ // as its own view would be (its style, its members, seats, poses, bubbles, walking), scaled into its tile. This module
3
+ // is the pure part (fleet-office.js draws it): who is in no office (the lobby tile), where the tiles go, what a point
4
+ // on the overview hits, which tiles are on screen, and the traffic that crosses between tiles.
5
+ //
6
+ // - Shown when at least two offices are stored (overviewOk); an id no stored office can have (ALL_ID: '*' is not an
7
+ // office id's character), kept per device as any office pick is.
8
+ // - The tiles: each as large as its office's drawn content — a zones scene its 1280×720, a desks office its rooms'
9
+ // bounds (cropToRooms: an office of three is small) — scaled down to at most CELL_W × CELL_H, never up; a LABEL band
10
+ // above each (the page's label sits there), GAP apart, M from the edge. Shelf packing in the stored order (the lobby
11
+ // last): a row takes tiles while they fit a row width, each row as tall as its tallest tile and centred across. The
12
+ // row width: whichever (of the widths a run of tiles makes) lets the whole overview show largest in the panel (Fit's
13
+ // contain); a tie keeps the narrower. The same input always gives the same picture.
14
+ // - Traffic between people in different tiles is a straight flight between their seats in overview coordinates
15
+ // (createCrossFlights); between two people in the same tile it is that tile's own (createFlights, along its corridors).
16
+ import { FLIGHT, along, desksOf, membersOf, pathLength } from "./fleet-office-model.js";
17
+ import { hue } from "./fleet-traffic.js";
18
+
19
+ /** The switcher's "All offices" value: '*' is never in a stored office's id (fleet-office-model.js officeOk). */
20
+ export const ALL_ID = "*all";
21
+ /** The lobby tile's key: never an office's id. */
22
+ export const LOBBY_TILE = "\u0000lobby";
23
+ /** The overview's geometry, in logical units. */
24
+ export const OV = { CELL_W: 1280, CELL_H: 720, LABEL: 56, GAP: 24, M: 24 };
25
+
26
+ /** Whether "All offices" is offered: at least two stored offices. */
27
+ export const overviewOk = (stored) => Array.isArray(stored) && stored.length >= 2;
28
+
29
+ /**
30
+ * The people in no stored office, in the org chart's order (General, the teams, the rest): the lobby tile's. An office
31
+ * with no members holds everyone (fleet-office-model.js membersOf), so then nobody is left for the lobby.
32
+ */
33
+ export function lobbyNodes(stored, view) {
34
+ const placed = new Set((stored || []).flatMap((o) => membersOf(o, view).map((n) => n.name)));
35
+ const out = new Map();
36
+ for (const n of [...view.top, ...view.teams.flatMap((tm) => tm.nodes), ...view.rest.nodes]) if (!placed.has(n.name) && !out.has(n.name)) out.set(n.name, n);
37
+ return [...out.values()];
38
+ }
39
+
40
+ /** A scene's scale in its tile: its own size, scaled down to fit a CELL_W × CELL_H cell (never up). */
41
+ export const tileScale = (w, h) => Math.min(1, OV.CELL_W / Math.max(1, w), OV.CELL_H / Math.max(1, h));
42
+
43
+ /**
44
+ * A desks layout cropped to its rooms: everything moved so the rooms' bounds start at (0, 0), its size theirs (the
45
+ * corridors outside the rooms and the margins are not part of a tile). Unchanged when it has no rooms.
46
+ */
47
+ export function cropToRooms(L) {
48
+ if (!L.rooms.length) return L;
49
+ const x0 = Math.min(...L.rooms.map((r) => r.x)), y0 = Math.min(...L.rooms.map((r) => r.y));
50
+ const x1 = Math.max(...L.rooms.map((r) => r.x + r.w)), y1 = Math.max(...L.rooms.map((r) => r.y + r.h));
51
+ const mv = (p) => ({ ...p, x: p.x - x0, y: p.y - y0 });
52
+ return { ...L, rooms: L.rooms.map((r) => ({ ...mv(r), desks: r.desks.map((d) => ({ ...mv(d), seat: mv(d.seat) })) })), waypoints: (L.waypoints || []).map(mv),
53
+ width: x1 - x0, height: y1 - y0 };
54
+ }
55
+
56
+ /**
57
+ * The tiles of `scenes` ([{ key, w, h }], in order) on shelves at most `rowW` wide (a tile wider than that has a row of
58
+ * its own): each { key, x, y, w, h, s (its scale), label: { x, y, w, h } (the band above it) }; and the overview's size.
59
+ * Each row is centred across the widest; its tiles stand at its top, under their labels.
60
+ */
61
+ export function arrangeTiles(scenes, rowW) {
62
+ const { LABEL, GAP, M } = OV;
63
+ const rows = [];
64
+ let row = null;
65
+ for (const sc of scenes) {
66
+ const s = tileScale(sc.w, sc.h), it = { key: sc.key, s, w: Math.max(1, sc.w) * s, h: Math.max(1, sc.h) * s };
67
+ if (!row || row.w + GAP + it.w > rowW + 1e-6) { row = { items: [], w: -GAP, h: 0 }; rows.push(row); }
68
+ row.items.push(it); row.w += GAP + it.w; row.h = Math.max(row.h, it.h);
69
+ }
70
+ const inner = rows.length ? Math.max(...rows.map((r) => r.w)) : 0, tiles = [];
71
+ let y = M;
72
+ for (const r of rows) {
73
+ let x = M + (inner - r.w) / 2;
74
+ for (const it of r.items) {
75
+ tiles.push({ key: it.key, x, y: y + LABEL, w: it.w, h: it.h, s: it.s, label: { x, y, w: it.w, h: LABEL } });
76
+ x += it.w + GAP;
77
+ }
78
+ y += LABEL + r.h + GAP;
79
+ }
80
+ return { rows: rows.length, rowW, tiles, width: 2 * M + inner, height: rows.length ? y - GAP + M : 2 * M };
81
+ }
82
+
83
+ /**
84
+ * The tiles packed for a `size` panel: of the row widths a run of consecutive tiles makes, the one whose overview shows
85
+ * largest there (min of the two fits); a tie keeps the narrower.
86
+ */
87
+ export function tileLayout(scenes, size) {
88
+ const ws = scenes.map((sc) => Math.max(1, sc.w) * tileScale(sc.w, sc.h)), cands = new Set();
89
+ for (let i = 0; i < ws.length; i++) { let run = -OV.GAP; for (let j = i; j < ws.length; j++) { run += OV.GAP + ws[j]; cands.add(run); } }
90
+ let best = arrangeTiles(scenes, 0), bestK = -1;
91
+ for (const rowW of [...cands].sort((a, b) => a - b)) {
92
+ const a = arrangeTiles(scenes, rowW), k = Math.min(size.w / a.width, size.h / a.height);
93
+ if (k > bestK + 1e-9) { best = a; bestK = k; }
94
+ }
95
+ return best;
96
+ }
97
+
98
+ /** The tile whose scene holds the overview point (x, y), or null. */
99
+ export const tileAt = (lay, x, y) => lay.tiles.find((t) => x >= t.x && x < t.x + t.w && y >= t.y && y < t.y + t.h) || null;
100
+ /** The tile whose label band holds the overview point, or null. */
101
+ export const labelAt = (lay, x, y) => lay.tiles.find((t) => x >= t.label.x && x < t.label.x + t.label.w && y >= t.label.y && y < t.label.y + t.label.h) || null;
102
+ /** Overview → the tile's own scene units, and back; a box in the scene → the overview. */
103
+ export const inTile = (t, x, y) => ({ x: (x - t.x) / t.s, y: (y - t.y) / t.s });
104
+ export const fromTile = (t, p) => ({ x: t.x + p.x * t.s, y: t.y + p.y * t.s });
105
+ export const tileBox = (t, b) => ({ x: t.x + b.x * t.s, y: t.y + b.y * t.s, w: b.w * t.s, h: b.h * t.s });
106
+ /** The tiles a view ({ k, x, y }) shows any of in a `size` viewport: the rest are not drawn. */
107
+ export function visibleTiles(lay, v, size) {
108
+ return lay.tiles.filter((t) => {
109
+ const x = v.x + t.x * v.k, y = v.y + t.y * v.k;
110
+ return x < size.w && x + t.w * v.k > 0 && y < size.h && y + t.h * v.k > 0;
111
+ });
112
+ }
113
+
114
+ /**
115
+ * A straight flight between two people in different tiles: [the sender's seat, the receiver's] in overview units (the
116
+ * first tile each is in), or null — when either is drawn nowhere, or some tile holds both (that tile carries it along
117
+ * its corridors). `parts`: [{ tile, L }] in the tiles' order.
118
+ */
119
+ export function crossPath(parts, from, to) {
120
+ let a = null, z = null;
121
+ for (const p of parts) {
122
+ const ds = desksOf(p.L), da = ds.find((d) => d.node.name === from), dz = ds.find((d) => d.node.name === to);
123
+ if (da && dz) return null;
124
+ if (da && !a) a = fromTile(p.tile, da.seat);
125
+ if (dz && !z) z = fromTile(p.tile, dz.seat);
126
+ }
127
+ return a && z ? [a, z] : null;
128
+ }
129
+
130
+ const MAX_SEEN = 2000;
131
+ /**
132
+ * The items in the air between tiles — fleet-office-model.js createFlights's lifecycle (each new item once; none for a
133
+ * stale delegation or with reduced motion), on crossPath's straight line: `frame(now, parts)` → { id, hue, kind, from, x, y,
134
+ * t } in overview units; a trip with no crossing (both in one tile, or either gone) is dropped.
135
+ */
136
+ export function createCrossFlights({ max = FLIGHT.MAX } = {}) {
137
+ const seen = new Set();
138
+ let trips = [];
139
+ return {
140
+ sync(items, now, still = false) {
141
+ let k = 0, started = 0;
142
+ for (const it of items || []) {
143
+ if (seen.has(it.id)) continue;
144
+ seen.add(it.id);
145
+ if (seen.size > MAX_SEEN) seen.delete(seen.values().next().value);
146
+ if (still || it.phase === "stale") continue;
147
+ trips.push({ id: it.id, from: it.from, to: it.to, kind: it.kind, hue: hue(it.kind), start: now + k++ * FLIGHT.STAGGER_MS, parts: null, pts: null, ms: 0 });
148
+ started++;
149
+ }
150
+ if (trips.length > max) trips = trips.slice(trips.length - max);
151
+ return started;
152
+ },
153
+ frame(now, parts) {
154
+ const out = [];
155
+ trips = trips.filter((f) => {
156
+ if (f.parts !== parts) { f.parts = parts; f.pts = crossPath(parts, f.from, f.to); f.ms = f.pts ? Math.min(FLIGHT.MAX_MS, Math.max(FLIGHT.MIN_MS, pathLength(f.pts) / FLIGHT.SPEED)) : 0; }
157
+ if (!f.pts) return false;
158
+ const t = (now - f.start) / f.ms;
159
+ if (t >= 1) return false;
160
+ if (t >= 0) { const p = along(f.pts, t); out.push({ id: f.id, hue: f.hue, kind: f.kind, from: f.from, x: p.x, y: p.y, t }); }
161
+ return true;
162
+ });
163
+ return out;
164
+ },
165
+ size: () => trips.length,
166
+ };
167
+ }
@@ -3,8 +3,11 @@
3
3
  /** `dw` × `dh`: its displayed size in logical units (w·scale × h·scale unless the manifest says otherwise). */
4
4
  export interface PackStrip { src: string; frames: number; w: number; h: number; fps: number; ax: number; ay: number; dw: number; dh: number }
5
5
  export interface PackPoint { x: number; y: number }
6
- export interface PackArea { name: string; rect: { x: number; y: number; w: number; h: number }; seats: PackPoint[] }
7
- export interface PackFurniture { id: string; sprite: PackStrip; x: number; y: number; depth: number | "y"; activeWhen: string[] | null; activeSprite: PackStrip | null }
6
+ /** #2691: a seat reserved for `for` (lent while they are all elsewhere when `lend`); a plain seat has neither. */
7
+ export interface PackSeat extends PackPoint { for?: string[]; lend?: boolean }
8
+ export interface PackArea { name: string; rect: { x: number; y: number; w: number; h: number }; seats: PackSeat[] }
9
+ /** `label` (#2574): its name tag, or null. */
10
+ export interface PackFurniture { id: string; sprite: PackStrip; x: number; y: number; depth: number | "y"; activeWhen: string[] | null; activeSprite: PackStrip | null; label: string | null }
8
11
  export interface CheckedPack {
9
12
  format: 1; id: string; scale: number; background?: string; foreground?: string; matte?: string;
10
13
  areas: Record<string, PackArea>; stateZones: Record<string, string> | null; door: PackPoint;
@@ -17,6 +20,10 @@ export interface LayoutOverrides {
17
20
  pack: string;
18
21
  seats?: Record<string, Array<[number, number]>>;
19
22
  furniture?: Record<string, [number, number]>;
23
+ /** #2665: an item's night place (an item with a `night` only). */
24
+ furnitureNight?: Record<string, [number, number]>;
25
+ /** #2691: a seat's reservation by area and slot ("0", "1", …), in place of the pack's; `for: []` is none. */
26
+ seatFor?: Record<string, Record<string, { for: string[]; lend: boolean }>>;
20
27
  door?: [number, number];
21
28
  waypoints?: Array<{ id: string; x: number; y: number }>;
22
29
  edges?: Array<[string, string]>;
@@ -28,12 +35,15 @@ export function own<T = unknown>(o: unknown, k: unknown): T | undefined;
28
35
  export function inherited(k: unknown): boolean;
29
36
  export function matteOk(v: unknown): v is string;
30
37
  export function checkStrip(v: unknown, at?: string, scale?: number): PackStrip;
31
- export function checkSkinPack(x: unknown): { ok: true; pack: CheckedPack } | { ok: false; error: string };
38
+ export function checkSkinPack(x: unknown, opts?: { kept?: boolean }): { ok: true; pack: CheckedPack } | { ok: false; error: string };
32
39
  export function skinPackOk(x: unknown): CheckedPack | null;
33
40
  export function packImages(pack: CheckedPack): string[];
34
41
  export function packStrips(pack: CheckedPack): Array<{ at: string; strip: PackStrip }>;
35
42
  export function checkLayoutOverrides(x: unknown): { ok: true; overrides: LayoutOverrides } | { ok: false; error: string };
36
43
  export function applyOverrides(pack: CheckedPack, ov: LayoutOverrides | null | undefined): { ok: true; pack: CheckedPack } | { ok: false; error: string };
44
+ export function fitNight<T extends LayoutOverrides | null | undefined>(pack: CheckedPack, ov: T): T;
45
+ export function fitSeatFor<T extends LayoutOverrides | null | undefined>(pack: CheckedPack, ov: T): T;
37
46
  export function overridesBetween(pack: CheckedPack, edited: CheckedPack): LayoutOverrides | null;
38
47
  export function poseStrip(set: Record<string, PackStrip> | null | undefined, pose: string, heading?: { dx: number; dy: number } | null): { strip: PackStrip; mirror: boolean } | null;
48
+ export function walkStrip(f: { walk?: Record<string, PackStrip> | null; walking?: boolean; heading?: { dx: number; dy: number } | null } | null | undefined): { strip: PackStrip; mirror: boolean } | null;
39
49
  export function stripBox(st: PackStrip, x: number, y: number, mirror?: boolean): { x: number; y: number; w: number; h: number };