@serene-pub/core-catalog 0.6.0-pr-2 → 0.6.0-pr-5

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 (360) hide show
  1. package/README.md +21 -1
  2. package/components/{sessions → genres/chat}/authors-note/AuthorsNote.svelte +1 -1
  3. package/components/{sessions → genres/chat}/authors-note/AuthorsNoteWidget.svelte +1 -1
  4. package/components/{sessions/world-state/WorldState.svelte → shared/actions/Actions.svelte} +5 -5
  5. package/components/shared/actions/ActionsWidget.svelte +118 -0
  6. package/components/shared/actions/actions.ts +11 -0
  7. package/components/shared/album/Album.svelte +24 -0
  8. package/components/shared/album/AlbumWidget.svelte +163 -0
  9. package/components/shared/album/album.ts +10 -0
  10. package/components/shared/annex/Annex.svelte +24 -0
  11. package/components/shared/annex/AnnexWidget.svelte +151 -0
  12. package/components/shared/annex/annex.ts +10 -0
  13. package/components/shared/attendance/Attendance.svelte +24 -0
  14. package/components/shared/attendance/AttendanceWidget.svelte +136 -0
  15. package/components/shared/attendance/attendance.ts +12 -0
  16. package/components/shared/backdrop/Backdrop.svelte +24 -0
  17. package/components/shared/backdrop/BackdropWidget.svelte +345 -0
  18. package/components/shared/backdrop/backdrop.ts +10 -0
  19. package/components/shared/chronicle/Chronicle.svelte +36 -0
  20. package/components/shared/chronicle/ChronicleWidget.svelte +569 -0
  21. package/components/shared/chronicle/chronicle.ts +11 -0
  22. package/components/{sessions → shared}/lore-entries/LoreEntries.svelte +1 -1
  23. package/components/{sessions → shared}/lore-entries/LoreEntriesWidget.svelte +3 -3
  24. package/components/shared/map-canvas/MapCanvas.svelte +171 -0
  25. package/components/shared/map-canvas/index.ts +390 -0
  26. package/components/{sessions → shared}/messages/MessageComposer.svelte +1 -1
  27. package/components/{sessions → shared}/messages/MessageControls.svelte +42 -0
  28. package/components/{sessions → shared}/messages/MessageStateLedger.svelte +19 -8
  29. package/components/{sessions → shared}/messages/Messages.svelte +1 -1
  30. package/components/{sessions → shared}/messages/MessagesWidget.svelte +126 -40
  31. package/components/{sessions → shared}/messages/NextCharacterBlock.svelte +17 -14
  32. package/components/shared/messages/SceneCueChip.svelte +82 -0
  33. package/components/shared/messages/SceneDivider.svelte +399 -0
  34. package/components/{sessions → shared}/messages/SessionComposer.svelte +33 -9
  35. package/components/shared/messages/SessionContainer.svelte +651 -0
  36. package/components/{sessions → shared}/messages/SessionMessage.svelte +52 -7
  37. package/components/shared/messages/TurnLine.svelte +254 -0
  38. package/components/{sessions → shared}/messages/conversation.svelte.ts +191 -2
  39. package/components/shared/messages/sceneMarks.ts +397 -0
  40. package/components/shared/places/Places.svelte +24 -0
  41. package/components/shared/places/PlacesWidget.svelte +290 -0
  42. package/components/shared/places/places.ts +11 -0
  43. package/components/{sessions → shared}/scene-portraits/ScenePortraits.svelte +1 -1
  44. package/components/shared/scene-portraits/ScenePortraitsWidget.svelte +404 -0
  45. package/components/{sessions → shared}/state/SlotControl.svelte +9 -1
  46. package/components/{sessions → shared}/stats/Stats.svelte +1 -1
  47. package/components/shared/stats/StatsWidget.svelte +350 -0
  48. package/components/{sessions → shared}/stats/stats.ts +3 -2
  49. package/components/shared/turn-order/TurnOrder.svelte +24 -0
  50. package/components/shared/turn-order/TurnOrderWidget.svelte +167 -0
  51. package/components/shared/turn-order/turn-order.ts +11 -0
  52. package/components/{sessions/shared → shared}/widgetRef.svelte.ts +9 -2
  53. package/components/shared/world-state/WorldState.svelte +33 -0
  54. package/components/shared/world-state/world-state.ts +10 -0
  55. package/components/tsconfig.json +2 -2
  56. package/dist/components/actions.js +294 -0
  57. package/dist/components/actions.source.json +1 -0
  58. package/dist/components/album.js +386 -0
  59. package/dist/components/album.source.json +1 -0
  60. package/dist/components/annex.js +457 -0
  61. package/dist/components/annex.source.json +1 -0
  62. package/dist/components/attendance.js +353 -0
  63. package/dist/components/attendance.source.json +1 -0
  64. package/dist/components/authors-note.js +5 -5
  65. package/dist/components/authors-note.source.json +1 -1
  66. package/dist/components/backdrop.js +561 -0
  67. package/dist/components/backdrop.source.json +1 -0
  68. package/dist/components/chronicle.js +1141 -0
  69. package/dist/components/chronicle.source.json +1 -0
  70. package/dist/components/core-ui.json +1 -1
  71. package/dist/components/lore-entries.js +5 -5
  72. package/dist/components/lore-entries.source.json +1 -1
  73. package/dist/components/messages.js +3014 -2489
  74. package/dist/components/messages.source.json +1 -1
  75. package/dist/components/places.js +1133 -0
  76. package/dist/components/places.source.json +1 -0
  77. package/dist/components/scene-portraits.js +514 -345
  78. package/dist/components/scene-portraits.source.json +1 -1
  79. package/dist/components/shared-3K7SOGH7.js +16 -0
  80. package/dist/components/shared-452PIS46.js +156 -0
  81. package/dist/components/shared-GEDAMORM.js +45 -0
  82. package/dist/components/{shared-TCQZXBE3.js → shared-GXTL5G2H.js} +4 -3
  83. package/dist/components/shared-ITSLBJB5.js +478 -0
  84. package/dist/components/shared-NK7QSVMU.js +400 -0
  85. package/dist/components/shared-TDWKI2QV.js +58 -0
  86. package/dist/components/{shared-UAQVMZZK.js → shared-XBPH6USH.js} +586 -18
  87. package/dist/components/{shared-AINANAIA.js → shared-XISPHAKY.js} +502 -98
  88. package/dist/components/stats.js +8 -208
  89. package/dist/components/stats.source.json +1 -1
  90. package/dist/components/turn-order.js +461 -0
  91. package/dist/components/turn-order.source.json +1 -0
  92. package/dist/components/world-state.js +14 -202
  93. package/dist/components/world-state.source.json +1 -1
  94. package/dist/{answerForm.d.ts → factories/answerForm.d.ts} +4 -30
  95. package/dist/{answerForm.js → factories/answerForm.js} +10 -39
  96. package/dist/factories/once.d.ts +7 -0
  97. package/dist/factories/once.js +9 -0
  98. package/dist/{turnOrder.d.ts → factories/turnOrder.d.ts} +0 -22
  99. package/dist/{turnOrder.js → factories/turnOrder.js} +4 -104
  100. package/dist/genres/adventure/advanceTime.d.ts +18 -0
  101. package/dist/genres/adventure/advanceTime.js +24 -0
  102. package/dist/genres/adventure/answer.d.ts +23 -0
  103. package/dist/genres/adventure/answer.js +59 -0
  104. package/dist/genres/adventure/answerForm.d.ts +9 -0
  105. package/dist/genres/adventure/answerForm.js +11 -0
  106. package/dist/genres/adventure/ask.d.ts +73 -0
  107. package/dist/genres/adventure/ask.js +157 -0
  108. package/dist/genres/adventure/create.d.ts +36 -0
  109. package/dist/genres/adventure/create.js +62 -0
  110. package/dist/genres/adventure/illustrateScene.d.ts +7 -0
  111. package/dist/genres/adventure/illustrateScene.js +19 -0
  112. package/dist/genres/adventure/index.d.ts +45 -0
  113. package/dist/genres/adventure/index.js +45 -0
  114. package/dist/genres/adventure/keeperAction.d.ts +43 -0
  115. package/dist/genres/adventure/keeperAction.js +217 -0
  116. package/dist/genres/adventure/look.d.ts +45 -0
  117. package/dist/genres/adventure/look.js +209 -0
  118. package/dist/{adventure.d.ts → genres/adventure/respond.d.ts} +74 -65
  119. package/dist/{adventure.js → genres/adventure/respond.js} +125 -65
  120. package/dist/genres/adventure/rest.d.ts +10 -0
  121. package/dist/genres/adventure/rest.js +16 -0
  122. package/dist/genres/adventure/summarizeScene.d.ts +7 -0
  123. package/dist/genres/adventure/summarizeScene.js +14 -0
  124. package/dist/genres/adventure/turnOrder.d.ts +10 -0
  125. package/dist/genres/adventure/turnOrder.js +27 -0
  126. package/dist/genres/chat/advanceTime.d.ts +7 -0
  127. package/dist/genres/chat/advanceTime.js +17 -0
  128. package/dist/genres/chat/answerForm.d.ts +9 -0
  129. package/dist/genres/chat/answerForm.js +11 -0
  130. package/dist/genres/chat/create.d.ts +7 -0
  131. package/dist/{createChat.js → genres/chat/create.js} +6 -6
  132. package/dist/genres/chat/generateImage.d.ts +7 -0
  133. package/dist/{generateImage.js → genres/chat/generateImage.js} +26 -22
  134. package/dist/genres/chat/illustrateScene.d.ts +8 -0
  135. package/dist/genres/chat/illustrateScene.js +19 -0
  136. package/dist/genres/chat/index.d.ts +18 -0
  137. package/dist/genres/chat/index.js +19 -0
  138. package/dist/{narrate.d.ts → genres/chat/narrate.d.ts} +3 -3
  139. package/dist/{narrate.js → genres/chat/narrate.js} +37 -12
  140. package/dist/{narrateCharacter.d.ts → genres/chat/narrateCharacter.d.ts} +2 -2
  141. package/dist/{narrateCharacter.js → genres/chat/narrateCharacter.js} +39 -17
  142. package/dist/genres/chat/respond.d.ts +25 -0
  143. package/dist/{respond.js → genres/chat/respond.js} +91 -23
  144. package/dist/genres/chat/summarizeScene.d.ts +7 -0
  145. package/dist/genres/chat/summarizeScene.js +14 -0
  146. package/dist/genres/chat/turnOrder.d.ts +9 -0
  147. package/dist/genres/chat/turnOrder.js +28 -0
  148. package/dist/{ui/sessions → genres/chat/ui}/authors-note/index.d.ts +1 -1
  149. package/dist/genres/guide/answerForm.d.ts +9 -0
  150. package/dist/genres/guide/answerForm.js +11 -0
  151. package/dist/genres/guide/create.d.ts +24 -0
  152. package/dist/genres/guide/create.js +58 -0
  153. package/dist/genres/guide/index.d.ts +10 -0
  154. package/dist/genres/guide/index.js +10 -0
  155. package/dist/{guide.d.ts → genres/guide/respond.d.ts} +1 -20
  156. package/dist/{guide.js → genres/guide/respond.js} +32 -61
  157. package/dist/genres/guide/summarizeScene.d.ts +7 -0
  158. package/dist/genres/guide/summarizeScene.js +14 -0
  159. package/dist/genres/guide/turnOrder.d.ts +10 -0
  160. package/dist/genres/guide/turnOrder.js +27 -0
  161. package/dist/genres/index.d.ts +14 -0
  162. package/dist/genres/index.js +41 -0
  163. package/dist/genres/lair/advanceTime.d.ts +7 -0
  164. package/dist/genres/lair/advanceTime.js +17 -0
  165. package/dist/genres/lair/answerForm.d.ts +17 -0
  166. package/dist/genres/lair/answerForm.js +19 -0
  167. package/dist/genres/lair/buildRoom.d.ts +64 -0
  168. package/dist/genres/lair/buildRoom.js +244 -0
  169. package/dist/genres/lair/castellanAction.d.ts +27 -0
  170. package/dist/genres/lair/castellanAction.js +177 -0
  171. package/dist/genres/lair/create.d.ts +28 -0
  172. package/dist/genres/lair/create.js +69 -0
  173. package/dist/genres/lair/fileRoom.d.ts +53 -0
  174. package/dist/genres/lair/fileRoom.js +288 -0
  175. package/dist/genres/lair/index.d.ts +62 -0
  176. package/dist/genres/lair/index.js +63 -0
  177. package/dist/genres/lair/nudge.d.ts +25 -0
  178. package/dist/genres/lair/nudge.js +78 -0
  179. package/dist/{lair.d.ts → genres/lair/respond.d.ts} +46 -59
  180. package/dist/{lair.js → genres/lair/respond.js} +55 -76
  181. package/dist/genres/lair/reveal.d.ts +10 -0
  182. package/dist/genres/lair/reveal.js +18 -0
  183. package/dist/genres/lair/roomAnswer.d.ts +86 -0
  184. package/dist/genres/lair/roomAnswer.js +378 -0
  185. package/dist/genres/lair/summarizeScene.d.ts +39 -0
  186. package/dist/genres/lair/summarizeScene.js +51 -0
  187. package/dist/genres/lair/trap.d.ts +11 -0
  188. package/dist/genres/lair/trap.js +24 -0
  189. package/dist/genres/lair/turnOrder.d.ts +9 -0
  190. package/dist/genres/lair/turnOrder.js +36 -0
  191. package/dist/genres/lair/whisper.d.ts +35 -0
  192. package/dist/genres/lair/whisper.js +90 -0
  193. package/dist/index.d.ts +52 -29
  194. package/dist/index.js +192 -86
  195. package/dist/loadouts.d.ts +37 -0
  196. package/dist/loadouts.js +105 -0
  197. package/dist/{entries.d.ts → registry/entries.d.ts} +1 -1
  198. package/dist/{genres.js → registry/genres.js} +40 -6
  199. package/dist/{ui/sessions → registry}/layouts.d.ts +41 -27
  200. package/dist/{ui/sessions → registry}/layouts.js +90 -49
  201. package/dist/{ui/sessions → registry}/widgets.d.ts +22 -0
  202. package/dist/registry/widgets.js +1294 -0
  203. package/dist/{presets.js → seed/presets.js} +28 -13
  204. package/dist/{prompts.d.ts → seed/prompts.d.ts} +10 -5
  205. package/dist/{prompts.js → seed/prompts.js} +225 -176
  206. package/dist/{annexField.d.ts → shared/annexField.d.ts} +12 -8
  207. package/dist/{annexField.js → shared/annexField.js} +16 -15
  208. package/dist/shared/builtins/branch.d.ts +8 -0
  209. package/dist/shared/builtins/branch.js +13 -0
  210. package/dist/{builtins.d.ts → shared/builtins/builtIn.d.ts} +16 -21
  211. package/dist/{builtins.js → shared/builtins/builtIn.js} +3 -37
  212. package/dist/shared/builtins/delete.d.ts +8 -0
  213. package/dist/shared/builtins/delete.js +13 -0
  214. package/dist/shared/builtins/edit.d.ts +8 -0
  215. package/dist/shared/builtins/edit.js +13 -0
  216. package/dist/shared/builtins/hide.d.ts +8 -0
  217. package/dist/shared/builtins/hide.js +13 -0
  218. package/dist/shared/builtins/index.d.ts +11 -0
  219. package/dist/shared/builtins/index.js +11 -0
  220. package/dist/shared/builtins/swipe.d.ts +8 -0
  221. package/dist/shared/builtins/swipe.js +17 -0
  222. package/dist/shared/describeLikeness.d.ts +14 -0
  223. package/dist/shared/describeLikeness.js +65 -0
  224. package/dist/shared/illustrateScene.d.ts +28 -0
  225. package/dist/shared/illustrateScene.js +181 -0
  226. package/dist/shared/portrait.d.ts +21 -0
  227. package/dist/shared/portrait.js +101 -0
  228. package/dist/shared/spriteFill.d.ts +14 -0
  229. package/dist/shared/spriteFill.js +107 -0
  230. package/dist/shared/sprites.d.ts +34 -0
  231. package/dist/shared/sprites.js +98 -0
  232. package/dist/shared/summarize/character.d.ts +9 -0
  233. package/dist/shared/summarize/character.js +10 -0
  234. package/dist/shared/summarize/history.d.ts +9 -0
  235. package/dist/shared/summarize/history.js +10 -0
  236. package/dist/shared/summarize/index.d.ts +12 -0
  237. package/dist/shared/summarize/index.js +12 -0
  238. package/dist/shared/summarize/scene.d.ts +38 -0
  239. package/dist/shared/summarize/scene.js +42 -0
  240. package/dist/shared/summarize/sceneIds.d.ts +17 -0
  241. package/dist/shared/summarize/sceneIds.js +17 -0
  242. package/dist/shared/summarize/summarizeScene.d.ts +113 -0
  243. package/dist/shared/summarize/summarizeScene.js +234 -0
  244. package/dist/shared/summarize/summarizeSpec.d.ts +54 -0
  245. package/dist/{summarize.js → shared/summarize/summarizeSpec.js} +23 -53
  246. package/dist/shared/summarize/world.d.ts +8 -0
  247. package/dist/shared/summarize/world.js +9 -0
  248. package/dist/shared/timePasses.d.ts +56 -0
  249. package/dist/shared/timePasses.js +86 -0
  250. package/dist/{toolLoop.d.ts → shared/toolLoop.d.ts} +25 -3
  251. package/dist/{toolLoop.js → shared/toolLoop.js} +70 -14
  252. package/dist/shared/ui/actions/index.d.ts +117 -0
  253. package/dist/shared/ui/actions/index.js +154 -0
  254. package/dist/shared/ui/album/index.d.ts +115 -0
  255. package/dist/shared/ui/album/index.js +178 -0
  256. package/dist/shared/ui/annex/index.d.ts +163 -0
  257. package/dist/shared/ui/annex/index.js +273 -0
  258. package/dist/shared/ui/attendance/index.d.ts +97 -0
  259. package/dist/shared/ui/attendance/index.js +89 -0
  260. package/dist/shared/ui/backdrop/index.d.ts +78 -0
  261. package/dist/shared/ui/backdrop/index.js +98 -0
  262. package/dist/shared/ui/chronicle/index.d.ts +230 -0
  263. package/dist/shared/ui/chronicle/index.js +249 -0
  264. package/dist/shared/ui/conversation/dossier.d.ts +33 -0
  265. package/dist/shared/ui/conversation/dossier.js +31 -0
  266. package/dist/{ui/sessions → shared/ui}/conversation/index.d.ts +2 -1
  267. package/dist/{ui/sessions → shared/ui}/conversation/index.js +3 -1
  268. package/dist/{ui/sessions → shared/ui}/conversation/messageVerbState.d.ts +1 -1
  269. package/dist/shared/ui/conversation/storyDays.d.ts +21 -0
  270. package/dist/shared/ui/conversation/storyDays.js +23 -0
  271. package/dist/{ui/sessions → shared/ui}/coreWidgetsEntry.d.ts +1 -1
  272. package/dist/{ui/sessions → shared/ui}/coreWidgetsEntry.js +1 -1
  273. package/dist/{ui/sessions → shared/ui}/lore-entries/index.d.ts +2 -2
  274. package/dist/shared/ui/places/index.d.ts +148 -0
  275. package/dist/shared/ui/places/index.js +249 -0
  276. package/dist/{ui/sessions → shared/ui}/scene-portraits/index.d.ts +1 -1
  277. package/dist/{ui/sessions → shared/ui}/scene-portraits/index.js +1 -1
  278. package/dist/shared/ui/scene-portraits/portraits.d.ts +191 -0
  279. package/dist/shared/ui/scene-portraits/portraits.js +223 -0
  280. package/dist/shared/ui/session-state/index.d.ts +16 -0
  281. package/dist/shared/ui/session-state/index.js +16 -0
  282. package/dist/{ui/sessions → shared/ui}/session-state/shapes.d.ts +2 -2
  283. package/dist/shared/ui/session-state/stateView.d.ts +249 -0
  284. package/dist/shared/ui/session-state/stateView.js +247 -0
  285. package/dist/shared/ui/turn-order/index.d.ts +146 -0
  286. package/dist/shared/ui/turn-order/index.js +257 -0
  287. package/dist/{ui/sessions → shared/ui}/widgetContext.d.ts +19 -10
  288. package/package.json +69 -30
  289. package/components/sessions/messages/SessionContainer.svelte +0 -459
  290. package/components/sessions/scene-portraits/ScenePortraitsWidget.svelte +0 -249
  291. package/components/sessions/stats/StatsWidget.svelte +0 -112
  292. package/components/sessions/world-state/WorldStateWidget.svelte +0 -112
  293. package/components/sessions/world-state/world-state.ts +0 -10
  294. package/dist/adventureActions.d.ts +0 -169
  295. package/dist/adventureActions.js +0 -599
  296. package/dist/createChat.d.ts +0 -7
  297. package/dist/generateImage.d.ts +0 -7
  298. package/dist/lairActions.d.ts +0 -296
  299. package/dist/lairActions.js +0 -1287
  300. package/dist/respond.d.ts +0 -24
  301. package/dist/sprites.d.ts +0 -24
  302. package/dist/sprites.js +0 -102
  303. package/dist/summarize.d.ts +0 -76
  304. package/dist/ui/sessions/conversation/dossier.d.ts +0 -328
  305. package/dist/ui/sessions/conversation/dossier.js +0 -31
  306. package/dist/ui/sessions/scene-portraits/portraits.d.ts +0 -95
  307. package/dist/ui/sessions/scene-portraits/portraits.js +0 -115
  308. package/dist/ui/sessions/session-state/index.d.ts +0 -15
  309. package/dist/ui/sessions/session-state/index.js +0 -15
  310. package/dist/ui/sessions/session-state/stateView.d.ts +0 -155
  311. package/dist/ui/sessions/session-state/stateView.js +0 -141
  312. package/dist/ui/sessions/widgets.js +0 -567
  313. package/components/{sessions → genres/chat}/authors-note/authors-note.ts +0 -0
  314. package/components/{sessions/shared → shared}/context.ts +0 -0
  315. package/components/{sessions → shared}/lore-entries/lore-entries.ts +0 -0
  316. package/components/{sessions → shared}/messages/MessageBlocksView.svelte +0 -0
  317. package/components/{sessions → shared}/messages/MessageMediaStrip.svelte +0 -0
  318. package/components/{sessions → shared}/messages/MessagePartsView.svelte +0 -0
  319. package/components/{sessions → shared}/messages/StateProposalList.svelte +0 -0
  320. package/components/{sessions → shared}/messages/mediaStrip.ts +0 -0
  321. package/components/{sessions → shared}/messages/messages.ts +0 -0
  322. package/components/{sessions → shared}/scene-portraits/StatBars.svelte +0 -0
  323. package/components/{sessions → shared}/scene-portraits/scene-portraits.ts +0 -0
  324. package/components/{sessions → shared}/state/entryFinder.ts +0 -0
  325. package/components/{sessions → shared}/state/slotWriter.svelte.ts +0 -0
  326. package/dist/components/{shared-RJDGOAVC.js → shared-FTRGUE7G.js} +78 -78
  327. /package/dist/{ui/sessions → genres/chat/ui}/authors-note/index.js +0 -0
  328. /package/dist/{entries.js → registry/entries.js} +0 -0
  329. /package/dist/{genres.d.ts → registry/genres.d.ts} +0 -0
  330. /package/dist/{slots.d.ts → registry/slots.d.ts} +0 -0
  331. /package/dist/{slots.js → registry/slots.js} +0 -0
  332. /package/dist/{statShapes.d.ts → registry/statShapes.d.ts} +0 -0
  333. /package/dist/{statShapes.js → registry/statShapes.js} +0 -0
  334. /package/dist/{guideMascotImage.d.ts → seed/guideMascotImage.d.ts} +0 -0
  335. /package/dist/{guideMascotImage.js → seed/guideMascotImage.js} +0 -0
  336. /package/dist/{presets.d.ts → seed/presets.d.ts} +0 -0
  337. /package/dist/{graphBuild.d.ts → shared/graphBuild.d.ts} +0 -0
  338. /package/dist/{graphBuild.js → shared/graphBuild.js} +0 -0
  339. /package/dist/{ui/sessions → shared/ui}/conversation/actionsDisclosure.d.ts +0 -0
  340. /package/dist/{ui/sessions → shared/ui}/conversation/actionsDisclosure.js +0 -0
  341. /package/dist/{ui/sessions → shared/ui}/conversation/composerTray.d.ts +0 -0
  342. /package/dist/{ui/sessions → shared/ui}/conversation/composerTray.js +0 -0
  343. /package/dist/{ui/sessions → shared/ui}/conversation/formAnswer.d.ts +0 -0
  344. /package/dist/{ui/sessions → shared/ui}/conversation/formAnswer.js +0 -0
  345. /package/dist/{ui/sessions → shared/ui}/conversation/itemValues.d.ts +0 -0
  346. /package/dist/{ui/sessions → shared/ui}/conversation/itemValues.js +0 -0
  347. /package/dist/{ui/sessions → shared/ui}/conversation/messageOrder.d.ts +0 -0
  348. /package/dist/{ui/sessions → shared/ui}/conversation/messageOrder.js +0 -0
  349. /package/dist/{ui/sessions → shared/ui}/conversation/messageSpeaker.d.ts +0 -0
  350. /package/dist/{ui/sessions → shared/ui}/conversation/messageSpeaker.js +0 -0
  351. /package/dist/{ui/sessions → shared/ui}/conversation/messageVerbState.js +0 -0
  352. /package/dist/{ui/sessions → shared/ui}/conversation/slashPalette.d.ts +0 -0
  353. /package/dist/{ui/sessions → shared/ui}/conversation/slashPalette.js +0 -0
  354. /package/dist/{ui/sessions → shared/ui}/conversation/text.d.ts +0 -0
  355. /package/dist/{ui/sessions → shared/ui}/conversation/text.js +0 -0
  356. /package/dist/{ui/sessions → shared/ui}/lore-entries/index.js +0 -0
  357. /package/dist/{ui/sessions → shared/ui}/session-state/barMath.d.ts +0 -0
  358. /package/dist/{ui/sessions → shared/ui}/session-state/barMath.js +0 -0
  359. /package/dist/{ui/sessions → shared/ui}/session-state/shapes.js +0 -0
  360. /package/dist/{ui/sessions → shared/ui}/widgetContext.js +0 -0
@@ -0,0 +1,178 @@
1
+ /**
2
+ * `@serene-pub/core-catalog/album` — the plain-TypeScript half of core's
3
+ * Album widget (PLAN-core-widgets W2): its settings, and the one reading it
4
+ * draws — every picture on the session's lines, newest first, each with
5
+ * where it came from and who showed it when. The widget's Svelte source
6
+ * lives in `components/shared/album/` and ships built
7
+ * (`dist/components/album.js`); a host imports only this half, which carries
8
+ * no Svelte runtime.
9
+ *
10
+ * **What it reads** is the log (`messages.v1`): each row's `core:image`
11
+ * parts, the step's shown revision only, in the order the media strip
12
+ * under the line draws them (`mediaStripItems`). A part with no usable
13
+ * `assetId` is no file anyone can fetch and is left out, as the strip
14
+ * leaves it out. A hidden row's pictures are not drawn. A file part
15
+ * (`core:file`) is not a picture and is the strip's alone.
16
+ *
17
+ * **Where a picture came from** is the row's: a person's line (`role:
18
+ * 'user'`) holds what they **attached**; any other line holds what a run
19
+ * **generated** — image generation, or an outlet that attached its bytes.
20
+ * The part itself names no origin today (`mediaPartFor` writes the same
21
+ * part for all three writers). A line's sprite is not a part — the line
22
+ * records its set and label, the picture is the character's — so the album
23
+ * never draws one.
24
+ *
25
+ * ⚠ Not a **gallery** (a character's or persona's own image set), not the
26
+ * **media strip** (one message's files, under its card) and not the
27
+ * **Media** collection (every file a person stored).
28
+ *
29
+ * Every sentence is English source handed through the widget's `t`, so the
30
+ * same words speak the viewer's language natively or in a worker.
31
+ *
32
+ * 🚧 Provisional with the widget.
33
+ */
34
+ import { parseChannel } from '@serene-pub/sdk';
35
+ /** @experimental */
36
+ export const ALBUM_DEFAULTS = Object.freeze({
37
+ source: 'all',
38
+ tile: 'medium',
39
+ arrangement: 'grid',
40
+ channel: '',
41
+ });
42
+ const oneOf = (v, of, fallback) => typeof v === 'string' && of.includes(v) ? v : fallback;
43
+ /** Read one settings payload (`settings.v1`) into the complete object above. @experimental */
44
+ export function readAlbumSettings(raw) {
45
+ const v = raw ?? {};
46
+ return {
47
+ source: oneOf(v.source, ['all', 'attached', 'generated'], ALBUM_DEFAULTS.source),
48
+ tile: oneOf(v.tile, ['small', 'medium', 'large'], ALBUM_DEFAULTS.tile),
49
+ arrangement: oneOf(v.arrangement, ['grid', 'latest'], ALBUM_DEFAULTS.arrangement),
50
+ channel: typeof v.channel === 'string' ? v.channel.trim() : ALBUM_DEFAULTS.channel,
51
+ };
52
+ }
53
+ /** The address of one representation (`/media/{id}`, plus `?v=` for a derived one) — the media strip's. @experimental */
54
+ export function albumSrc(assetId, variant) {
55
+ return variant ? `/media/${assetId}?v=${variant}` : `/media/${assetId}`;
56
+ }
57
+ const text = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
58
+ const count = (v) => typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : null;
59
+ /** A `date` column carries the day only; a time of day needs a timestamp. */
60
+ const DAY_ONLY = /^\d{4}-\d{2}-\d{2}$/;
61
+ /**
62
+ * The clock beside a line's name, as the line draws it (`SessionMessage`):
63
+ * `createdAt` unless it is a day-only date, then `updatedAt`.
64
+ */
65
+ function lineTime(row, locale) {
66
+ const created = row.createdAt;
67
+ const stamp = typeof created === 'string' && DAY_ONLY.test(created)
68
+ ? (row.updatedAt ?? created)
69
+ : (created ?? row.updatedAt);
70
+ if (!stamp)
71
+ return '';
72
+ const at = stamp instanceof Date ? stamp : new Date(stamp);
73
+ if (Number.isNaN(at.getTime()))
74
+ return '';
75
+ try {
76
+ return at.toLocaleTimeString(locale || [], { hour: 'numeric', minute: '2-digit' });
77
+ }
78
+ catch {
79
+ return at.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
80
+ }
81
+ }
82
+ /** A row's pictures, the shown revision of each step, in the strip's order. */
83
+ function imagesOf(row) {
84
+ const parts = Array.isArray(row.parts) ? row.parts : [];
85
+ if (!parts.length)
86
+ return [];
87
+ const active = row.activeRevisions ?? {};
88
+ return parts
89
+ .filter((p) => p?.type === 'core:image' &&
90
+ p.revision === (active[String(p.step)] ?? 0) &&
91
+ count(p.data?.assetId) !== null)
92
+ .sort((a, b) => a.step - b.step || a.ordinal - b.ordinal);
93
+ }
94
+ /** The row's channel slug: `main` when unset, a lane's slug for `slug:n`. */
95
+ const slugOf = (channel) => parseChannel(channel).slug;
96
+ /**
97
+ * The album: every picture on `rows` (the log, in its order) the settings
98
+ * let through, **newest line first**, a line's own pictures in the strip's
99
+ * order. `channel`, set, keeps one channel's lines — its every lane — as a
100
+ * Messages copy's `channel` claims one; empty keeps every channel. `source`
101
+ * keeps the attached or the generated alone.
102
+ * @experimental
103
+ */
104
+ export function albumItems(rows, settings, options = {}) {
105
+ if (!rows?.length)
106
+ return [];
107
+ const t = options.t ?? ((s) => s);
108
+ const claim = settings.channel ? slugOf(settings.channel) : null;
109
+ const out = [];
110
+ for (let i = rows.length - 1; i >= 0; i--) {
111
+ const row = rows[i];
112
+ if (!row || typeof row !== 'object' || row.isHidden)
113
+ continue;
114
+ if (claim !== null && slugOf(row.channel) !== claim)
115
+ continue;
116
+ const origin = row.role === 'user' ? 'attached' : 'generated';
117
+ if (settings.source !== 'all' && settings.source !== origin)
118
+ continue;
119
+ const images = imagesOf(row);
120
+ if (!images.length)
121
+ continue;
122
+ const speaker = text(row.speakerLabel) ?? '';
123
+ const time = lineTime(row, options.locale);
124
+ const caption = [speaker, time].filter(Boolean).join(' · ');
125
+ for (const p of images) {
126
+ const d = (p.data ?? {});
127
+ out.push({
128
+ partId: p.id,
129
+ messageId: row.id,
130
+ assetId: d.assetId,
131
+ label: text(d.alt) ?? text(d.filename) ?? text(d.name) ?? t('Image'),
132
+ origin,
133
+ speaker,
134
+ time,
135
+ caption,
136
+ width: count(d.width),
137
+ height: count(d.height),
138
+ });
139
+ }
140
+ }
141
+ return out;
142
+ }
143
+ /**
144
+ * The `view-image` request for opening picture `index` of `items` (the
145
+ * album as drawn, in display order, less any whose file is gone): the
146
+ * picture itself, full size, and every other as the lightbox's pages,
147
+ * captioned by their names as the media strip captions them.
148
+ * @experimental
149
+ */
150
+ export function albumViewImageParams(items, index) {
151
+ const srcs = items.map((i) => albumSrc(i.assetId));
152
+ return {
153
+ src: srcs[index],
154
+ gallery: { srcs, index, captions: items.map((i) => i.label) },
155
+ };
156
+ }
157
+ /** What the album says when it has nothing to draw, by `source`. @experimental */
158
+ export const ALBUM_EMPTY = Object.freeze({
159
+ all: 'Nothing has been attached or generated in this session yet.',
160
+ attached: 'Nothing has been attached in this session yet.',
161
+ generated: 'Nothing has been generated in this session yet.',
162
+ });
163
+ /** A tile's name for a reader: *Open attached image cat.png, Wren · 9:41 PM, 2 of 7*. @experimental */
164
+ export function albumOpenLabel(item, at, total, t = (s) => s) {
165
+ const head = item.origin === 'attached' ? t('Open attached image') : t('Open generated image');
166
+ const parts = [`${head} ${item.label}`];
167
+ if (item.caption)
168
+ parts.push(item.caption);
169
+ if (total > 1)
170
+ parts.push(`${at + 1} of ${total}`);
171
+ return parts.join(', ');
172
+ }
173
+ /** The origin glyph's words, for its `title`. @experimental */
174
+ export const ALBUM_ORIGIN_NAMES = Object.freeze({
175
+ attached: 'Attached',
176
+ generated: 'Generated',
177
+ });
178
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,163 @@
1
+ /**
2
+ * `@serene-pub/core-catalog/annex` — the plain-TypeScript half of core's
3
+ * Annex widget (PLAN-core-widgets W9): its settings, what it knows of one
4
+ * declared annex field, and the one view it draws — one annex key, by its
5
+ * label, in the shape it was declared in. The widget's Svelte source lives
6
+ * in `components/shared/annex/` and ships built (`dist/components/annex.js`);
7
+ * a host imports only this half, which carries no Svelte runtime.
8
+ *
9
+ * **The key** is `<owner>.<key>`, the way a template reads it
10
+ * (`annex.<owner>.<key>`): `core.retake-quietly`, a plugin's
11
+ * `acme.dice.last-roll`. A field's key is a kebab token with no dot
12
+ * (`ANNEX_FIELD_KEY`), so the last dot splits, whatever the owner's slug.
13
+ *
14
+ * **What it draws** is the viewer's own view of the annex (`annex.v1`) — the
15
+ * values whose `see` audience holds for them, never the annex itself. Text
16
+ * is prose; a number, a switch or a choice is one label/value row; a list is
17
+ * chips; an object is a row per member. The declared shape decides when the
18
+ * widget is handed one; otherwise the stored value's own form does.
19
+ *
20
+ * **What it knows of the field** is what the host lists (`actions.v1`): a
21
+ * field a person may set is one action at the `widget` venue
22
+ * (`<owner>:annex#<key>`), named by the field's label and judged for the
23
+ * viewer (`canAct`) — so the label and *may I edit* are the host's, never
24
+ * worked out here. A field nobody may set reaches no listing, and is titled
25
+ * by its key. ⚠ Neither the declared shape nor the `see` verdict reaches a
26
+ * widget today; `AnnexWidgetField` takes both, for a host that hands them.
27
+ *
28
+ * **Edit** is the Session data list's: a text field the viewer may set,
29
+ * saved by pressing its ready-made action with `{ value }` — the same door,
30
+ * the same write.
31
+ *
32
+ * 🚧 Provisional with the widget.
33
+ */
34
+ import { type ActionsV1, type AnnexV1, type FieldDecl, type I18n, type ViewerV1 } from '@serene-pub/sdk';
35
+ /** A translation: English source in, the viewer's words out. @experimental */
36
+ export type AnnexWidgetT = (source: string) => string;
37
+ /** The widget's settings, complete — the declared defaults wherever an instance has none. @experimental */
38
+ export interface AnnexWidgetSettings {
39
+ /** The annex key it draws, `<owner>.<key>`; `''` until one is picked. */
40
+ key: string;
41
+ /** Draw the field's label above its value. */
42
+ showLabel: boolean;
43
+ }
44
+ /** @experimental */
45
+ export declare const ANNEX_WIDGET_DEFAULTS: AnnexWidgetSettings;
46
+ /** Read one settings payload (`settings.v1`) into the complete object above. @experimental */
47
+ export declare function readAnnexWidgetSettings(raw: Record<string, unknown> | undefined): AnnexWidgetSettings;
48
+ /**
49
+ * `<owner>.<key>` taken apart at its last dot — null for anything that is
50
+ * not one (no dot, an empty owner, a key that is not a kebab token).
51
+ * @experimental
52
+ */
53
+ export declare function parseAnnexWidgetKey(raw: string | undefined): {
54
+ owner: string;
55
+ key: string;
56
+ } | null;
57
+ /**
58
+ * What the widget knows of one declared annex field. Each fact is optional
59
+ * because each has its own source, and the widget draws what it is given:
60
+ * the label and `canAct` come from the host's listing
61
+ * ({@link annexWidgetFieldsFrom}); `shape` and `canSee` from a host that
62
+ * hands the declaration (none does yet).
63
+ * @experimental
64
+ */
65
+ export interface AnnexWidgetField {
66
+ owner: string;
67
+ key: string;
68
+ label?: I18n;
69
+ /** The declared shape — what the value is drawn as. Absent: the value's own form. */
70
+ shape?: FieldDecl;
71
+ /** The host's verdict on the field's `act` audience for this viewer. */
72
+ canAct?: boolean;
73
+ /** The host's verdict on the field's `see` audience for this viewer. */
74
+ canSee?: boolean;
75
+ }
76
+ /**
77
+ * The annex fields the host lists for this viewer: each settable field it may
78
+ * set is one action at the `widget` venue whose spec slug is `<owner>:annex`,
79
+ * its key the field's, its name the field's label. Disabled for this session
80
+ * (`enabled: false`) or not the viewer's to press (`canAct: false`), it is
81
+ * known but not settable.
82
+ * @experimental
83
+ */
84
+ export declare function annexWidgetFieldsFrom(actions: ActionsV1 | undefined): AnnexWidgetField[];
85
+ /** One label/value row. @experimental */
86
+ export interface AnnexWidgetRow {
87
+ /** The member's key — the row's key; the field's own key for a one-row value. */
88
+ key: string;
89
+ label: string;
90
+ text: string;
91
+ }
92
+ /** How the value is drawn. @experimental */
93
+ export type AnnexWidgetDrawn = {
94
+ as: 'prose';
95
+ text: string;
96
+ } | {
97
+ as: 'rows';
98
+ rows: AnnexWidgetRow[];
99
+ } | {
100
+ as: 'chips';
101
+ chips: string[];
102
+ };
103
+ /** The three things the widget says instead of a value. @experimental */
104
+ export type AnnexWidgetEmptyState = 'pick' | 'unwritten' | 'hidden';
105
+ /** Each empty state's line, English source. @experimental */
106
+ export declare const ANNEX_WIDGET_EMPTY: Readonly<Record<AnnexWidgetEmptyState, string>>;
107
+ /** The widget's one view. @experimental */
108
+ export type AnnexWidgetView = {
109
+ state: AnnexWidgetEmptyState;
110
+ /** The field's label, its key without one; *Annex* with no key picked. */
111
+ title: string;
112
+ empty: string;
113
+ /** `<owner>:annex#<key>` — what a Save presses. Null with no key picked. */
114
+ identity: string | null;
115
+ /** May the viewer write the first value here (the Session data list's Edit). */
116
+ canEdit: boolean;
117
+ /** The editor's starting text. */
118
+ draft: string;
119
+ } | {
120
+ state: 'value';
121
+ title: string;
122
+ /** The declared shape's type, else the value's own form (`text`, `integer`, `list`, …). */
123
+ shape: string;
124
+ drawn: AnnexWidgetDrawn;
125
+ value: unknown;
126
+ identity: string;
127
+ canEdit: boolean;
128
+ draft: string;
129
+ };
130
+ /** What `annexWidgetView` reads. @experimental */
131
+ export interface AnnexWidgetInputs {
132
+ /** `annex.v1` — the viewer's view of the annex. */
133
+ annex: AnnexV1 | undefined;
134
+ /** What the widget knows of the declared fields ({@link annexWidgetFieldsFrom}). */
135
+ fields: readonly AnnexWidgetField[];
136
+ /** The `key` setting, `<owner>.<key>`. */
137
+ key: string;
138
+ viewer: ViewerV1 | undefined;
139
+ /** `locale.v1`, for a label's and a member's own words. */
140
+ locale?: string;
141
+ t?: AnnexWidgetT;
142
+ }
143
+ /**
144
+ * Draw one annex key: an empty state, each one line and never silent, or the
145
+ * value in its shape, with the Session data list's Edit where the viewer may
146
+ * set it.
147
+ *
148
+ * - no key, or not `<owner>.<key>` → *Pick a key in settings*, titled *Annex*;
149
+ * - in the viewer's view → the value;
150
+ * - not in it, and the host says the viewer may not see it → *You can't
151
+ * see this*;
152
+ * - otherwise → *Nothing written yet*. ⚠ A key the viewer may not see is
153
+ * absent from their view exactly as an unwritten one is, so without the
154
+ * host's `see` verdict the two read alike.
155
+ *
156
+ * **Edit** needs all three: the host lists the field as the viewer's to set
157
+ * (`canAct`), the viewer holds no guest seat, and the field is text — by its
158
+ * declared shape, else by the stored value's form (the Session data list's
159
+ * rule, `annexEditsAsText`).
160
+ * @experimental
161
+ */
162
+ export declare function annexWidgetView(inputs: AnnexWidgetInputs): AnnexWidgetView;
163
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,273 @@
1
+ /**
2
+ * `@serene-pub/core-catalog/annex` — the plain-TypeScript half of core's
3
+ * Annex widget (PLAN-core-widgets W9): its settings, what it knows of one
4
+ * declared annex field, and the one view it draws — one annex key, by its
5
+ * label, in the shape it was declared in. The widget's Svelte source lives
6
+ * in `components/shared/annex/` and ships built (`dist/components/annex.js`);
7
+ * a host imports only this half, which carries no Svelte runtime.
8
+ *
9
+ * **The key** is `<owner>.<key>`, the way a template reads it
10
+ * (`annex.<owner>.<key>`): `core.retake-quietly`, a plugin's
11
+ * `acme.dice.last-roll`. A field's key is a kebab token with no dot
12
+ * (`ANNEX_FIELD_KEY`), so the last dot splits, whatever the owner's slug.
13
+ *
14
+ * **What it draws** is the viewer's own view of the annex (`annex.v1`) — the
15
+ * values whose `see` audience holds for them, never the annex itself. Text
16
+ * is prose; a number, a switch or a choice is one label/value row; a list is
17
+ * chips; an object is a row per member. The declared shape decides when the
18
+ * widget is handed one; otherwise the stored value's own form does.
19
+ *
20
+ * **What it knows of the field** is what the host lists (`actions.v1`): a
21
+ * field a person may set is one action at the `widget` venue
22
+ * (`<owner>:annex#<key>`), named by the field's label and judged for the
23
+ * viewer (`canAct`) — so the label and *may I edit* are the host's, never
24
+ * worked out here. A field nobody may set reaches no listing, and is titled
25
+ * by its key. ⚠ Neither the declared shape nor the `see` verdict reaches a
26
+ * widget today; `AnnexWidgetField` takes both, for a host that hands them.
27
+ *
28
+ * **Edit** is the Session data list's: a text field the viewer may set,
29
+ * saved by pressing its ready-made action with `{ value }` — the same door,
30
+ * the same write.
31
+ *
32
+ * 🚧 Provisional with the widget.
33
+ */
34
+ import { ANNEX_FIELD_KEY, ANNEX_FIELD_SLUG_SUFFIX, annexFieldAction, i18nText, } from '@serene-pub/sdk';
35
+ /** @experimental */
36
+ export const ANNEX_WIDGET_DEFAULTS = Object.freeze({
37
+ key: '',
38
+ showLabel: false,
39
+ });
40
+ /** Read one settings payload (`settings.v1`) into the complete object above. @experimental */
41
+ export function readAnnexWidgetSettings(raw) {
42
+ const v = raw ?? {};
43
+ return {
44
+ key: typeof v.key === 'string' ? v.key.trim() : ANNEX_WIDGET_DEFAULTS.key,
45
+ showLabel: typeof v.showLabel === 'boolean' ? v.showLabel : ANNEX_WIDGET_DEFAULTS.showLabel,
46
+ };
47
+ }
48
+ /**
49
+ * `<owner>.<key>` taken apart at its last dot — null for anything that is
50
+ * not one (no dot, an empty owner, a key that is not a kebab token).
51
+ * @experimental
52
+ */
53
+ export function parseAnnexWidgetKey(raw) {
54
+ const s = (raw ?? '').trim();
55
+ const at = s.lastIndexOf('.');
56
+ if (at <= 0)
57
+ return null;
58
+ const owner = s.slice(0, at);
59
+ const key = s.slice(at + 1);
60
+ if (!ANNEX_FIELD_KEY.test(key) || owner.includes('#') || /\s/.test(owner))
61
+ return null;
62
+ return { owner, key };
63
+ }
64
+ /**
65
+ * The annex fields the host lists for this viewer: each settable field it may
66
+ * set is one action at the `widget` venue whose spec slug is `<owner>:annex`,
67
+ * its key the field's, its name the field's label. Disabled for this session
68
+ * (`enabled: false`) or not the viewer's to press (`canAct: false`), it is
69
+ * known but not settable.
70
+ * @experimental
71
+ */
72
+ export function annexWidgetFieldsFrom(actions) {
73
+ const out = [];
74
+ const seen = new Set();
75
+ const venue = actions?.widget;
76
+ for (const a of [...(venue?.primary ?? []), ...(venue?.overflow ?? [])]) {
77
+ const slug = a.specSlug ?? '';
78
+ if (!slug.endsWith(ANNEX_FIELD_SLUG_SUFFIX) ||
79
+ slug.length <= ANNEX_FIELD_SLUG_SUFFIX.length)
80
+ continue;
81
+ const owner = slug.slice(0, -ANNEX_FIELD_SLUG_SUFFIX.length);
82
+ const id = `${owner}.${a.key}`;
83
+ if (seen.has(id))
84
+ continue;
85
+ seen.add(id);
86
+ out.push({
87
+ owner,
88
+ key: a.key,
89
+ ...(a.name ? { label: a.name } : {}),
90
+ canAct: !!a.canAct && a.enabled !== false,
91
+ });
92
+ }
93
+ return out;
94
+ }
95
+ /** Each empty state's line, English source. @experimental */
96
+ export const ANNEX_WIDGET_EMPTY = Object.freeze({
97
+ pick: 'Pick a key in settings',
98
+ unwritten: 'Nothing written yet',
99
+ hidden: "You can't see this",
100
+ });
101
+ const humanise = (s) => s
102
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
103
+ .replace(/[_-]+/g, ' ')
104
+ .replace(/^./, (c) => c.toUpperCase());
105
+ /** The value's own form, when no declaration says: what it would be declared as. @internal */
106
+ function typeOfValue(value) {
107
+ if (typeof value === 'string')
108
+ return 'text';
109
+ if (typeof value === 'number')
110
+ return Number.isInteger(value) ? 'integer' : 'number';
111
+ if (typeof value === 'boolean')
112
+ return 'boolean';
113
+ if (Array.isArray(value))
114
+ return 'list';
115
+ if (value && typeof value === 'object')
116
+ return 'object';
117
+ return 'text';
118
+ }
119
+ /** Nothing written: absent, null, blank text, an empty list or object. @internal */
120
+ function isBlank(value) {
121
+ if (value === undefined || value === null)
122
+ return true;
123
+ if (typeof value === 'string')
124
+ return !value.trim();
125
+ if (Array.isArray(value))
126
+ return value.length === 0;
127
+ if (typeof value === 'object')
128
+ return Object.keys(value).length === 0;
129
+ return false;
130
+ }
131
+ /** One scalar in the viewer's words, by its declaration where there is one. @internal */
132
+ function textOf(value, shape, locale, t) {
133
+ if (value === undefined || value === null)
134
+ return '—';
135
+ if (shape?.type === 'enum' && typeof value === 'string') {
136
+ const member = shape.members?.find((m) => m.key === value);
137
+ return i18nText(member?.label, locale) ?? humanise(value);
138
+ }
139
+ if (typeof value === 'boolean')
140
+ return value ? t('Yes') : t('No');
141
+ if (typeof value === 'number') {
142
+ try {
143
+ return new Intl.NumberFormat(locale).format(value);
144
+ }
145
+ catch {
146
+ return String(value);
147
+ }
148
+ }
149
+ if (typeof value === 'string')
150
+ return value;
151
+ if (Array.isArray(value))
152
+ return value.map((v) => textOf(v, shape?.item, locale, t)).join(', ');
153
+ try {
154
+ return JSON.stringify(value);
155
+ }
156
+ catch {
157
+ return String(value);
158
+ }
159
+ }
160
+ /** The value drawn by its shape. @internal */
161
+ function drawnOf(value, type, shape, label, key, locale, t) {
162
+ switch (type) {
163
+ case 'text':
164
+ case 'string':
165
+ return {
166
+ as: 'prose',
167
+ text: typeof value === 'string' ? value : textOf(value, undefined, locale, t),
168
+ };
169
+ case 'list':
170
+ case 'string[]':
171
+ if (Array.isArray(value))
172
+ return {
173
+ as: 'chips',
174
+ chips: value.map((v) => textOf(v, type === 'list' ? shape?.item : undefined, locale, t)),
175
+ };
176
+ break;
177
+ case 'object':
178
+ case 'share':
179
+ case 'perMember':
180
+ case 'strengths': {
181
+ if (!value || typeof value !== 'object' || Array.isArray(value))
182
+ break;
183
+ const v = value;
184
+ // Declared members in their declared order, then whatever else is stored.
185
+ const declared = type === 'object'
186
+ ? Object.entries(shape?.fields ?? {}).map(([k, d]) => ({
187
+ key: k,
188
+ label: d.label,
189
+ shape: d,
190
+ }))
191
+ : (shape?.members ?? []).map((m) => ({ key: m.key, label: m.label }));
192
+ const keys = [
193
+ ...declared.map((d) => d.key),
194
+ ...Object.keys(v).filter((k) => !declared.some((d) => d.key === k)),
195
+ ];
196
+ return {
197
+ as: 'rows',
198
+ rows: keys
199
+ .filter((k) => v[k] !== undefined)
200
+ .map((k) => {
201
+ const d = declared.find((x) => x.key === k);
202
+ return {
203
+ key: k,
204
+ label: i18nText(d?.label, locale) ?? humanise(k),
205
+ text: textOf(v[k], d?.shape, locale, t),
206
+ };
207
+ }),
208
+ };
209
+ }
210
+ }
211
+ if (type === 'text' || type === 'string')
212
+ return { as: 'prose', text: textOf(value, shape, locale, t) };
213
+ return { as: 'rows', rows: [{ key, label, text: textOf(value, shape, locale, t) }] };
214
+ }
215
+ /**
216
+ * Draw one annex key: an empty state, each one line and never silent, or the
217
+ * value in its shape, with the Session data list's Edit where the viewer may
218
+ * set it.
219
+ *
220
+ * - no key, or not `<owner>.<key>` → *Pick a key in settings*, titled *Annex*;
221
+ * - in the viewer's view → the value;
222
+ * - not in it, and the host says the viewer may not see it → *You can't
223
+ * see this*;
224
+ * - otherwise → *Nothing written yet*. ⚠ A key the viewer may not see is
225
+ * absent from their view exactly as an unwritten one is, so without the
226
+ * host's `see` verdict the two read alike.
227
+ *
228
+ * **Edit** needs all three: the host lists the field as the viewer's to set
229
+ * (`canAct`), the viewer holds no guest seat, and the field is text — by its
230
+ * declared shape, else by the stored value's form (the Session data list's
231
+ * rule, `annexEditsAsText`).
232
+ * @experimental
233
+ */
234
+ export function annexWidgetView(inputs) {
235
+ const t = inputs.t ?? ((s) => s);
236
+ const locale = inputs.locale ?? 'en';
237
+ const parsed = parseAnnexWidgetKey(inputs.key);
238
+ if (!parsed)
239
+ return {
240
+ state: 'pick',
241
+ title: t('Annex'),
242
+ empty: t(ANNEX_WIDGET_EMPTY.pick),
243
+ identity: null,
244
+ canEdit: false,
245
+ draft: '',
246
+ };
247
+ const { owner, key } = parsed;
248
+ const field = inputs.fields.find((f) => f.owner === owner && f.key === key);
249
+ const title = i18nText(field?.label, locale) || key;
250
+ const identity = annexFieldAction(owner, key);
251
+ const doc = inputs.annex?.[owner];
252
+ const value = doc && typeof doc === 'object' ? doc[key] : undefined;
253
+ const blank = isBlank(value);
254
+ const type = field?.shape?.type ?? (blank ? undefined : typeOfValue(value));
255
+ const canEdit = !!field?.canAct && !inputs.viewer?.isGuest && (type === 'text' || type === 'string');
256
+ const draft = typeof value === 'string' ? value : '';
257
+ if (blank) {
258
+ const state = field?.canSee === false && value === undefined ? 'hidden' : 'unwritten';
259
+ return { state, title, empty: t(ANNEX_WIDGET_EMPTY[state]), identity, canEdit, draft };
260
+ }
261
+ const shapeType = type ?? 'text';
262
+ return {
263
+ state: 'value',
264
+ title,
265
+ shape: shapeType,
266
+ drawn: drawnOf(value, shapeType, field?.shape, title, key, locale, t),
267
+ value,
268
+ identity,
269
+ canEdit,
270
+ draft,
271
+ };
272
+ }
273
+ //# sourceMappingURL=index.js.map