@dsh-agentic-roleplay/core 0.10.0 → 0.10.1

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 (32) hide show
  1. package/README.md +1 -1
  2. package/lib/{authoring-tools-B4mEdKp_.js → authoring-tools-C6Hzy8jU.js} +1425 -1241
  3. package/lib/authoring.js +18 -7
  4. package/lib/{child-Dtv76jNx.js → child-C8r8AFpm.js} +36 -5
  5. package/lib/client.js +1780 -829
  6. package/lib/client.js.map +1 -1
  7. package/lib/compaction.js +2 -2
  8. package/lib/doctor.js +2 -2
  9. package/lib/{gallery-BZJleAeH.js → gallery-CtG-bDzz.js} +2 -2
  10. package/lib/{generator-Cg6CQc5S.js → generator-nLoPM5MF.js} +2 -2
  11. package/lib/helper.js +1 -1
  12. package/lib/{hooks-DTjHWTfx.js → hooks-BuQ61nvQ.js} +105 -61
  13. package/lib/images.js +4 -4
  14. package/lib/index.js +964 -106
  15. package/lib/{library-GIlrkOim.js → library-CH-ahlm0.js} +2 -2
  16. package/lib/{lorebook-author-tools-BCFFJSle.js → lorebook-author-tools-B6_Jj8oe.js} +6 -6
  17. package/lib/lorebook-authoring.js +4 -4
  18. package/lib/{narration-BVzew4-K.js → narration-B0hConSw.js} +5 -2
  19. package/lib/orchestration.js +50 -13
  20. package/lib/{pack-jail-hsNQNTOf.js → pack-jail-OZSgU85i.js} +10 -10
  21. package/lib/{packs-UpK_cvI4.js → packs-B88bxt8E.js} +2 -2
  22. package/lib/{presenter-agent-DZOgBOR9.js → presenter-agent-D-WNs626.js} +5 -5
  23. package/lib/{preset-Cyoj1ZWa.js → preset-DNuqvMan.js} +4 -4
  24. package/lib/{preset-author-tools-RSta6pHK.js → preset-author-tools-CDwavcTb.js} +6 -6
  25. package/lib/preset-authoring.js +5 -5
  26. package/lib/{presets-CvpsW_10.js → presets-9_MNxwaw.js} +103 -7
  27. package/lib/{reflection-0qTvw2It.js → reflection-BvM0w1R4.js} +132 -92
  28. package/lib/{text-CbGQhK1-.js → text-CzqhC8sT.js} +11 -1
  29. package/lib/{turn-guard-BzNeGNnc.js → turn-guard-Ygdww1Wt.js} +3 -3
  30. package/package.json +2 -2
  31. package/prompts/en/checks/decide-stated.md +1 -0
  32. package/prompts/zh/checks/decide-stated.md +1 -0
package/lib/client.js CHANGED
@@ -35,8 +35,8 @@ window.__ModuleLoader__.load({
35
35
  }
36
36
  tag$39.textContent = css$39;
37
37
  var PageTabs_module_css_default = {
38
- "tab": "rp_LrKukW_tab",
39
- "tabs": "rp_LrKukW_tabs"
38
+ "tabs": "rp_LrKukW_tabs",
39
+ "tab": "rp_LrKukW_tab"
40
40
  };
41
41
  // src/client/widgets/page-tabs/PageTabs.tsx
42
42
  /** Underlined text tabs; arrow keys, Home and End move between them. */
@@ -89,10 +89,10 @@ window.__ModuleLoader__.load({
89
89
  }
90
90
  tag$38.textContent = css$38;
91
91
  var RoleplayPanel_module_css_default = {
92
- "body": "rp_ua5gBa_body",
93
- "panel": "rp_ua5gBa_panel",
94
92
  "header": "rp_ua5gBa_header",
95
- "title": "rp_ua5gBa_title"
93
+ "title": "rp_ua5gBa_title",
94
+ "body": "rp_ua5gBa_body",
95
+ "panel": "rp_ua5gBa_panel"
96
96
  };
97
97
  // src/client/panel/RoleplayPanel.tsx
98
98
  /** Header, page navigation and the selected page. */
@@ -417,34 +417,34 @@ window.__ModuleLoader__.load({
417
417
  }
418
418
  tag$37.textContent = css$37;
419
419
  var ImportCard_module_css_default = {
420
- "entryHead": "rp_5cvtma_entryHead",
421
- "section": "rp_5cvtma_section",
422
- "entry": "rp_5cvtma_entry",
423
- "choice": "rp_5cvtma_choice",
420
+ "fieldTitle": "rp_5cvtma_fieldTitle",
421
+ "label": "rp_5cvtma_label",
422
+ "picture": "rp_5cvtma_picture",
423
+ "entryTitle": "rp_5cvtma_entryTitle",
424
424
  "page": "rp_5cvtma_page",
425
- "header": "rp_5cvtma_header",
425
+ "text": "rp_5cvtma_text",
426
+ "choice": "rp_5cvtma_choice",
426
427
  "note": "rp_5cvtma_note",
427
- "top": "rp_5cvtma_top",
428
- "title": "rp_5cvtma_title",
429
- "space": "rp_5cvtma_space",
430
- "entryTitle": "rp_5cvtma_entryTitle",
428
+ "section": "rp_5cvtma_section",
429
+ "choiceText": "rp_5cvtma_choiceText",
430
+ "preview": "rp_5cvtma_preview",
431
431
  "about": "rp_5cvtma_about",
432
432
  "tags": "rp_5cvtma_tags",
433
+ "top": "rp_5cvtma_top",
434
+ "fieldMeta": "rp_5cvtma_fieldMeta",
435
+ "entryHead": "rp_5cvtma_entryHead",
436
+ "body": "rp_5cvtma_body",
433
437
  "field": "rp_5cvtma_field",
434
- "text": "rp_5cvtma_text",
435
- "noPicture": "rp_5cvtma_noPicture",
436
438
  "row": "rp_5cvtma_row",
437
- "picture": "rp_5cvtma_picture",
438
- "fieldHead": "rp_5cvtma_fieldHead",
439
+ "entry": "rp_5cvtma_entry",
440
+ "noPicture": "rp_5cvtma_noPicture",
439
441
  "entryOff": "rp_5cvtma_entryOff",
440
- "choiceText": "rp_5cvtma_choiceText",
442
+ "title": "rp_5cvtma_title",
443
+ "header": "rp_5cvtma_header",
444
+ "space": "rp_5cvtma_space",
441
445
  "error": "rp_5cvtma_error",
442
- "label": "rp_5cvtma_label",
443
- "body": "rp_5cvtma_body",
444
446
  "heading": "rp_5cvtma_heading",
445
- "fieldMeta": "rp_5cvtma_fieldMeta",
446
- "fieldTitle": "rp_5cvtma_fieldTitle",
447
- "preview": "rp_5cvtma_preview"
447
+ "fieldHead": "rp_5cvtma_fieldHead"
448
448
  };
449
449
  // src/client/widgets/import-card/ImportCard.tsx
450
450
  const pictureUrl = (id) => `${API_PREFIX}/worlds/import/picture?id=${encodeURIComponent(id)}`;
@@ -490,6 +490,8 @@ window.__ModuleLoader__.load({
490
490
  function ImportCard({ t, preview, initialUpdate, start: begin, startPlain, discard, onCancelled, onStarted, onImportedPlain }) {
491
491
  const { card } = preview;
492
492
  const entries = card.book?.entries ?? [];
493
+ const dialect = preview.dialect;
494
+ const dialectParts = dialect === void 0 ? [] : [...dialect.macros.length > 0 ? [t("ic_dialectMacros", { names: dialect.macros.join(", ") })] : [], ...dialect.tags.length > 0 ? [t("ic_dialectTags", { names: dialect.tags.join(", ") })] : []];
493
495
  const [name, setName] = (0, react.useState)(preview.choices.name);
494
496
  const [off, setOff] = (0, react.useState)(() => new Set(preview.choices.disabledEntries));
495
497
  const [opening, setOpening] = (0, react.useState)(preview.choices.opening);
@@ -640,6 +642,11 @@ window.__ModuleLoader__.load({
640
642
  card.ignored.scripts > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
641
643
  className: ImportCard_module_css_default.note,
642
644
  children: t("ic_scripts", { count: card.ignored.scripts })
645
+ }),
646
+ dialectParts.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
647
+ className: ImportCard_module_css_default.note,
648
+ "data-testid": "roleplay-import-dialect",
649
+ children: t("ic_dialect", { parts: dialectParts.join("; ") })
643
650
  })
644
651
  ]
645
652
  })]
@@ -926,38 +933,38 @@ window.__ModuleLoader__.load({
926
933
  }
927
934
  tag$36.textContent = css$36;
928
935
  var CataloguePage_module_css_default = {
929
- "kind": "rp_qK1u-G_kind",
930
- "image": "rp_qK1u-G_image",
931
- "placeholder": "rp_qK1u-G_placeholder",
932
- "detail": "rp_qK1u-G_detail",
933
- "card": "rp_qK1u-G_card",
934
- "page": "rp_qK1u-G_page",
935
- "notice": "rp_qK1u-G_notice",
936
- "name": "rp_qK1u-G_name",
937
936
  "field": "rp_qK1u-G_field",
937
+ "actions": "rp_qK1u-G_actions",
938
+ "search": "rp_qK1u-G_search",
939
+ "name": "rp_qK1u-G_name",
940
+ "detail": "rp_qK1u-G_detail",
941
+ "select": "rp_qK1u-G_select",
942
+ "label": "rp_qK1u-G_label",
943
+ "update": "rp_qK1u-G_update",
938
944
  "form": "rp_qK1u-G_form",
939
- "updates": "rp_qK1u-G_updates",
940
- "spacer": "rp_qK1u-G_spacer",
941
945
  "changes": "rp_qK1u-G_changes",
946
+ "placeholder": "rp_qK1u-G_placeholder",
947
+ "kind": "rp_qK1u-G_kind",
948
+ "success": "rp_qK1u-G_success",
949
+ "card": "rp_qK1u-G_card",
950
+ "warning": "rp_qK1u-G_warning",
951
+ "viewport": "rp_qK1u-G_viewport",
952
+ "cover": "rp_qK1u-G_cover",
953
+ "notice": "rp_qK1u-G_notice",
942
954
  "tags": "rp_qK1u-G_tags",
955
+ "updates": "rp_qK1u-G_updates",
956
+ "grid": "rp_qK1u-G_grid",
943
957
  "toolbar": "rp_qK1u-G_toolbar",
958
+ "meta": "rp_qK1u-G_meta",
959
+ "description": "rp_qK1u-G_description",
944
960
  "status": "rp_qK1u-G_status",
945
- "viewport": "rp_qK1u-G_viewport",
961
+ "body": "rp_qK1u-G_body",
946
962
  "message": "rp_qK1u-G_message",
947
- "description": "rp_qK1u-G_description",
948
- "success": "rp_qK1u-G_success",
949
- "warning": "rp_qK1u-G_warning",
950
963
  "kinds": "rp_qK1u-G_kinds",
951
- "label": "rp_qK1u-G_label",
952
- "body": "rp_qK1u-G_body",
953
- "grid": "rp_qK1u-G_grid",
954
- "search": "rp_qK1u-G_search",
955
- "actions": "rp_qK1u-G_actions",
956
- "cover": "rp_qK1u-G_cover",
957
- "meta": "rp_qK1u-G_meta",
958
- "update": "rp_qK1u-G_update",
959
- "more": "rp_qK1u-G_more",
960
- "select": "rp_qK1u-G_select"
964
+ "image": "rp_qK1u-G_image",
965
+ "spacer": "rp_qK1u-G_spacer",
966
+ "page": "rp_qK1u-G_page",
967
+ "more": "rp_qK1u-G_more"
961
968
  };
962
969
  // src/client/pages/catalogue/ImportUrlDialog.tsx
963
970
  /** Installs a world from the address of its archive; an address on a configured catalogue's site is asked for with that catalogue's key. */
@@ -1156,19 +1163,19 @@ window.__ModuleLoader__.load({
1156
1163
  }
1157
1164
  tag$35.textContent = css$35;
1158
1165
  var ImportSelection_module_css_default = {
1159
- "count": "rp_Jx0l4q_count",
1160
- "bar": "rp_Jx0l4q_bar",
1161
1166
  "meta": "rp_Jx0l4q_meta",
1167
+ "body": "rp_Jx0l4q_body",
1162
1168
  "full": "rp_Jx0l4q_full",
1169
+ "note": "rp_Jx0l4q_note",
1163
1170
  "sampling": "rp_Jx0l4q_sampling",
1164
- "body": "rp_Jx0l4q_body",
1171
+ "help": "rp_Jx0l4q_help",
1172
+ "list": "rp_Jx0l4q_list",
1165
1173
  "error": "rp_Jx0l4q_error",
1166
1174
  "extra": "rp_Jx0l4q_extra",
1167
- "help": "rp_Jx0l4q_help",
1168
- "note": "rp_Jx0l4q_note",
1169
1175
  "text": "rp_Jx0l4q_text",
1170
1176
  "row": "rp_Jx0l4q_row",
1171
- "list": "rp_Jx0l4q_list"
1177
+ "bar": "rp_Jx0l4q_bar",
1178
+ "count": "rp_Jx0l4q_count"
1172
1179
  };
1173
1180
  // src/client/widgets/import-selection/ImportSelection.tsx
1174
1181
  const messageOf$12 = (failure) => failure instanceof Error ? failure.message : String(failure);
@@ -2175,6 +2182,9 @@ window.__ModuleLoader__.load({
2175
2182
  ic_keys: "Keys: {keys}",
2176
2183
  ic_noKeys: "No keys",
2177
2184
  ic_scripts: "{count} scripts and settings of the tool that made the card are not imported.",
2185
+ ic_dialect: "Nothing here runs the tool's own markup, so its effect is kept only where the card also says it in words: {parts}.",
2186
+ ic_dialectMacros: "macros ({names})",
2187
+ ic_dialectTags: "tag blocks ({names})",
2178
2188
  ic_start: "Import",
2179
2189
  ic_startPlain: "Import without a model",
2180
2190
  ic_startPlainHelp: "Carries over the card's own character, its lorebook (for the game master only) and its instructions as they are written, with no model: places, factions and other people are not read out of it.",
@@ -2223,6 +2233,9 @@ window.__ModuleLoader__.load({
2223
2233
  ic_keys: "关键词:{keys}",
2224
2234
  ic_noKeys: "无关键词",
2225
2235
  ic_scripts: "制作角色卡的工具的 {count} 个脚本和设置不会导入。",
2236
+ ic_dialect: "这里不会执行原工具的标记,所以只有卡片同时用文字写明的效果才会保留:{parts}。",
2237
+ ic_dialectMacros: "宏({names})",
2238
+ ic_dialectTags: "标签块({names})",
2226
2239
  ic_start: "导入",
2227
2240
  ic_startPlain: "不使用模型导入",
2228
2241
  ic_startPlainHelp: "不使用模型,原样带入卡片自己的角色、世界书(仅游戏主持人可读)和指令;不会从中识别地点、势力或其他人物。",
@@ -3050,40 +3063,40 @@ window.__ModuleLoader__.load({
3050
3063
  }
3051
3064
  tag$34.textContent = css$34;
3052
3065
  var CharactersPanel_module_css_default = {
3053
- "missing": "rp_5ZMIxq_missing",
3054
- "row": "rp_5ZMIxq_row",
3055
- "grid": "rp_5ZMIxq_grid",
3056
- "initial": "rp_5ZMIxq_initial",
3066
+ "help": "rp_5ZMIxq_help",
3067
+ "portraitAction": "rp_5ZMIxq_portraitAction",
3068
+ "tabs": "rp_5ZMIxq_tabs",
3069
+ "placeholder": "rp_5ZMIxq_placeholder",
3057
3070
  "section": "rp_5ZMIxq_section",
3058
- "nameInput": "rp_5ZMIxq_nameInput",
3059
- "portraitError": "rp_5ZMIxq_portraitError",
3060
- "portrait": "rp_5ZMIxq_portrait",
3061
- "portraitBox": "rp_5ZMIxq_portraitBox",
3062
- "voiceInline": "rp_5ZMIxq_voiceInline",
3063
- "barText": "rp_5ZMIxq_barText",
3064
- "label": "rp_5ZMIxq_label",
3065
- "empty": "rp_5ZMIxq_empty",
3066
- "sectionTitle": "rp_5ZMIxq_sectionTitle",
3067
3071
  "wide": "rp_5ZMIxq_wide",
3068
- "body": "rp_5ZMIxq_body",
3069
- "panel": "rp_5ZMIxq_panel",
3070
- "head": "rp_5ZMIxq_head",
3071
- "meta": "rp_5ZMIxq_meta",
3072
+ "field": "rp_5ZMIxq_field",
3072
3073
  "goal": "rp_5ZMIxq_goal",
3073
- "select": "rp_5ZMIxq_select",
3074
- "tabsSpace": "rp_5ZMIxq_tabsSpace",
3075
- "tabOn": "rp_5ZMIxq_tabOn",
3076
- "portraitHint": "rp_5ZMIxq_portraitHint",
3077
- "placeholder": "rp_5ZMIxq_placeholder",
3078
- "help": "rp_5ZMIxq_help",
3079
- "portraitAction": "rp_5ZMIxq_portraitAction",
3074
+ "portraitError": "rp_5ZMIxq_portraitError",
3075
+ "tab": "rp_5ZMIxq_tab",
3080
3076
  "sheet": "rp_5ZMIxq_sheet",
3081
3077
  "error": "rp_5ZMIxq_error",
3078
+ "grid": "rp_5ZMIxq_grid",
3079
+ "portraitHint": "rp_5ZMIxq_portraitHint",
3080
+ "row": "rp_5ZMIxq_row",
3081
+ "panel": "rp_5ZMIxq_panel",
3082
3082
  "bar": "rp_5ZMIxq_bar",
3083
- "tabs": "rp_5ZMIxq_tabs",
3084
- "field": "rp_5ZMIxq_field",
3083
+ "barText": "rp_5ZMIxq_barText",
3084
+ "head": "rp_5ZMIxq_head",
3085
+ "missing": "rp_5ZMIxq_missing",
3086
+ "sectionTitle": "rp_5ZMIxq_sectionTitle",
3087
+ "label": "rp_5ZMIxq_label",
3088
+ "nameInput": "rp_5ZMIxq_nameInput",
3089
+ "tabOn": "rp_5ZMIxq_tabOn",
3090
+ "meta": "rp_5ZMIxq_meta",
3091
+ "select": "rp_5ZMIxq_select",
3085
3092
  "area": "rp_5ZMIxq_area",
3086
- "tab": "rp_5ZMIxq_tab"
3093
+ "initial": "rp_5ZMIxq_initial",
3094
+ "portraitBox": "rp_5ZMIxq_portraitBox",
3095
+ "body": "rp_5ZMIxq_body",
3096
+ "empty": "rp_5ZMIxq_empty",
3097
+ "voiceInline": "rp_5ZMIxq_voiceInline",
3098
+ "portrait": "rp_5ZMIxq_portrait",
3099
+ "tabsSpace": "rp_5ZMIxq_tabsSpace"
3087
3100
  };
3088
3101
  // src/client/world-editor/EditorTabs.tsx
3089
3102
  /** Adds expected arrow, Home and End navigation to an existing editor tab strip. */
@@ -4802,39 +4815,39 @@ window.__ModuleLoader__.load({
4802
4815
  }
4803
4816
  tag$33.textContent = css$33;
4804
4817
  var RelationsPanel_module_css_default = {
4805
- "space": "rp_7pEHTW_space",
4806
- "graph": "rp_7pEHTW_graph",
4807
- "node_location": "rp_7pEHTW_node_location",
4808
- "wide": "rp_7pEHTW_wide",
4809
- "edge": "rp_7pEHTW_edge",
4810
- "edgeOn": "rp_7pEHTW_edgeOn",
4811
- "perspective": "rp_7pEHTW_perspective",
4812
- "inspector": "rp_7pEHTW_inspector",
4813
- "node_item": "rp_7pEHTW_node_item",
4814
- "error": "rp_7pEHTW_error",
4815
- "empty": "rp_7pEHTW_empty",
4816
4818
  "toolbar": "rp_7pEHTW_toolbar",
4817
- "filterOn": "rp_7pEHTW_filterOn",
4818
- "edgeTitle": "rp_7pEHTW_edgeTitle",
4819
+ "filter": "rp_7pEHTW_filter",
4819
4820
  "status": "rp_7pEHTW_status",
4820
- "entities": "rp_7pEHTW_entities",
4821
- "head": "rp_7pEHTW_head",
4822
- "workspace": "rp_7pEHTW_workspace",
4821
+ "error": "rp_7pEHTW_error",
4822
+ "panel": "rp_7pEHTW_panel",
4823
+ "node_location": "rp_7pEHTW_node_location",
4823
4824
  "node_character": "rp_7pEHTW_node_character",
4824
- "metrics": "rp_7pEHTW_metrics",
4825
+ "graphEdgeOn": "rp_7pEHTW_graphEdgeOn",
4825
4826
  "node": "rp_7pEHTW_node",
4826
- "node_faction": "rp_7pEHTW_node_faction",
4827
4827
  "list": "rp_7pEHTW_list",
4828
- "graphInspector": "rp_7pEHTW_graphInspector",
4829
- "panel": "rp_7pEHTW_panel",
4830
- "graphEdge": "rp_7pEHTW_graphEdge",
4828
+ "perspective": "rp_7pEHTW_perspective",
4829
+ "head": "rp_7pEHTW_head",
4830
+ "empty": "rp_7pEHTW_empty",
4831
+ "graph": "rp_7pEHTW_graph",
4832
+ "form": "rp_7pEHTW_form",
4833
+ "edgeTitle": "rp_7pEHTW_edgeTitle",
4834
+ "actions": "rp_7pEHTW_actions",
4835
+ "edgeOn": "rp_7pEHTW_edgeOn",
4836
+ "space": "rp_7pEHTW_space",
4837
+ "edge": "rp_7pEHTW_edge",
4838
+ "metrics": "rp_7pEHTW_metrics",
4831
4839
  "edgeKind": "rp_7pEHTW_edgeKind",
4832
- "check": "rp_7pEHTW_check",
4833
- "filter": "rp_7pEHTW_filter",
4840
+ "graphInspector": "rp_7pEHTW_graphInspector",
4841
+ "wide": "rp_7pEHTW_wide",
4834
4842
  "notice": "rp_7pEHTW_notice",
4835
- "actions": "rp_7pEHTW_actions",
4836
- "form": "rp_7pEHTW_form",
4837
- "graphEdgeOn": "rp_7pEHTW_graphEdgeOn"
4843
+ "workspace": "rp_7pEHTW_workspace",
4844
+ "inspector": "rp_7pEHTW_inspector",
4845
+ "check": "rp_7pEHTW_check",
4846
+ "node_faction": "rp_7pEHTW_node_faction",
4847
+ "filterOn": "rp_7pEHTW_filterOn",
4848
+ "graphEdge": "rp_7pEHTW_graphEdge",
4849
+ "entities": "rp_7pEHTW_entities",
4850
+ "node_item": "rp_7pEHTW_node_item"
4838
4851
  };
4839
4852
  // src/client/world-editor/RelationsPanel.tsx
4840
4853
  const title = (relation) => `${relation.from.name} → ${relation.to.name}`;
@@ -6204,11 +6217,11 @@ window.__ModuleLoader__.load({
6204
6217
  tag$32.textContent = css$32;
6205
6218
  var PackFrame_module_css_default = {
6206
6219
  "frame": "rp_h_sbFq_frame",
6207
- "problems": "rp_h_sbFq_problems",
6208
- "hud": "rp_h_sbFq_hud",
6209
6220
  "tab": "rp_h_sbFq_tab",
6210
- "message": "rp_h_sbFq_message",
6211
- "fill": "rp_h_sbFq_fill"
6221
+ "hud": "rp_h_sbFq_hud",
6222
+ "fill": "rp_h_sbFq_fill",
6223
+ "problems": "rp_h_sbFq_problems",
6224
+ "message": "rp_h_sbFq_message"
6212
6225
  };
6213
6226
  // src/client/widgets/pack-frame/theme.ts
6214
6227
  /** The colours of DSH a surface is given, so that it looks right in light and dark. */
@@ -6467,13 +6480,13 @@ window.__ModuleLoader__.load({
6467
6480
  }
6468
6481
  tag$31.textContent = css$31;
6469
6482
  var PacksPanel_module_css_default = {
6470
- "controls": "rp_FLaP7q_controls",
6483
+ "stage": "rp_FLaP7q_stage",
6471
6484
  "group": "rp_FLaP7q_group",
6472
- "stageTall": "rp_FLaP7q_stageTall",
6485
+ "controls": "rp_FLaP7q_controls",
6473
6486
  "log": "rp_FLaP7q_log",
6487
+ "stageTall": "rp_FLaP7q_stageTall",
6474
6488
  "files": "rp_FLaP7q_files",
6475
- "note": "rp_FLaP7q_note",
6476
- "stage": "rp_FLaP7q_stage"
6489
+ "note": "rp_FLaP7q_note"
6477
6490
  };
6478
6491
  // src/client/world-editor/PacksPanel.tsx
6479
6492
  const WIDTHS = {
@@ -7568,12 +7581,12 @@ window.__ModuleLoader__.load({
7568
7581
  }
7569
7582
  tag$30.textContent = css$30;
7570
7583
  var SamplingFields_module_css_default = {
7571
- "label": "rp_9vxYSG_label",
7572
- "grid": "rp_9vxYSG_grid",
7573
- "input": "rp_9vxYSG_input",
7574
- "help": "rp_9vxYSG_help",
7575
7584
  "root": "rp_9vxYSG_root",
7576
- "field": "rp_9vxYSG_field"
7585
+ "input": "rp_9vxYSG_input",
7586
+ "grid": "rp_9vxYSG_grid",
7587
+ "field": "rp_9vxYSG_field",
7588
+ "label": "rp_9vxYSG_label",
7589
+ "help": "rp_9vxYSG_help"
7577
7590
  };
7578
7591
  // src/client/widgets/sampling-fields/SamplingFields.tsx
7579
7592
  const samplingTexts = (sampling) => Object.fromEntries(SAMPLING_KEYS.map((key) => [key, sampling[key]?.toString() ?? ""]));
@@ -8982,17 +8995,17 @@ window.__ModuleLoader__.load({
8982
8995
  }
8983
8996
  tag$29.textContent = css$29;
8984
8997
  var ToolSwitches_module_css_default = {
8998
+ "help": "rp_CjoFLq_help",
8999
+ "agent": "rp_CjoFLq_agent",
9000
+ "default": "rp_CjoFLq_default",
8985
9001
  "agentName": "rp_CjoFLq_agentName",
9002
+ "toolText": "rp_CjoFLq_toolText",
8986
9003
  "root": "rp_CjoFLq_root",
8987
- "hint": "rp_CjoFLq_hint",
8988
- "tool": "rp_CjoFLq_tool",
9004
+ "error": "rp_CjoFLq_error",
8989
9005
  "external": "rp_CjoFLq_external",
8990
- "help": "rp_CjoFLq_help",
8991
- "agent": "rp_CjoFLq_agent",
9006
+ "hint": "rp_CjoFLq_hint",
8992
9007
  "title": "rp_CjoFLq_title",
8993
- "toolText": "rp_CjoFLq_toolText",
8994
- "default": "rp_CjoFLq_default",
8995
- "error": "rp_CjoFLq_error"
9008
+ "tool": "rp_CjoFLq_tool"
8996
9009
  };
8997
9010
  // src/client/widgets/tool-switches/ToolSwitches.tsx
8998
9011
  /**
@@ -9995,39 +10008,39 @@ window.__ModuleLoader__.load({
9995
10008
  }
9996
10009
  tag$28.textContent = css$28;
9997
10010
  var GalleryView_module_css_default = {
9998
- "editInput": "rp_9pSHmG_editInput",
10011
+ "detail": "rp_9pSHmG_detail",
9999
10012
  "error": "rp_9pSHmG_error",
10000
- "image": "rp_9pSHmG_image",
10001
- "tags": "rp_9pSHmG_tags",
10002
- "thumb": "rp_9pSHmG_thumb",
10013
+ "open": "rp_9pSHmG_open",
10014
+ "grid": "rp_9pSHmG_grid",
10003
10015
  "count": "rp_9pSHmG_count",
10004
- "reusable": "rp_9pSHmG_reusable",
10005
- "detail": "rp_9pSHmG_detail",
10016
+ "tags": "rp_9pSHmG_tags",
10017
+ "note": "rp_9pSHmG_note",
10018
+ "status": "rp_9pSHmG_status",
10019
+ "page": "rp_9pSHmG_page",
10020
+ "cell": "rp_9pSHmG_cell",
10006
10021
  "pre": "rp_9pSHmG_pre",
10007
- "message": "rp_9pSHmG_message",
10008
- "actions": "rp_9pSHmG_actions",
10009
- "edit": "rp_9pSHmG_edit",
10010
- "large": "rp_9pSHmG_large",
10011
- "editButton": "rp_9pSHmG_editButton",
10022
+ "editLabel": "rp_9pSHmG_editLabel",
10023
+ "facts": "rp_9pSHmG_facts",
10012
10024
  "editHelp": "rp_9pSHmG_editHelp",
10013
- "grid": "rp_9pSHmG_grid",
10025
+ "large": "rp_9pSHmG_large",
10026
+ "caption": "rp_9pSHmG_caption",
10014
10027
  "toolbar": "rp_9pSHmG_toolbar",
10028
+ "editInput": "rp_9pSHmG_editInput",
10029
+ "message": "rp_9pSHmG_message",
10015
10030
  "select": "rp_9pSHmG_select",
10016
- "page": "rp_9pSHmG_page",
10017
- "facts": "rp_9pSHmG_facts",
10018
- "note": "rp_9pSHmG_note",
10031
+ "actions": "rp_9pSHmG_actions",
10019
10032
  "statusError": "rp_9pSHmG_statusError",
10020
- "open": "rp_9pSHmG_open",
10021
- "status": "rp_9pSHmG_status",
10022
- "editArea": "rp_9pSHmG_editArea",
10023
- "caption": "rp_9pSHmG_caption",
10033
+ "thumb": "rp_9pSHmG_thumb",
10024
10034
  "editField": "rp_9pSHmG_editField",
10025
- "cell": "rp_9pSHmG_cell",
10026
- "editLabel": "rp_9pSHmG_editLabel"
10035
+ "editButton": "rp_9pSHmG_editButton",
10036
+ "reusable": "rp_9pSHmG_reusable",
10037
+ "image": "rp_9pSHmG_image",
10038
+ "editArea": "rp_9pSHmG_editArea",
10039
+ "edit": "rp_9pSHmG_edit"
10027
10040
  };
10028
10041
  // src/client/widgets/gallery-view/GalleryView.tsx
10029
10042
  /** How often the list is read again while pictures are waiting to be described. */
10030
- const POLL_MS$2 = 3e3;
10043
+ const POLL_MS$3 = 3e3;
10031
10044
  const messageOf$8 = (error) => error instanceof Error ? error.message : String(error);
10032
10045
  function EditDialog({ t, image, onSave, onClose }) {
10033
10046
  const [description, setDescription] = (0, react.useState)(image.description ?? "");
@@ -10148,7 +10161,7 @@ window.__ModuleLoader__.load({
10148
10161
  const abort = new AbortController();
10149
10162
  const timer = window.setTimeout(() => {
10150
10163
  read(abort.signal);
10151
- }, POLL_MS$2);
10164
+ }, POLL_MS$3);
10152
10165
  return () => {
10153
10166
  window.clearTimeout(timer);
10154
10167
  abort.abort();
@@ -10362,13 +10375,13 @@ window.__ModuleLoader__.load({
10362
10375
  }
10363
10376
  tag$27.textContent = css$27;
10364
10377
  var WorldEditor_module_css_default = {
10365
- "drawer": "rp__swA3a_drawer",
10366
- "drawerItemOn": "rp__swA3a_drawerItemOn",
10378
+ "view": "rp__swA3a_view",
10367
10379
  "warning": "rp__swA3a_warning",
10380
+ "drawerItemOn": "rp__swA3a_drawerItemOn",
10368
10381
  "message": "rp__swA3a_message",
10369
- "view": "rp__swA3a_view",
10370
- "drawerItem": "rp__swA3a_drawerItem",
10371
- "content": "rp__swA3a_content"
10382
+ "drawer": "rp__swA3a_drawer",
10383
+ "content": "rp__swA3a_content",
10384
+ "drawerItem": "rp__swA3a_drawerItem"
10372
10385
  };
10373
10386
  // src/client/world-editor/WorldEditor.tsx
10374
10387
  const SECTIONS = [
@@ -10762,27 +10775,27 @@ window.__ModuleLoader__.load({
10762
10775
  }
10763
10776
  tag$26.textContent = css$26;
10764
10777
  var AvatarsPage_module_css_default = {
10765
- "grid": "rp_pQOzEG_grid",
10766
- "card": "rp_pQOzEG_card",
10767
- "label": "rp_pQOzEG_label",
10768
- "text": "rp_pQOzEG_text",
10769
- "summary": "rp_pQOzEG_summary",
10770
- "form": "rp_pQOzEG_form",
10771
10778
  "editTitle": "rp_pQOzEG_editTitle",
10772
10779
  "count": "rp_pQOzEG_count",
10773
10780
  "open": "rp_pQOzEG_open",
10774
- "name": "rp_pQOzEG_name",
10775
- "editHeader": "rp_pQOzEG_editHeader",
10776
- "editBody": "rp_pQOzEG_editBody",
10777
- "viewport": "rp_pQOzEG_viewport",
10778
10781
  "actions": "rp_pQOzEG_actions",
10779
- "toolbar": "rp_pQOzEG_toolbar",
10780
- "message": "rp_pQOzEG_message",
10782
+ "grid": "rp_pQOzEG_grid",
10783
+ "placeholder": "rp_pQOzEG_placeholder",
10781
10784
  "error": "rp_pQOzEG_error",
10782
- "page": "rp_pQOzEG_page",
10783
10785
  "portrait": "rp_pQOzEG_portrait",
10786
+ "summary": "rp_pQOzEG_summary",
10787
+ "editBody": "rp_pQOzEG_editBody",
10788
+ "label": "rp_pQOzEG_label",
10789
+ "message": "rp_pQOzEG_message",
10790
+ "name": "rp_pQOzEG_name",
10791
+ "card": "rp_pQOzEG_card",
10792
+ "page": "rp_pQOzEG_page",
10793
+ "text": "rp_pQOzEG_text",
10794
+ "toolbar": "rp_pQOzEG_toolbar",
10784
10795
  "field": "rp_pQOzEG_field",
10785
- "placeholder": "rp_pQOzEG_placeholder"
10796
+ "viewport": "rp_pQOzEG_viewport",
10797
+ "editHeader": "rp_pQOzEG_editHeader",
10798
+ "form": "rp_pQOzEG_form"
10786
10799
  };
10787
10800
  // src/client/pages/avatars/AvatarsPage.tsx
10788
10801
  const hueOf$2 = (name) => Array.from(name).reduce((hash, char) => (hash * 31 + char.charCodeAt(0)) % 360, 0);
@@ -12226,41 +12239,41 @@ window.__ModuleLoader__.load({
12226
12239
  }
12227
12240
  tag$25.textContent = css$25;
12228
12241
  var LorebooksPage_module_css_default = {
12229
- "page": "rp_VV-Eha_page",
12230
- "form": "rp_VV-Eha_form",
12231
- "sectionTitle": "rp_VV-Eha_sectionTitle",
12232
- "editHeader": "rp_VV-Eha_editHeader",
12242
+ "actions": "rp_VV-Eha_actions",
12233
12243
  "meta": "rp_VV-Eha_meta",
12234
- "viewport": "rp_VV-Eha_viewport",
12235
- "card": "rp_VV-Eha_card",
12236
- "select": "rp_VV-Eha_select",
12237
- "field": "rp_VV-Eha_field",
12238
- "count": "rp_VV-Eha_count",
12239
- "cardActions": "rp_VV-Eha_cardActions",
12240
- "section": "rp_VV-Eha_section",
12241
- "toolbar": "rp_VV-Eha_toolbar",
12242
- "error": "rp_VV-Eha_error",
12244
+ "label": "rp_VV-Eha_label",
12245
+ "entryArea": "rp_VV-Eha_entryArea",
12243
12246
  "message": "rp_VV-Eha_message",
12247
+ "form": "rp_VV-Eha_form",
12244
12248
  "title": "rp_VV-Eha_title",
12249
+ "select": "rp_VV-Eha_select",
12250
+ "count": "rp_VV-Eha_count",
12251
+ "field": "rp_VV-Eha_field",
12252
+ "editTitle": "rp_VV-Eha_editTitle",
12253
+ "name": "rp_VV-Eha_name",
12245
12254
  "area": "rp_VV-Eha_area",
12246
- "entryArea": "rp_VV-Eha_entryArea",
12247
- "actions": "rp_VV-Eha_actions",
12248
- "row": "rp_VV-Eha_row",
12249
- "grid": "rp_VV-Eha_grid",
12250
- "ok": "rp_VV-Eha_ok",
12251
- "warning": "rp_VV-Eha_warning",
12252
- "editBody": "rp_VV-Eha_editBody",
12255
+ "sectionTitle": "rp_VV-Eha_sectionTitle",
12256
+ "card": "rp_VV-Eha_card",
12257
+ "head": "rp_VV-Eha_head",
12253
12258
  "description": "rp_VV-Eha_description",
12254
- "label": "rp_VV-Eha_label",
12255
12259
  "input": "rp_VV-Eha_input",
12260
+ "grid": "rp_VV-Eha_grid",
12261
+ "section": "rp_VV-Eha_section",
12256
12262
  "help": "rp_VV-Eha_help",
12257
- "editTitle": "rp_VV-Eha_editTitle",
12258
- "head": "rp_VV-Eha_head",
12259
- "name": "rp_VV-Eha_name"
12263
+ "row": "rp_VV-Eha_row",
12264
+ "cardActions": "rp_VV-Eha_cardActions",
12265
+ "viewport": "rp_VV-Eha_viewport",
12266
+ "toolbar": "rp_VV-Eha_toolbar",
12267
+ "page": "rp_VV-Eha_page",
12268
+ "editHeader": "rp_VV-Eha_editHeader",
12269
+ "editBody": "rp_VV-Eha_editBody",
12270
+ "error": "rp_VV-Eha_error",
12271
+ "ok": "rp_VV-Eha_ok",
12272
+ "warning": "rp_VV-Eha_warning"
12260
12273
  };
12261
12274
  // src/client/pages/lorebooks/LorebookEditor.tsx
12262
12275
  const messageOf$7 = (failure) => failure instanceof Error ? failure.message : String(failure);
12263
- const KINDS = [
12276
+ const KINDS$1 = [
12264
12277
  "history",
12265
12278
  "culture",
12266
12279
  "religion",
@@ -12575,7 +12588,7 @@ window.__ModuleLoader__.load({
12575
12588
  onChange: (event) => {
12576
12589
  edit({ kind: event.target.value });
12577
12590
  },
12578
- children: KINDS.map((kind) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
12591
+ children: KINDS$1.map((kind) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
12579
12592
  value: kind,
12580
12593
  children: t(`kind_${kind}`)
12581
12594
  }, kind))
@@ -13295,35 +13308,35 @@ window.__ModuleLoader__.load({
13295
13308
  }
13296
13309
  tag$24.textContent = css$24;
13297
13310
  var PresetsPage_module_css_default = {
13298
- "title": "rp_ZK89ba_title",
13299
- "meta": "rp_ZK89ba_meta",
13311
+ "editHeader": "rp_ZK89ba_editHeader",
13300
13312
  "warning": "rp_ZK89ba_warning",
13313
+ "error": "rp_ZK89ba_error",
13314
+ "section": "rp_ZK89ba_section",
13315
+ "card": "rp_ZK89ba_card",
13316
+ "grid": "rp_ZK89ba_grid",
13301
13317
  "editTitle": "rp_ZK89ba_editTitle",
13302
- "description": "rp_ZK89ba_description",
13318
+ "row": "rp_ZK89ba_row",
13319
+ "message": "rp_ZK89ba_message",
13320
+ "field": "rp_ZK89ba_field",
13321
+ "actions": "rp_ZK89ba_actions",
13322
+ "meta": "rp_ZK89ba_meta",
13303
13323
  "page": "rp_ZK89ba_page",
13304
- "area": "rp_ZK89ba_area",
13305
- "help": "rp_ZK89ba_help",
13306
- "count": "rp_ZK89ba_count",
13307
- "editHeader": "rp_ZK89ba_editHeader",
13308
- "editBody": "rp_ZK89ba_editBody",
13309
- "form": "rp_ZK89ba_form",
13310
- "card": "rp_ZK89ba_card",
13311
13324
  "cardActions": "rp_ZK89ba_cardActions",
13312
- "error": "rp_ZK89ba_error",
13313
- "field": "rp_ZK89ba_field",
13314
- "head": "rp_ZK89ba_head",
13325
+ "form": "rp_ZK89ba_form",
13326
+ "label": "rp_ZK89ba_label",
13327
+ "area": "rp_ZK89ba_area",
13315
13328
  "viewport": "rp_ZK89ba_viewport",
13316
- "toolbar": "rp_ZK89ba_toolbar",
13329
+ "description": "rp_ZK89ba_description",
13330
+ "title": "rp_ZK89ba_title",
13317
13331
  "name": "rp_ZK89ba_name",
13318
- "grid": "rp_ZK89ba_grid",
13319
- "label": "rp_ZK89ba_label",
13320
- "ok": "rp_ZK89ba_ok",
13321
- "input": "rp_ZK89ba_input",
13322
- "section": "rp_ZK89ba_section",
13332
+ "count": "rp_ZK89ba_count",
13333
+ "toolbar": "rp_ZK89ba_toolbar",
13334
+ "head": "rp_ZK89ba_head",
13335
+ "help": "rp_ZK89ba_help",
13323
13336
  "sectionTitle": "rp_ZK89ba_sectionTitle",
13324
- "actions": "rp_ZK89ba_actions",
13325
- "row": "rp_ZK89ba_row",
13326
- "message": "rp_ZK89ba_message"
13337
+ "editBody": "rp_ZK89ba_editBody",
13338
+ "input": "rp_ZK89ba_input",
13339
+ "ok": "rp_ZK89ba_ok"
13327
13340
  };
13328
13341
  // src/client/pages/presets/PresetEditor.tsx
13329
13342
  const messageOf$4 = (failure) => failure instanceof Error ? failure.message : String(failure);
@@ -14381,8 +14394,8 @@ window.__ModuleLoader__.load({
14381
14394
  }
14382
14395
  tag$23.textContent = css$23;
14383
14396
  var Pager_module_css_default = {
14384
- "pager": "rp_KBAD0W_pager",
14385
- "position": "rp_KBAD0W_position"
14397
+ "position": "rp_KBAD0W_position",
14398
+ "pager": "rp_KBAD0W_pager"
14386
14399
  };
14387
14400
  // src/client/widgets/pager/Pager.tsx
14388
14401
  /** Previous and next buttons around the current position; the owner supplies every label. */
@@ -14451,10 +14464,10 @@ window.__ModuleLoader__.load({
14451
14464
  }
14452
14465
  tag$21.textContent = css$21;
14453
14466
  var DeleteSessionDialog_module_css_default = {
14467
+ "body": "rp_FifHrW_body",
14454
14468
  "question": "rp_FifHrW_question",
14455
14469
  "warning": "rp_FifHrW_warning",
14456
14470
  "choice": "rp_FifHrW_choice",
14457
- "body": "rp_FifHrW_body",
14458
14471
  "error": "rp_FifHrW_error"
14459
14472
  };
14460
14473
  // src/client/pages/sessions/DeleteSessionDialog.tsx
@@ -14528,443 +14541,108 @@ window.__ModuleLoader__.load({
14528
14541
  })
14529
14542
  });
14530
14543
  }
14531
- // src/client/paging/use-fit.ts
14532
- /**
14533
- * How many items fit in the element, measured whenever it resizes; 0 until
14534
- * measured. `compute` receives the content box and the element's styles, where
14535
- * item sizes live in custom properties so the stylesheet stays their only source.
14536
- * It must be a stable function.
14537
- */
14538
- function useFit(viewport, compute) {
14539
- const [fit, setFit] = (0, react.useState)(0);
14540
- (0, react.useLayoutEffect)(() => {
14541
- const element = viewport.current;
14542
- if (element === null) return;
14543
- const observer = new ResizeObserver(([entry]) => {
14544
- if (entry !== void 0) setFit(compute({
14545
- width: entry.contentRect.width,
14546
- height: entry.contentRect.height
14547
- }, getComputedStyle(element)));
14548
- });
14549
- observer.observe(element);
14550
- return () => {
14551
- observer.disconnect();
14552
- };
14553
- }, [viewport, compute]);
14554
- return fit;
14544
+ // src/client/pages/sessions/ExportSessionDialog.tsx
14545
+ const KINDS = [
14546
+ "story",
14547
+ "annotated",
14548
+ "data",
14549
+ "archive"
14550
+ ];
14551
+ /** Asks what to export of a session: the story to read, the story with its notes and every turn, the same as data, or the whole story to put back. */
14552
+ function ExportSessionDialog({ t, name, onExport, onCancel }) {
14553
+ const [kind, setKind] = (0, react.useState)("story");
14554
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
14555
+ open: true,
14556
+ onClose: onCancel,
14557
+ title: t("exportTitle"),
14558
+ closeLabel: t("close"),
14559
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14560
+ variant: "ghost",
14561
+ "data-modal-autofocus": true,
14562
+ onClick: onCancel,
14563
+ children: t("cancel")
14564
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14565
+ variant: "primary",
14566
+ onClick: () => {
14567
+ onExport(kind);
14568
+ },
14569
+ children: t("exportConfirm")
14570
+ })] }),
14571
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14572
+ className: DeleteSessionDialog_module_css_default.body,
14573
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14574
+ className: DeleteSessionDialog_module_css_default.question,
14575
+ children: t("exportQuestion", { name })
14576
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("fieldset", {
14577
+ className: DeleteSessionDialog_module_css_default.choice,
14578
+ children: KINDS.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [
14579
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
14580
+ type: "radio",
14581
+ name: "roleplay-export-kind",
14582
+ checked: kind === option,
14583
+ onChange: () => {
14584
+ setKind(option);
14585
+ }
14586
+ }),
14587
+ " ",
14588
+ t(`export_${option}`)
14589
+ ] }, option))
14590
+ })]
14591
+ })
14592
+ });
14555
14593
  }
14556
- /** A length custom property in pixels, or undefined when it is not set. */
14557
- function pixels(style, name) {
14558
- const value = Number.parseFloat(style.getPropertyValue(name));
14559
- return Number.isFinite(value) ? value : void 0;
14594
+ // src/shared/sync.ts
14595
+ const DEFAULT_SYNC = {
14596
+ remote: "",
14597
+ rclone: "",
14598
+ configFile: "",
14599
+ passwordRef: "",
14600
+ intervalMinutes: 0
14601
+ };
14602
+ const SYNC_PASSWORD_REF = "ROLEPLAY_SYNC_RCLONE_CONFIG_PASS";
14603
+ const SYNC_CHANGED = "roleplay-sync-changed";
14604
+ // src/client/sync-api.ts
14605
+ async function reply$1(response) {
14606
+ if (!response.ok) {
14607
+ const body = await response.json().catch(() => void 0);
14608
+ throw new Error(typeof body?.message === "string" ? body.message : `${response.status} ${response.statusText}`.trim());
14609
+ }
14610
+ return await response.json();
14560
14611
  }
14561
- // src/client/pages/sessions/row-layout.ts
14562
- /** How many whole rows fit under the header without scrolling. */
14563
- function rowsThatFit(box, { rowHeight, headerHeight }) {
14564
- return Math.max(0, Math.floor((box.height - headerHeight) / rowHeight));
14612
+ const json = (method, body) => ({
14613
+ method,
14614
+ credentials: "same-origin",
14615
+ headers: { "content-type": "application/json" },
14616
+ body: JSON.stringify(body)
14617
+ });
14618
+ async function loadSyncStatus(signal) {
14619
+ return await reply$1(await fetch(`${API_PREFIX}/sync/status`, {
14620
+ credentials: "same-origin",
14621
+ signal
14622
+ }));
14565
14623
  }
14566
- // src/client/pages/sessions/use-row-fit.ts
14567
- function rowFit(box, style) {
14568
- const rowHeight = pixels(style, "--rp-row-height");
14569
- const headerHeight = pixels(style, "--rp-header-height");
14570
- return rowHeight === void 0 || headerHeight === void 0 ? 0 : rowsThatFit(box, {
14571
- rowHeight,
14572
- headerHeight
14573
- });
14624
+ /** Syncs every unit, or only the named ones; resolves when the run is over. */
14625
+ async function runSync(units, signal) {
14626
+ return await reply$1(await fetch(`${API_PREFIX}/sync/run`, {
14627
+ ...json("POST", units === void 0 ? {} : { units }),
14628
+ signal
14629
+ }));
14574
14630
  }
14575
- /** Number of table rows that fit in the element without scrolling; 0 until measured. */
14576
- function useRowFit(viewport) {
14577
- return useFit(viewport, rowFit);
14631
+ async function resolveSync(unit, side, signal) {
14632
+ return await reply$1(await fetch(`${API_PREFIX}/sync/resolve`, {
14633
+ ...json("POST", {
14634
+ unit,
14635
+ side
14636
+ }),
14637
+ signal
14638
+ }));
14578
14639
  }
14579
- // \0css-module:/home/runner/work/dsh-agentic-roleplay/dsh-agentic-roleplay/packages/dsh-agentic-roleplay-core/src/client/pages/sessions/SessionsPage.module.css.mjs
14580
- const css$20 = ".rp_24z4eW_page{flex-direction:column;flex:1 1 0;gap:8px;min-height:0;display:flex}.rp_24z4eW_toolbar{flex:none;justify-content:space-between;align-items:center;gap:12px;min-height:28px;display:flex}.rp_24z4eW_count{color:var(--dsw-alias-label-tertiary);font-size:12px}.rp_24z4eW_spinning{animation:.9s linear infinite rp_24z4eW_spin}@keyframes rp_24z4eW_spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.rp_24z4eW_spinning{animation:none}}.rp_24z4eW_notice{color:var(--dsw-alias-state-error-primary);margin:0;font-size:12px}.rp_24z4eW_viewport{--rp-row-height:40px;--rp-header-height:32px;flex:1 1 0;min-height:0;overflow-x:auto}.rp_24z4eW_scrolls{overflow-y:auto}.rp_24z4eW_fits{overflow-y:hidden}.rp_24z4eW_table{border-collapse:collapse;table-layout:fixed;width:100%;min-width:720px}.rp_24z4eW_actionsColumn{width:104px}.rp_24z4eW_nameColumn{width:30%}.rp_24z4eW_worldColumn{width:26%}.rp_24z4eW_timeColumn{width:16%}.rp_24z4eW_turnsColumn{width:10%}.rp_24z4eW_table th{height:var(--rp-header-height);border-bottom:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);text-align:left;color:var(--dsw-alias-label-tertiary);padding:0 12px;font-size:12px;font-weight:400;position:sticky;top:0}.rp_24z4eW_table td{height:var(--rp-row-height);border-bottom:.5px solid var(--dsw-alias-border-l1);text-overflow:ellipsis;white-space:nowrap;padding:0 12px;font-size:13px;overflow:hidden}.rp_24z4eW_name{color:var(--dsw-alias-label-primary);font-weight:500}.rp_24z4eW_secondary{color:var(--dsw-alias-label-secondary);font-size:12px}.rp_24z4eW_table .rp_24z4eW_number{text-align:right}.rp_24z4eW_table .rp_24z4eW_actions{text-align:center;white-space:nowrap;padding:0 8px}.rp_24z4eW_message{text-align:center;color:var(--dsw-alias-label-secondary);margin:0;padding:40px 0;font-size:13px}.rp_24z4eW_archived td{opacity:.6}.rp_24z4eW_badge{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);margin-left:6px;padding:0 6px;font-size:12px}@media (width<=640px){.rp_24z4eW_viewport{--rp-row-height:196px;--rp-header-height:0px;overflow-x:hidden}.rp_24z4eW_table,.rp_24z4eW_table tbody,.rp_24z4eW_table tr,.rp_24z4eW_table td{width:100%;display:block}.rp_24z4eW_table{min-width:0}.rp_24z4eW_table colgroup,.rp_24z4eW_table thead{display:none}.rp_24z4eW_table tr{box-sizing:border-box;min-height:var(--rp-row-height);border-bottom:.5px solid var(--dsw-alias-border-l2);padding:10px 12px}.rp_24z4eW_table td{box-sizing:border-box;text-align:start;text-overflow:clip;white-space:normal;overflow-wrap:anywhere;border:0;grid-template-columns:minmax(88px,34%) minmax(0,1fr);align-items:baseline;height:auto;min-height:24px;padding:2px 0;display:grid;overflow:visible}.rp_24z4eW_table td:before{content:attr(data-label);color:var(--dsw-alias-label-tertiary);padding-inline-end:10px;font-size:12px;font-weight:400}.rp_24z4eW_table .rp_24z4eW_number{text-align:start}.rp_24z4eW_table .rp_24z4eW_actions{justify-content:flex-end;min-height:36px;padding-top:4px;display:flex}.rp_24z4eW_table .rp_24z4eW_actions:before{margin-inline-end:auto}}";
14581
- const key$20 = "src/client/pages/sessions/SessionsPage.module.css";
14582
- let tag$20 = document.querySelector("style[data-plugin-css=" + JSON.stringify(key$20) + "]");
14583
- if (tag$20 === null) {
14584
- tag$20 = document.createElement("style");
14585
- tag$20.dataset.plugin = "@dsh-agentic-roleplay/core";
14586
- tag$20.dataset.pluginCss = key$20;
14587
- document.head.appendChild(tag$20);
14588
- }
14589
- tag$20.textContent = css$20;
14590
- var SessionsPage_module_css_default = {
14591
- "actions": "rp_24z4eW_actions",
14592
- "count": "rp_24z4eW_count",
14593
- "spinning": "rp_24z4eW_spinning",
14594
- "viewport": "rp_24z4eW_viewport",
14595
- "number": "rp_24z4eW_number",
14596
- "table": "rp_24z4eW_table",
14597
- "page": "rp_24z4eW_page",
14598
- "actionsColumn": "rp_24z4eW_actionsColumn",
14599
- "spin": "rp_24z4eW_spin",
14600
- "message": "rp_24z4eW_message",
14601
- "nameColumn": "rp_24z4eW_nameColumn",
14602
- "notice": "rp_24z4eW_notice",
14603
- "badge": "rp_24z4eW_badge",
14604
- "timeColumn": "rp_24z4eW_timeColumn",
14605
- "toolbar": "rp_24z4eW_toolbar",
14606
- "fits": "rp_24z4eW_fits",
14607
- "worldColumn": "rp_24z4eW_worldColumn",
14608
- "archived": "rp_24z4eW_archived",
14609
- "turnsColumn": "rp_24z4eW_turnsColumn",
14610
- "secondary": "rp_24z4eW_secondary",
14611
- "name": "rp_24z4eW_name",
14612
- "scrolls": "rp_24z4eW_scrolls"
14613
- };
14614
- // src/client/pages/sessions/SessionsPage.tsx
14615
- /** The sessions as a table, one page at a time, the most recently played first. */
14616
- function SessionsPage({ t, useRoleplaySessions, load, refresh, open, archive, restore, askRemoval, cancelRemoval, confirmRemoval, setEverywhere }) {
14617
- const state = useRoleplaySessions((snapshot) => snapshot);
14618
- const viewport = (0, react.useRef)(null);
14619
- const { pageSize, scrolls } = pagingFor(useRowFit(viewport));
14620
- const [requestedStart, setRequestedStart] = (0, react.useState)(0);
14621
- const dateLocale = t("dateLocale");
14622
- const dateTime = (0, react.useMemo)(() => new Intl.DateTimeFormat(dateLocale, {
14623
- dateStyle: "medium",
14624
- timeStyle: "short"
14625
- }), [dateLocale]);
14626
- (0, react.useEffect)(() => {
14627
- load();
14628
- }, [load]);
14629
- const sessions = state.payload?.sessions ?? [];
14630
- const start = pageStart(requestedStart, sessions.length, pageSize);
14631
- const pages = pageCount(sessions.length, pageSize);
14632
- const visible = sessions.slice(start, start + pageSize);
14633
- (0, react.useEffect)(() => {
14634
- viewport.current?.scrollTo({ top: 0 });
14635
- }, [start]);
14636
- const count = t(sessions.length === 1 ? "countOne" : "countOther", { count: sessions.length });
14637
- const failedWithoutData = state.status === "failed" && state.payload === void 0;
14638
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14639
- className: SessionsPage_module_css_default.page,
14640
- "data-testid": "roleplay-sessions-page",
14641
- children: [
14642
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14643
- className: SessionsPage_module_css_default.toolbar,
14644
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14645
- className: SessionsPage_module_css_default.count,
14646
- children: state.payload === void 0 ? "" : count
14647
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14648
- variant: "outline",
14649
- size: "sm",
14650
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { className: state.refreshing ? SessionsPage_module_css_default.spinning : void 0 }),
14651
- disabled: state.refreshing || state.status === "loading",
14652
- "aria-busy": state.refreshing,
14653
- onClick: refresh,
14654
- children: state.refreshing ? t("refreshing") : t("refresh")
14655
- })]
14656
- }),
14657
- state.error !== void 0 && !failedWithoutData && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14658
- className: SessionsPage_module_css_default.notice,
14659
- role: "alert",
14660
- children: t("loadFailed", { message: state.error })
14661
- }),
14662
- state.moveError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14663
- className: SessionsPage_module_css_default.notice,
14664
- role: "alert",
14665
- children: t("moveFailed", { message: state.moveError })
14666
- }),
14667
- state.openError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14668
- className: SessionsPage_module_css_default.notice,
14669
- role: "alert",
14670
- children: t("openFailed", { message: state.openError })
14671
- }),
14672
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProblemList, {
14673
- summary: t("problems", { count: state.payload?.problems.length ?? 0 }),
14674
- problems: state.payload?.problems ?? []
14675
- }),
14676
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14677
- ref: viewport,
14678
- className: `${SessionsPage_module_css_default.viewport} ${scrolls ? SessionsPage_module_css_default.scrolls : SessionsPage_module_css_default.fits}`,
14679
- children: state.status === "loading" || state.status === "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14680
- className: SessionsPage_module_css_default.message,
14681
- children: t("loading")
14682
- }) : failedWithoutData ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14683
- className: SessionsPage_module_css_default.message,
14684
- role: "alert",
14685
- children: t("loadFailed", { message: state.error ?? "" })
14686
- }) : sessions.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14687
- className: SessionsPage_module_css_default.message,
14688
- children: t("empty")
14689
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
14690
- className: SessionsPage_module_css_default.table,
14691
- children: [
14692
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("colgroup", { children: [
14693
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.nameColumn }),
14694
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.worldColumn }),
14695
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.timeColumn }),
14696
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.timeColumn }),
14697
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.turnsColumn }),
14698
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.actionsColumn })
14699
- ] }),
14700
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
14701
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
14702
- scope: "col",
14703
- children: t("columnName")
14704
- }),
14705
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
14706
- scope: "col",
14707
- children: t("columnWorld")
14708
- }),
14709
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
14710
- scope: "col",
14711
- children: t("columnCreated")
14712
- }),
14713
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
14714
- scope: "col",
14715
- children: t("columnLastPlayed")
14716
- }),
14717
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
14718
- scope: "col",
14719
- className: SessionsPage_module_css_default.number,
14720
- children: t("columnTurns")
14721
- }),
14722
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
14723
- scope: "col",
14724
- className: SessionsPage_module_css_default.actions,
14725
- children: t("columnActions")
14726
- })
14727
- ] }) }),
14728
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: visible.map((session) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
14729
- "data-testid": "session-row",
14730
- className: session.archivedAt === void 0 ? void 0 : SessionsPage_module_css_default.archived,
14731
- children: [
14732
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
14733
- className: SessionsPage_module_css_default.name,
14734
- "data-label": t("columnName"),
14735
- title: session.name,
14736
- children: [session.name, session.archivedAt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14737
- className: SessionsPage_module_css_default.badge,
14738
- children: t("archived")
14739
- })]
14740
- }),
14741
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
14742
- className: SessionsPage_module_css_default.secondary,
14743
- "data-label": t("columnWorld"),
14744
- title: session.worldName,
14745
- children: session.worldName
14746
- }),
14747
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
14748
- className: SessionsPage_module_css_default.secondary,
14749
- "data-label": t("columnCreated"),
14750
- children: dateTime.format(new Date(session.createdAt))
14751
- }),
14752
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
14753
- className: SessionsPage_module_css_default.secondary,
14754
- "data-label": t("columnLastPlayed"),
14755
- children: session.lastPlayedAt === void 0 ? t("neverPlayed") : dateTime.format(new Date(session.lastPlayedAt))
14756
- }),
14757
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
14758
- className: `${SessionsPage_module_css_default.secondary} ${SessionsPage_module_css_default.number}`,
14759
- "data-label": t("columnTurns"),
14760
- children: session.turns
14761
- }),
14762
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
14763
- className: SessionsPage_module_css_default.actions,
14764
- "data-label": t("columnActions"),
14765
- children: [
14766
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14767
- variant: "ghost",
14768
- size: "sm",
14769
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlayOutlineRegular, {}),
14770
- "aria-label": t("open"),
14771
- title: t("open"),
14772
- disabled: state.opening !== void 0 || session.archivedAt !== void 0,
14773
- onClick: () => {
14774
- open(session.id);
14775
- }
14776
- }),
14777
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14778
- variant: "ghost",
14779
- size: "sm",
14780
- icon: session.archivedAt === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconArchiveOutlineRegular, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconArchiveOffOutlineRegular, {}),
14781
- "aria-label": session.archivedAt === void 0 ? t("archive") : t("restore"),
14782
- title: session.archivedAt === void 0 ? t("archive") : t("restore"),
14783
- disabled: state.moving !== void 0,
14784
- onClick: () => {
14785
- if (session.archivedAt === void 0) archive(session.id);
14786
- else restore(session.id);
14787
- }
14788
- }),
14789
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
14790
- variant: "ghost",
14791
- size: "sm",
14792
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutlineRegular, {}),
14793
- "aria-label": t("delete"),
14794
- title: t("delete"),
14795
- onClick: () => {
14796
- askRemoval(session.id, session.name);
14797
- }
14798
- })
14799
- ]
14800
- })
14801
- ]
14802
- }, session.id)) })
14803
- ]
14804
- })
14805
- }),
14806
- pages > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pager, {
14807
- label: t("nav"),
14808
- previousLabel: t("previousPage"),
14809
- nextLabel: t("nextPage"),
14810
- positionLabel: t("pageOf", {
14811
- page: start / pageSize + 1,
14812
- pages
14813
- }),
14814
- hasPrevious: start > 0,
14815
- hasNext: start + pageSize < sessions.length,
14816
- onPrevious: () => {
14817
- setRequestedStart(start - pageSize);
14818
- },
14819
- onNext: () => {
14820
- setRequestedStart(start + pageSize);
14821
- }
14822
- }),
14823
- state.removal !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DeleteSessionDialog, {
14824
- t,
14825
- removal: state.removal,
14826
- onConfirm: confirmRemoval,
14827
- onCancel: cancelRemoval,
14828
- onEverywhere: setEverywhere
14829
- }, state.removal.id)
14830
- ]
14831
- });
14832
- }
14833
- // src/client/pages/sessions/locales.ts
14834
- const dictionaries$11 = {
14835
- en: {
14836
- nav: "Sessions",
14837
- loading: "Loading sessions…",
14838
- loadFailed: "Could not load sessions: {message}",
14839
- empty: "No sessions yet. Press play on a world to start one.",
14840
- countOne: "{count} session",
14841
- countOther: "{count} sessions",
14842
- refresh: "Refresh",
14843
- refreshing: "Refreshing…",
14844
- previousPage: "Previous page",
14845
- nextPage: "Next page",
14846
- pageOf: "Page {page} of {pages}",
14847
- problems: "{count} session(s) could not be read",
14848
- columnName: "Name",
14849
- columnWorld: "World",
14850
- columnCreated: "Created",
14851
- columnLastPlayed: "Last played",
14852
- columnTurns: "Turns",
14853
- columnActions: "Actions",
14854
- archive: "Put the session away",
14855
- restore: "Bring the session back",
14856
- archived: "Away",
14857
- moveFailed: "Could not put the session away or bring it back: {message}",
14858
- open: "Open the chat",
14859
- openFailed: "Could not open the chat: {message}",
14860
- delete: "Delete session",
14861
- deleteTitle: "Delete session",
14862
- deleteQuestion: "Delete the session \"{name}\"?",
14863
- deleteWarning: "Its characters, state and everything else saved with it are removed permanently.",
14864
- deleteConfirm: "Delete",
14865
- deleteScope: "Where to delete it",
14866
- deleteHere: "Delete it on this device only. It stays on the remote and is not synced back until you restore it on the Sync page.",
14867
- deleteEverywhere: "Delete it on the remote too. Every device that syncs deletes its copy.",
14868
- deleting: "Deleting…",
14869
- deleteFailed: "Could not delete the session: {message}",
14870
- cancel: "Cancel",
14871
- close: "Close",
14872
- neverPlayed: "Never",
14873
- dateLocale: "en-GB"
14874
- },
14875
- zh: {
14876
- nav: "存档",
14877
- loading: "正在加载存档…",
14878
- loadFailed: "无法加载存档:{message}",
14879
- empty: "还没有存档。请在世界卡上点击开始。",
14880
- countOne: "{count} 个存档",
14881
- countOther: "{count} 个存档",
14882
- refresh: "刷新",
14883
- refreshing: "刷新中…",
14884
- previousPage: "上一页",
14885
- nextPage: "下一页",
14886
- pageOf: "第 {page} 页,共 {pages} 页",
14887
- problems: "{count} 个存档无法读取",
14888
- columnName: "名称",
14889
- columnWorld: "世界卡",
14890
- columnCreated: "创建时间",
14891
- columnLastPlayed: "上次游玩",
14892
- columnTurns: "回合数",
14893
- columnActions: "操作",
14894
- archive: "归档存档",
14895
- restore: "恢复存档",
14896
- archived: "已归档",
14897
- moveFailed: "无法归档或恢复该存档:{message}",
14898
- open: "打开对话",
14899
- openFailed: "无法打开对话:{message}",
14900
- delete: "删除存档",
14901
- deleteTitle: "删除存档",
14902
- deleteQuestion: "删除存档“{name}”?",
14903
- deleteWarning: "存档中的角色、状态及所有已保存的内容将被永久删除。",
14904
- deleteConfirm: "删除",
14905
- deleteScope: "删除范围",
14906
- deleteHere: "只在本机删除。远端仍保留,在“同步”页恢复之前不会同步回来。",
14907
- deleteEverywhere: "同时从远端删除。其他设备下次同步时也会删除它们的副本。",
14908
- deleting: "正在删除…",
14909
- deleteFailed: "无法删除存档:{message}",
14910
- cancel: "取消",
14911
- close: "关闭",
14912
- neverPlayed: "从未",
14913
- dateLocale: "zh-CN"
14914
- }
14915
- };
14916
- // src/shared/sync.ts
14917
- const DEFAULT_SYNC = {
14918
- remote: "",
14919
- rclone: "",
14920
- configFile: "",
14921
- passwordRef: "",
14922
- intervalMinutes: 0
14923
- };
14924
- const SYNC_PASSWORD_REF = "ROLEPLAY_SYNC_RCLONE_CONFIG_PASS";
14925
- const SYNC_CHANGED = "roleplay-sync-changed";
14926
- // src/client/sync-api.ts
14927
- async function reply$1(response) {
14928
- if (!response.ok) {
14929
- const body = await response.json().catch(() => void 0);
14930
- throw new Error(typeof body?.message === "string" ? body.message : `${response.status} ${response.statusText}`.trim());
14931
- }
14932
- return await response.json();
14933
- }
14934
- const json = (method, body) => ({
14935
- method,
14936
- credentials: "same-origin",
14937
- headers: { "content-type": "application/json" },
14938
- body: JSON.stringify(body)
14939
- });
14940
- async function loadSyncStatus(signal) {
14941
- return await reply$1(await fetch(`${API_PREFIX}/sync/status`, {
14942
- credentials: "same-origin",
14943
- signal
14944
- }));
14945
- }
14946
- /** Syncs every unit, or only the named ones; resolves when the run is over. */
14947
- async function runSync(units, signal) {
14948
- return await reply$1(await fetch(`${API_PREFIX}/sync/run`, {
14949
- ...json("POST", units === void 0 ? {} : { units }),
14950
- signal
14951
- }));
14952
- }
14953
- async function resolveSync(unit, side, signal) {
14954
- return await reply$1(await fetch(`${API_PREFIX}/sync/resolve`, {
14955
- ...json("POST", {
14956
- unit,
14957
- side
14958
- }),
14959
- signal
14960
- }));
14961
- }
14962
- /** Stops syncing a unit that was deleted here; the remote's copy stays and is not brought back until `restoreSync`. */
14963
- async function forgetSync(unit, signal) {
14964
- await reply$1(await fetch(`${API_PREFIX}/sync/forget`, {
14965
- ...json("POST", { unit }),
14966
- signal
14967
- }));
14640
+ /** Stops syncing a unit that was deleted here; the remote's copy stays and is not brought back until `restoreSync`. */
14641
+ async function forgetSync(unit, signal) {
14642
+ await reply$1(await fetch(`${API_PREFIX}/sync/forget`, {
14643
+ ...json("POST", { unit }),
14644
+ signal
14645
+ }));
14968
14646
  }
14969
14647
  /** Lets a unit that was forgotten sync again, which brings the remote's copy back on the next run. */
14970
14648
  async function restoreSync(unit, signal) {
@@ -14992,6 +14670,15 @@ window.__ModuleLoader__.load({
14992
14670
  return status;
14993
14671
  }
14994
14672
  // src/client/pages/sessions/sessions-controller.ts
14673
+ /** The address that sends an export as a file. */
14674
+ function exportAddress(id, kind) {
14675
+ return `${API_PREFIX}/sessions/export?id=${encodeURIComponent(id)}&${{
14676
+ story: "format=markdown&scope=path",
14677
+ annotated: "format=markdown&scope=all&annotated=1",
14678
+ data: "format=json&scope=all&annotated=1",
14679
+ archive: "format=archive"
14680
+ }[kind]}`;
14681
+ }
14995
14682
  /** Reads the sessions list from the host. */
14996
14683
  var SessionsController = class {
14997
14684
  store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
@@ -15017,6 +14704,22 @@ window.__ModuleLoader__.load({
15017
14704
  restore: (id) => {
15018
14705
  this.move(id, "restore");
15019
14706
  },
14707
+ askExport: (id, name) => {
14708
+ this.store.update((draft) => {
14709
+ draft.exporting = {
14710
+ id,
14711
+ name
14712
+ };
14713
+ });
14714
+ },
14715
+ closeExport: () => {
14716
+ this.store.update((draft) => {
14717
+ delete draft.exporting;
14718
+ });
14719
+ },
14720
+ importArchive: (file) => {
14721
+ this.importArchive(file);
14722
+ },
15020
14723
  askRemoval: (id, name) => {
15021
14724
  this.store.update((draft) => {
15022
14725
  draft.removal = {
@@ -15106,6 +14809,45 @@ window.__ModuleLoader__.load({
15106
14809
  });
15107
14810
  }
15108
14811
  }
14812
+ /** Puts an archived story back as a new session; the list is read again. */
14813
+ async importArchive(file) {
14814
+ if (this.store.getSnapshot().importing === true) return;
14815
+ this.store.update((draft) => {
14816
+ draft.importing = true;
14817
+ delete draft.importError;
14818
+ delete draft.imported;
14819
+ });
14820
+ try {
14821
+ const response = await fetch(`${API_PREFIX}/sessions/import`, {
14822
+ method: "POST",
14823
+ credentials: "same-origin",
14824
+ headers: { "content-type": "application/zip" },
14825
+ body: file,
14826
+ signal: this.abort.signal
14827
+ });
14828
+ if (!response.ok) {
14829
+ const body = await response.json().catch(() => void 0);
14830
+ throw new Error(typeof body?.message === "string" ? body.message : `${response.status} ${response.statusText}`.trim());
14831
+ }
14832
+ const made = await response.json();
14833
+ this.store.update((draft) => {
14834
+ draft.imported = {
14835
+ name: made.name,
14836
+ worldAdded: made.worldAdded
14837
+ };
14838
+ });
14839
+ await this.read(true);
14840
+ } catch (error) {
14841
+ if (this.abort.signal.aborted) return;
14842
+ this.store.update((draft) => {
14843
+ draft.importError = error instanceof Error ? error.message : String(error);
14844
+ });
14845
+ } finally {
14846
+ if (!this.abort.signal.aborted) this.store.update((draft) => {
14847
+ delete draft.importing;
14848
+ });
14849
+ }
14850
+ }
15109
14851
  /** Only when sync works is there a remote to delete from; if its state cannot be read the dialog offers no remote deletion, and the delete itself reports its own failures. */
15110
14852
  async offerSync(id) {
15111
14853
  try {
@@ -15190,6 +14932,477 @@ window.__ModuleLoader__.load({
15190
14932
  }
15191
14933
  }
15192
14934
  };
14935
+ // src/client/paging/use-fit.ts
14936
+ /**
14937
+ * How many items fit in the element, measured whenever it resizes; 0 until
14938
+ * measured. `compute` receives the content box and the element's styles, where
14939
+ * item sizes live in custom properties so the stylesheet stays their only source.
14940
+ * It must be a stable function.
14941
+ */
14942
+ function useFit(viewport, compute) {
14943
+ const [fit, setFit] = (0, react.useState)(0);
14944
+ (0, react.useLayoutEffect)(() => {
14945
+ const element = viewport.current;
14946
+ if (element === null) return;
14947
+ const observer = new ResizeObserver(([entry]) => {
14948
+ if (entry !== void 0) setFit(compute({
14949
+ width: entry.contentRect.width,
14950
+ height: entry.contentRect.height
14951
+ }, getComputedStyle(element)));
14952
+ });
14953
+ observer.observe(element);
14954
+ return () => {
14955
+ observer.disconnect();
14956
+ };
14957
+ }, [viewport, compute]);
14958
+ return fit;
14959
+ }
14960
+ /** A length custom property in pixels, or undefined when it is not set. */
14961
+ function pixels(style, name) {
14962
+ const value = Number.parseFloat(style.getPropertyValue(name));
14963
+ return Number.isFinite(value) ? value : void 0;
14964
+ }
14965
+ // src/client/pages/sessions/row-layout.ts
14966
+ /** How many whole rows fit under the header without scrolling. */
14967
+ function rowsThatFit(box, { rowHeight, headerHeight }) {
14968
+ return Math.max(0, Math.floor((box.height - headerHeight) / rowHeight));
14969
+ }
14970
+ // src/client/pages/sessions/use-row-fit.ts
14971
+ function rowFit(box, style) {
14972
+ const rowHeight = pixels(style, "--rp-row-height");
14973
+ const headerHeight = pixels(style, "--rp-header-height");
14974
+ return rowHeight === void 0 || headerHeight === void 0 ? 0 : rowsThatFit(box, {
14975
+ rowHeight,
14976
+ headerHeight
14977
+ });
14978
+ }
14979
+ /** Number of table rows that fit in the element without scrolling; 0 until measured. */
14980
+ function useRowFit(viewport) {
14981
+ return useFit(viewport, rowFit);
14982
+ }
14983
+ // \0css-module:/home/runner/work/dsh-agentic-roleplay/dsh-agentic-roleplay/packages/dsh-agentic-roleplay-core/src/client/pages/sessions/SessionsPage.module.css.mjs
14984
+ const css$20 = ".rp_24z4eW_page{flex-direction:column;flex:1 1 0;gap:8px;min-height:0;display:flex}.rp_24z4eW_toolbar{flex:none;justify-content:space-between;align-items:center;gap:12px;min-height:28px;display:flex}.rp_24z4eW_count{color:var(--dsw-alias-label-tertiary);font-size:12px}.rp_24z4eW_spinning{animation:.9s linear infinite rp_24z4eW_spin}@keyframes rp_24z4eW_spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.rp_24z4eW_spinning{animation:none}}.rp_24z4eW_notice{color:var(--dsw-alias-state-error-primary);margin:0;font-size:12px}.rp_24z4eW_viewport{--rp-row-height:40px;--rp-header-height:32px;flex:1 1 0;min-height:0;overflow-x:auto}.rp_24z4eW_scrolls{overflow-y:auto}.rp_24z4eW_fits{overflow-y:hidden}.rp_24z4eW_table{border-collapse:collapse;table-layout:fixed;width:100%;min-width:720px}.rp_24z4eW_actionsColumn{width:104px}.rp_24z4eW_nameColumn{width:30%}.rp_24z4eW_worldColumn{width:26%}.rp_24z4eW_timeColumn{width:16%}.rp_24z4eW_turnsColumn{width:10%}.rp_24z4eW_table th{height:var(--rp-header-height);border-bottom:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);text-align:left;color:var(--dsw-alias-label-tertiary);padding:0 12px;font-size:12px;font-weight:400;position:sticky;top:0}.rp_24z4eW_table td{height:var(--rp-row-height);border-bottom:.5px solid var(--dsw-alias-border-l1);text-overflow:ellipsis;white-space:nowrap;padding:0 12px;font-size:13px;overflow:hidden}.rp_24z4eW_name{color:var(--dsw-alias-label-primary);font-weight:500}.rp_24z4eW_secondary{color:var(--dsw-alias-label-secondary);font-size:12px}.rp_24z4eW_table .rp_24z4eW_number{text-align:right}.rp_24z4eW_table .rp_24z4eW_actions{text-align:center;white-space:nowrap;padding:0 8px}.rp_24z4eW_message{text-align:center;color:var(--dsw-alias-label-secondary);margin:0;padding:40px 0;font-size:13px}.rp_24z4eW_archived td{opacity:.6}.rp_24z4eW_badge{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);margin-left:6px;padding:0 6px;font-size:12px}@media (width<=640px){.rp_24z4eW_viewport{--rp-row-height:196px;--rp-header-height:0px;overflow-x:hidden}.rp_24z4eW_table,.rp_24z4eW_table tbody,.rp_24z4eW_table tr,.rp_24z4eW_table td{width:100%;display:block}.rp_24z4eW_table{min-width:0}.rp_24z4eW_table colgroup,.rp_24z4eW_table thead{display:none}.rp_24z4eW_table tr{box-sizing:border-box;min-height:var(--rp-row-height);border-bottom:.5px solid var(--dsw-alias-border-l2);padding:10px 12px}.rp_24z4eW_table td{box-sizing:border-box;text-align:start;text-overflow:clip;white-space:normal;overflow-wrap:anywhere;border:0;grid-template-columns:minmax(88px,34%) minmax(0,1fr);align-items:baseline;height:auto;min-height:24px;padding:2px 0;display:grid;overflow:visible}.rp_24z4eW_table td:before{content:attr(data-label);color:var(--dsw-alias-label-tertiary);padding-inline-end:10px;font-size:12px;font-weight:400}.rp_24z4eW_table .rp_24z4eW_number{text-align:start}.rp_24z4eW_table .rp_24z4eW_actions{justify-content:flex-end;min-height:36px;padding-top:4px;display:flex}.rp_24z4eW_table .rp_24z4eW_actions:before{margin-inline-end:auto}}";
14985
+ const key$20 = "src/client/pages/sessions/SessionsPage.module.css";
14986
+ let tag$20 = document.querySelector("style[data-plugin-css=" + JSON.stringify(key$20) + "]");
14987
+ if (tag$20 === null) {
14988
+ tag$20 = document.createElement("style");
14989
+ tag$20.dataset.plugin = "@dsh-agentic-roleplay/core";
14990
+ tag$20.dataset.pluginCss = key$20;
14991
+ document.head.appendChild(tag$20);
14992
+ }
14993
+ tag$20.textContent = css$20;
14994
+ var SessionsPage_module_css_default = {
14995
+ "fits": "rp_24z4eW_fits",
14996
+ "spinning": "rp_24z4eW_spinning",
14997
+ "actionsColumn": "rp_24z4eW_actionsColumn",
14998
+ "nameColumn": "rp_24z4eW_nameColumn",
14999
+ "message": "rp_24z4eW_message",
15000
+ "secondary": "rp_24z4eW_secondary",
15001
+ "viewport": "rp_24z4eW_viewport",
15002
+ "turnsColumn": "rp_24z4eW_turnsColumn",
15003
+ "spin": "rp_24z4eW_spin",
15004
+ "worldColumn": "rp_24z4eW_worldColumn",
15005
+ "timeColumn": "rp_24z4eW_timeColumn",
15006
+ "scrolls": "rp_24z4eW_scrolls",
15007
+ "count": "rp_24z4eW_count",
15008
+ "name": "rp_24z4eW_name",
15009
+ "actions": "rp_24z4eW_actions",
15010
+ "number": "rp_24z4eW_number",
15011
+ "archived": "rp_24z4eW_archived",
15012
+ "page": "rp_24z4eW_page",
15013
+ "badge": "rp_24z4eW_badge",
15014
+ "notice": "rp_24z4eW_notice",
15015
+ "table": "rp_24z4eW_table",
15016
+ "toolbar": "rp_24z4eW_toolbar"
15017
+ };
15018
+ // src/client/pages/sessions/SessionsPage.tsx
15019
+ /** The sessions as a table, one page at a time, the most recently played first. */
15020
+ function SessionsPage({ t, useRoleplaySessions, load, refresh, open, archive, restore, askExport, closeExport, importArchive, askRemoval, cancelRemoval, confirmRemoval, setEverywhere }) {
15021
+ const state = useRoleplaySessions((snapshot) => snapshot);
15022
+ const viewport = (0, react.useRef)(null);
15023
+ const picker = (0, react.useRef)(null);
15024
+ const { pageSize, scrolls } = pagingFor(useRowFit(viewport));
15025
+ const [requestedStart, setRequestedStart] = (0, react.useState)(0);
15026
+ const dateLocale = t("dateLocale");
15027
+ const dateTime = (0, react.useMemo)(() => new Intl.DateTimeFormat(dateLocale, {
15028
+ dateStyle: "medium",
15029
+ timeStyle: "short"
15030
+ }), [dateLocale]);
15031
+ (0, react.useEffect)(() => {
15032
+ load();
15033
+ }, [load]);
15034
+ const sessions = state.payload?.sessions ?? [];
15035
+ const start = pageStart(requestedStart, sessions.length, pageSize);
15036
+ const pages = pageCount(sessions.length, pageSize);
15037
+ const visible = sessions.slice(start, start + pageSize);
15038
+ (0, react.useEffect)(() => {
15039
+ viewport.current?.scrollTo({ top: 0 });
15040
+ }, [start]);
15041
+ /** The host sends the file as a download, which the browser keeps. */
15042
+ const download = (kind) => {
15043
+ if (state.exporting === void 0) return;
15044
+ const link = document.createElement("a");
15045
+ link.href = exportAddress(state.exporting.id, kind);
15046
+ link.rel = "noopener";
15047
+ link.click();
15048
+ closeExport();
15049
+ };
15050
+ const count = t(sessions.length === 1 ? "countOne" : "countOther", { count: sessions.length });
15051
+ const failedWithoutData = state.status === "failed" && state.payload === void 0;
15052
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
15053
+ className: SessionsPage_module_css_default.page,
15054
+ "data-testid": "roleplay-sessions-page",
15055
+ children: [
15056
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
15057
+ className: SessionsPage_module_css_default.toolbar,
15058
+ children: [
15059
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
15060
+ className: SessionsPage_module_css_default.count,
15061
+ children: state.payload === void 0 ? "" : count
15062
+ }),
15063
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
15064
+ ref: picker,
15065
+ type: "file",
15066
+ accept: ".zip,application/zip",
15067
+ hidden: true,
15068
+ onChange: (event) => {
15069
+ const file = event.target.files?.[0];
15070
+ event.target.value = "";
15071
+ if (file !== void 0) importArchive(file);
15072
+ }
15073
+ }),
15074
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15075
+ variant: "outline",
15076
+ size: "sm",
15077
+ disabled: state.importing === true,
15078
+ "aria-busy": state.importing === true,
15079
+ onClick: () => {
15080
+ picker.current?.click();
15081
+ },
15082
+ children: state.importing === true ? t("importing") : t("importStory")
15083
+ }),
15084
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15085
+ variant: "outline",
15086
+ size: "sm",
15087
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { className: state.refreshing ? SessionsPage_module_css_default.spinning : void 0 }),
15088
+ disabled: state.refreshing || state.status === "loading",
15089
+ "aria-busy": state.refreshing,
15090
+ onClick: refresh,
15091
+ children: state.refreshing ? t("refreshing") : t("refresh")
15092
+ })
15093
+ ]
15094
+ }),
15095
+ state.error !== void 0 && !failedWithoutData && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15096
+ className: SessionsPage_module_css_default.notice,
15097
+ role: "alert",
15098
+ children: t("loadFailed", { message: state.error })
15099
+ }),
15100
+ state.moveError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15101
+ className: SessionsPage_module_css_default.notice,
15102
+ role: "alert",
15103
+ children: t("moveFailed", { message: state.moveError })
15104
+ }),
15105
+ state.importError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15106
+ className: SessionsPage_module_css_default.notice,
15107
+ role: "alert",
15108
+ children: t("importFailed", { message: state.importError })
15109
+ }),
15110
+ state.imported !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15111
+ className: SessionsPage_module_css_default.notice,
15112
+ role: "status",
15113
+ children: t(state.imported.worldAdded ? "importedWithWorld" : "imported", { name: state.imported.name })
15114
+ }),
15115
+ state.openError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15116
+ className: SessionsPage_module_css_default.notice,
15117
+ role: "alert",
15118
+ children: t("openFailed", { message: state.openError })
15119
+ }),
15120
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProblemList, {
15121
+ summary: t("problems", { count: state.payload?.problems.length ?? 0 }),
15122
+ problems: state.payload?.problems ?? []
15123
+ }),
15124
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
15125
+ ref: viewport,
15126
+ className: `${SessionsPage_module_css_default.viewport} ${scrolls ? SessionsPage_module_css_default.scrolls : SessionsPage_module_css_default.fits}`,
15127
+ children: state.status === "loading" || state.status === "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15128
+ className: SessionsPage_module_css_default.message,
15129
+ children: t("loading")
15130
+ }) : failedWithoutData ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15131
+ className: SessionsPage_module_css_default.message,
15132
+ role: "alert",
15133
+ children: t("loadFailed", { message: state.error ?? "" })
15134
+ }) : sessions.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
15135
+ className: SessionsPage_module_css_default.message,
15136
+ children: t("empty")
15137
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
15138
+ className: SessionsPage_module_css_default.table,
15139
+ children: [
15140
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("colgroup", { children: [
15141
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.nameColumn }),
15142
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.worldColumn }),
15143
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.timeColumn }),
15144
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.timeColumn }),
15145
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.turnsColumn }),
15146
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: SessionsPage_module_css_default.actionsColumn })
15147
+ ] }),
15148
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
15149
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
15150
+ scope: "col",
15151
+ children: t("columnName")
15152
+ }),
15153
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
15154
+ scope: "col",
15155
+ children: t("columnWorld")
15156
+ }),
15157
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
15158
+ scope: "col",
15159
+ children: t("columnCreated")
15160
+ }),
15161
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
15162
+ scope: "col",
15163
+ children: t("columnLastPlayed")
15164
+ }),
15165
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
15166
+ scope: "col",
15167
+ className: SessionsPage_module_css_default.number,
15168
+ children: t("columnTurns")
15169
+ }),
15170
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
15171
+ scope: "col",
15172
+ className: SessionsPage_module_css_default.actions,
15173
+ children: t("columnActions")
15174
+ })
15175
+ ] }) }),
15176
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: visible.map((session) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
15177
+ "data-testid": "session-row",
15178
+ className: session.archivedAt === void 0 ? void 0 : SessionsPage_module_css_default.archived,
15179
+ children: [
15180
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
15181
+ className: SessionsPage_module_css_default.name,
15182
+ "data-label": t("columnName"),
15183
+ title: session.name,
15184
+ children: [session.name, session.archivedAt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
15185
+ className: SessionsPage_module_css_default.badge,
15186
+ children: t("archived")
15187
+ })]
15188
+ }),
15189
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
15190
+ className: SessionsPage_module_css_default.secondary,
15191
+ "data-label": t("columnWorld"),
15192
+ title: session.worldName,
15193
+ children: session.worldName
15194
+ }),
15195
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
15196
+ className: SessionsPage_module_css_default.secondary,
15197
+ "data-label": t("columnCreated"),
15198
+ children: dateTime.format(new Date(session.createdAt))
15199
+ }),
15200
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
15201
+ className: SessionsPage_module_css_default.secondary,
15202
+ "data-label": t("columnLastPlayed"),
15203
+ children: session.lastPlayedAt === void 0 ? t("neverPlayed") : dateTime.format(new Date(session.lastPlayedAt))
15204
+ }),
15205
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
15206
+ className: `${SessionsPage_module_css_default.secondary} ${SessionsPage_module_css_default.number}`,
15207
+ "data-label": t("columnTurns"),
15208
+ children: session.turns
15209
+ }),
15210
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
15211
+ className: SessionsPage_module_css_default.actions,
15212
+ "data-label": t("columnActions"),
15213
+ children: [
15214
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15215
+ variant: "ghost",
15216
+ size: "sm",
15217
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlayOutlineRegular, {}),
15218
+ "aria-label": t("open"),
15219
+ title: t("open"),
15220
+ disabled: state.opening !== void 0 || session.archivedAt !== void 0,
15221
+ onClick: () => {
15222
+ open(session.id);
15223
+ }
15224
+ }),
15225
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15226
+ variant: "ghost",
15227
+ size: "sm",
15228
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconDownloadOutlineRegular, {}),
15229
+ "aria-label": t("export"),
15230
+ title: t("export"),
15231
+ onClick: () => {
15232
+ askExport(session.id, session.name);
15233
+ }
15234
+ }),
15235
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15236
+ variant: "ghost",
15237
+ size: "sm",
15238
+ icon: session.archivedAt === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconArchiveOutlineRegular, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconArchiveOffOutlineRegular, {}),
15239
+ "aria-label": session.archivedAt === void 0 ? t("archive") : t("restore"),
15240
+ title: session.archivedAt === void 0 ? t("archive") : t("restore"),
15241
+ disabled: state.moving !== void 0,
15242
+ onClick: () => {
15243
+ if (session.archivedAt === void 0) archive(session.id);
15244
+ else restore(session.id);
15245
+ }
15246
+ }),
15247
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15248
+ variant: "ghost",
15249
+ size: "sm",
15250
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutlineRegular, {}),
15251
+ "aria-label": t("delete"),
15252
+ title: t("delete"),
15253
+ onClick: () => {
15254
+ askRemoval(session.id, session.name);
15255
+ }
15256
+ })
15257
+ ]
15258
+ })
15259
+ ]
15260
+ }, session.id)) })
15261
+ ]
15262
+ })
15263
+ }),
15264
+ pages > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pager, {
15265
+ label: t("nav"),
15266
+ previousLabel: t("previousPage"),
15267
+ nextLabel: t("nextPage"),
15268
+ positionLabel: t("pageOf", {
15269
+ page: start / pageSize + 1,
15270
+ pages
15271
+ }),
15272
+ hasPrevious: start > 0,
15273
+ hasNext: start + pageSize < sessions.length,
15274
+ onPrevious: () => {
15275
+ setRequestedStart(start - pageSize);
15276
+ },
15277
+ onNext: () => {
15278
+ setRequestedStart(start + pageSize);
15279
+ }
15280
+ }),
15281
+ state.exporting !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExportSessionDialog, {
15282
+ t,
15283
+ name: state.exporting.name,
15284
+ onExport: download,
15285
+ onCancel: closeExport
15286
+ }, state.exporting.id),
15287
+ state.removal !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DeleteSessionDialog, {
15288
+ t,
15289
+ removal: state.removal,
15290
+ onConfirm: confirmRemoval,
15291
+ onCancel: cancelRemoval,
15292
+ onEverywhere: setEverywhere
15293
+ }, state.removal.id)
15294
+ ]
15295
+ });
15296
+ }
15297
+ // src/client/pages/sessions/locales.ts
15298
+ const dictionaries$11 = {
15299
+ en: {
15300
+ nav: "Sessions",
15301
+ loading: "Loading sessions…",
15302
+ loadFailed: "Could not load sessions: {message}",
15303
+ empty: "No sessions yet. Press play on a world to start one.",
15304
+ countOne: "{count} session",
15305
+ countOther: "{count} sessions",
15306
+ refresh: "Refresh",
15307
+ refreshing: "Refreshing…",
15308
+ previousPage: "Previous page",
15309
+ nextPage: "Next page",
15310
+ pageOf: "Page {page} of {pages}",
15311
+ problems: "{count} session(s) could not be read",
15312
+ columnName: "Name",
15313
+ columnWorld: "World",
15314
+ columnCreated: "Created",
15315
+ columnLastPlayed: "Last played",
15316
+ columnTurns: "Turns",
15317
+ columnActions: "Actions",
15318
+ archive: "Put the session away",
15319
+ restore: "Bring the session back",
15320
+ archived: "Away",
15321
+ moveFailed: "Could not put the session away or bring it back: {message}",
15322
+ open: "Open the chat",
15323
+ openFailed: "Could not open the chat: {message}",
15324
+ export: "Export the story",
15325
+ exportTitle: "Export the story",
15326
+ exportQuestion: "What should be exported of \"{name}\"?",
15327
+ exportConfirm: "Export",
15328
+ export_story: "The story as it went, to read (Markdown)",
15329
+ export_annotated: "The story with every turn, including those set aside, and notes on rulings, rolls and checkpoints (Markdown)",
15330
+ export_data: "The same as data (JSON)",
15331
+ export_archive: "The whole story, to put back on any machine: state, turns, pictures, settings and its world (ZIP)",
15332
+ importStory: "Import a story",
15333
+ importing: "Importing…",
15334
+ importFailed: "Could not import the story: {message}",
15335
+ imported: "Imported as \"{name}\".",
15336
+ importedWithWorld: "Imported as \"{name}\", with the world it carried.",
15337
+ delete: "Delete session",
15338
+ deleteTitle: "Delete session",
15339
+ deleteQuestion: "Delete the session \"{name}\"?",
15340
+ deleteWarning: "Its characters, state and everything else saved with it are removed permanently.",
15341
+ deleteConfirm: "Delete",
15342
+ deleteScope: "Where to delete it",
15343
+ deleteHere: "Delete it on this device only. It stays on the remote and is not synced back until you restore it on the Sync page.",
15344
+ deleteEverywhere: "Delete it on the remote too. Every device that syncs deletes its copy.",
15345
+ deleting: "Deleting…",
15346
+ deleteFailed: "Could not delete the session: {message}",
15347
+ cancel: "Cancel",
15348
+ close: "Close",
15349
+ neverPlayed: "Never",
15350
+ dateLocale: "en-GB"
15351
+ },
15352
+ zh: {
15353
+ nav: "存档",
15354
+ loading: "正在加载存档…",
15355
+ loadFailed: "无法加载存档:{message}",
15356
+ empty: "还没有存档。请在世界卡上点击开始。",
15357
+ countOne: "{count} 个存档",
15358
+ countOther: "{count} 个存档",
15359
+ refresh: "刷新",
15360
+ refreshing: "刷新中…",
15361
+ previousPage: "上一页",
15362
+ nextPage: "下一页",
15363
+ pageOf: "第 {page} 页,共 {pages} 页",
15364
+ problems: "{count} 个存档无法读取",
15365
+ columnName: "名称",
15366
+ columnWorld: "世界卡",
15367
+ columnCreated: "创建时间",
15368
+ columnLastPlayed: "上次游玩",
15369
+ columnTurns: "回合数",
15370
+ columnActions: "操作",
15371
+ archive: "归档存档",
15372
+ restore: "恢复存档",
15373
+ archived: "已归档",
15374
+ moveFailed: "无法归档或恢复该存档:{message}",
15375
+ open: "打开对话",
15376
+ openFailed: "无法打开对话:{message}",
15377
+ export: "导出故事",
15378
+ exportTitle: "导出故事",
15379
+ exportQuestion: "要导出“{name}”的什么内容?",
15380
+ exportConfirm: "导出",
15381
+ export_story: "故事全文,便于阅读(Markdown)",
15382
+ export_annotated: "包含每个回合(含被放弃的回合),并附上裁定、掷骰和检查点的注释(Markdown)",
15383
+ export_data: "同样的内容,以数据形式(JSON)",
15384
+ export_archive: "完整故事,可在任何设备上恢复:状态、回合、图片、设置及其世界(ZIP)",
15385
+ importStory: "导入故事",
15386
+ importing: "正在导入…",
15387
+ importFailed: "无法导入故事:{message}",
15388
+ imported: "已导入为“{name}”。",
15389
+ importedWithWorld: "已导入为“{name}”,并带入了它的世界。",
15390
+ delete: "删除存档",
15391
+ deleteTitle: "删除存档",
15392
+ deleteQuestion: "删除存档“{name}”?",
15393
+ deleteWarning: "存档中的角色、状态及所有已保存的内容将被永久删除。",
15394
+ deleteConfirm: "删除",
15395
+ deleteScope: "删除范围",
15396
+ deleteHere: "只在本机删除。远端仍保留,在“同步”页恢复之前不会同步回来。",
15397
+ deleteEverywhere: "同时从远端删除。其他设备下次同步时也会删除它们的副本。",
15398
+ deleting: "正在删除…",
15399
+ deleteFailed: "无法删除存档:{message}",
15400
+ cancel: "取消",
15401
+ close: "关闭",
15402
+ neverPlayed: "从未",
15403
+ dateLocale: "zh-CN"
15404
+ }
15405
+ };
15193
15406
  // src/client/pages/sessions/index.ts
15194
15407
  const NAMESPACE$11 = "roleplay.sessions";
15195
15408
  /** Adds the Sessions page to the Role Play panel. */
@@ -15221,29 +15434,29 @@ window.__ModuleLoader__.load({
15221
15434
  }
15222
15435
  tag$19.textContent = css$19;
15223
15436
  var SyncPage_module_css_default = {
15224
- "page": "rp_Gk-byG_page",
15225
- "kindColumn": "rp_Gk-byG_kindColumn",
15226
- "actions": "rp_Gk-byG_actions",
15437
+ "table": "rp_Gk-byG_table",
15227
15438
  "syncedColumn": "rp_Gk-byG_syncedColumn",
15228
15439
  "problem": "rp_Gk-byG_problem",
15229
- "detail": "rp_Gk-byG_detail",
15230
- "actionHeading": "rp_Gk-byG_actionHeading",
15231
- "unitColumn": "rp_Gk-byG_unitColumn",
15232
- "table": "rp_Gk-byG_table",
15233
- "message": "rp_Gk-byG_message",
15234
- "failed": "rp_Gk-byG_failed",
15235
- "conflict": "rp_Gk-byG_conflict",
15236
- "meta": "rp_Gk-byG_meta",
15237
- "error": "rp_Gk-byG_error",
15440
+ "actionHeading": "rp_Gk-byG_actionHeading",
15441
+ "choices": "rp_Gk-byG_choices",
15442
+ "confirmation": "rp_Gk-byG_confirmation",
15443
+ "caption": "rp_Gk-byG_caption",
15238
15444
  "stateColumn": "rp_Gk-byG_stateColumn",
15445
+ "meta": "rp_Gk-byG_meta",
15446
+ "page": "rp_Gk-byG_page",
15239
15447
  "detailsColumn": "rp_Gk-byG_detailsColumn",
15240
- "confirmation": "rp_Gk-byG_confirmation",
15241
- "toolbar": "rp_Gk-byG_toolbar",
15448
+ "message": "rp_Gk-byG_message",
15449
+ "error": "rp_Gk-byG_error",
15450
+ "kindColumn": "rp_Gk-byG_kindColumn",
15242
15451
  "unit": "rp_Gk-byG_unit",
15452
+ "actions": "rp_Gk-byG_actions",
15243
15453
  "viewport": "rp_Gk-byG_viewport",
15244
- "choices": "rp_Gk-byG_choices",
15245
- "caption": "rp_Gk-byG_caption",
15246
- "actionsColumn": "rp_Gk-byG_actionsColumn"
15454
+ "unitColumn": "rp_Gk-byG_unitColumn",
15455
+ "toolbar": "rp_Gk-byG_toolbar",
15456
+ "actionsColumn": "rp_Gk-byG_actionsColumn",
15457
+ "conflict": "rp_Gk-byG_conflict",
15458
+ "failed": "rp_Gk-byG_failed",
15459
+ "detail": "rp_Gk-byG_detail"
15247
15460
  };
15248
15461
  // src/client/pages/sync/SyncPage.tsx
15249
15462
  const when = (iso, never, locale) => iso === void 0 ? never : new Date(iso).toLocaleString(locale);
@@ -15756,16 +15969,16 @@ window.__ModuleLoader__.load({
15756
15969
  }
15757
15970
  tag$18.textContent = css$18;
15758
15971
  var WorldCard_module_css_default = {
15759
- "openButton": "rp_Bvxx5q_openButton",
15760
- "placeholder": "rp_Bvxx5q_placeholder",
15761
- "info": "rp_Bvxx5q_info",
15762
15972
  "tag": "rp_Bvxx5q_tag",
15763
- "tags": "rp_Bvxx5q_tags",
15764
- "image": "rp_Bvxx5q_image",
15765
- "cover": "rp_Bvxx5q_cover",
15973
+ "info": "rp_Bvxx5q_info",
15766
15974
  "name": "rp_Bvxx5q_name",
15975
+ "openButton": "rp_Bvxx5q_openButton",
15976
+ "image": "rp_Bvxx5q_image",
15767
15977
  "card": "rp_Bvxx5q_card",
15768
- "play": "rp_Bvxx5q_play"
15978
+ "play": "rp_Bvxx5q_play",
15979
+ "cover": "rp_Bvxx5q_cover",
15980
+ "placeholder": "rp_Bvxx5q_placeholder",
15981
+ "tags": "rp_Bvxx5q_tags"
15769
15982
  };
15770
15983
  // src/client/widgets/world-card/WorldCard.tsx
15771
15984
  /** Stable hue per name, so a world without a cover keeps the same colour. */
@@ -15862,10 +16075,10 @@ window.__ModuleLoader__.load({
15862
16075
  }
15863
16076
  tag$17.textContent = css$17;
15864
16077
  var AvatarChoices_module_css_default = {
15865
- "summary": "rp_YCstOG_summary",
16078
+ "option": "rp_YCstOG_option",
15866
16079
  "text": "rp_YCstOG_text",
15867
16080
  "name": "rp_YCstOG_name",
15868
- "option": "rp_YCstOG_option"
16081
+ "summary": "rp_YCstOG_summary"
15869
16082
  };
15870
16083
  // src/client/widgets/avatar-choices/AvatarChoices.tsx
15871
16084
  /** A list of avatars to tick: the ones brought into a world or a session. */
@@ -15903,18 +16116,18 @@ window.__ModuleLoader__.load({
15903
16116
  }
15904
16117
  tag$16.textContent = css$16;
15905
16118
  var StartSessionDialog_module_css_default = {
15906
- "label": "rp_AnbLKG_label",
15907
- "optionSummary": "rp_AnbLKG_optionSummary",
15908
- "field": "rp_AnbLKG_field",
15909
- "advanced": "rp_AnbLKG_advanced",
15910
- "optionName": "rp_AnbLKG_optionName",
16119
+ "error": "rp_AnbLKG_error",
15911
16120
  "form": "rp_AnbLKG_form",
15912
- "advancedToggle": "rp_AnbLKG_advancedToggle",
15913
- "option": "rp_AnbLKG_option",
15914
16121
  "message": "rp_AnbLKG_message",
15915
- "error": "rp_AnbLKG_error",
16122
+ "field": "rp_AnbLKG_field",
16123
+ "optionText": "rp_AnbLKG_optionText",
16124
+ "label": "rp_AnbLKG_label",
16125
+ "advanced": "rp_AnbLKG_advanced",
15916
16126
  "advancedBody": "rp_AnbLKG_advancedBody",
15917
- "optionText": "rp_AnbLKG_optionText"
16127
+ "option": "rp_AnbLKG_option",
16128
+ "advancedToggle": "rp_AnbLKG_advancedToggle",
16129
+ "optionName": "rp_AnbLKG_optionName",
16130
+ "optionSummary": "rp_AnbLKG_optionSummary"
15918
16131
  };
15919
16132
  // src/client/pages/worlds/AddAvatarsDialog.tsx
15920
16133
  /** Asks which avatars become characters of a world's own files. */
@@ -16164,7 +16377,10 @@ window.__ModuleLoader__.load({
16164
16377
  confidence: ratio(0, 1, .7)
16165
16378
  },
16166
16379
  interface: { pack: text$1(60, "") },
16167
- rewind: { keepSnapshots: integer(0, 500, 30) },
16380
+ rewind: {
16381
+ keepSnapshots: integer(0, 500, 30),
16382
+ rolls: choice(["reroll", "keep"], "reroll")
16383
+ },
16168
16384
  rules: { own: text$1(MAX_OWN_RULES, "") },
16169
16385
  preview: { enabled: flag(true) },
16170
16386
  suggestions: { count: integer(0, 5, 3) },
@@ -16635,6 +16851,19 @@ window.__ModuleLoader__.load({
16635
16851
  label: "rewindKeep",
16636
16852
  help: "rewindKeepHelp"
16637
16853
  },
16854
+ {
16855
+ path: ["rewind", "rolls"],
16856
+ kind: "choice",
16857
+ label: "rewindRolls",
16858
+ help: "rewindRollsHelp",
16859
+ choices: [{
16860
+ value: "reroll",
16861
+ label: "rewindRollsReroll"
16862
+ }, {
16863
+ value: "keep",
16864
+ label: "rewindRollsKeep"
16865
+ }]
16866
+ },
16638
16867
  {
16639
16868
  path: ["preview", "enabled"],
16640
16869
  kind: "flag",
@@ -17071,13 +17300,13 @@ window.__ModuleLoader__.load({
17071
17300
  tag$15.textContent = css$15;
17072
17301
  var SettingsFields_module_css_default = {
17073
17302
  "label": "rp_Rhi3yq_label",
17303
+ "help": "rp_Rhi3yq_help",
17304
+ "row": "rp_Rhi3yq_row",
17305
+ "groupTitle": "rp_Rhi3yq_groupTitle",
17074
17306
  "error": "rp_Rhi3yq_error",
17075
17307
  "field": "rp_Rhi3yq_field",
17076
- "groupTitle": "rp_Rhi3yq_groupTitle",
17077
17308
  "area": "rp_Rhi3yq_area",
17078
- "row": "rp_Rhi3yq_row",
17079
- "group": "rp_Rhi3yq_group",
17080
- "help": "rp_Rhi3yq_help"
17309
+ "group": "rp_Rhi3yq_group"
17081
17310
  };
17082
17311
  // src/client/settings-form/SettingsFields.tsx
17083
17312
  /** The settings of a chat as editable fields: one control with its explanation under each. */
@@ -17369,10 +17598,10 @@ window.__ModuleLoader__.load({
17369
17598
  }
17370
17599
  tag$14.textContent = css$14;
17371
17600
  var TranslateBanner_module_css_default = {
17372
- "error": "rp_Lx8vJa_error",
17601
+ "banner": "rp_Lx8vJa_banner",
17373
17602
  "bannerActions": "rp_Lx8vJa_bannerActions",
17374
- "text": "rp_Lx8vJa_text",
17375
- "banner": "rp_Lx8vJa_banner"
17603
+ "error": "rp_Lx8vJa_error",
17604
+ "text": "rp_Lx8vJa_text"
17376
17605
  };
17377
17606
  // src/client/pages/worlds/TranslateBanner.tsx
17378
17607
  const languageName = (t, language) => language === "zh" ? t("languageChinese") : t("languageEnglish");
@@ -17956,26 +18185,26 @@ window.__ModuleLoader__.load({
17956
18185
  }
17957
18186
  tag$13.textContent = css$13;
17958
18187
  var WorldsPage_module_css_default = {
17959
- "spinning": "rp_FHUyRq_spinning",
17960
- "toolbarActions": "rp_FHUyRq_toolbarActions",
17961
- "editBody": "rp_FHUyRq_editBody",
17962
- "starters": "rp_FHUyRq_starters",
17963
- "editHeader": "rp_FHUyRq_editHeader",
17964
- "grid": "rp_FHUyRq_grid",
17965
- "cell": "rp_FHUyRq_cell",
17966
18188
  "starter": "rp_FHUyRq_starter",
17967
- "toolbar": "rp_FHUyRq_toolbar",
17968
18189
  "count": "rp_FHUyRq_count",
17969
- "viewport": "rp_FHUyRq_viewport",
17970
- "fits": "rp_FHUyRq_fits",
17971
- "spin": "rp_FHUyRq_spin",
18190
+ "info": "rp_FHUyRq_info",
18191
+ "message": "rp_FHUyRq_message",
17972
18192
  "editTitle": "rp_FHUyRq_editTitle",
17973
- "scrolls": "rp_FHUyRq_scrolls",
17974
- "page": "rp_FHUyRq_page",
17975
18193
  "editActions": "rp_FHUyRq_editActions",
18194
+ "editBody": "rp_FHUyRq_editBody",
18195
+ "editHeader": "rp_FHUyRq_editHeader",
18196
+ "spin": "rp_FHUyRq_spin",
18197
+ "scrolls": "rp_FHUyRq_scrolls",
18198
+ "viewport": "rp_FHUyRq_viewport",
18199
+ "cell": "rp_FHUyRq_cell",
18200
+ "spinning": "rp_FHUyRq_spinning",
18201
+ "grid": "rp_FHUyRq_grid",
17976
18202
  "notice": "rp_FHUyRq_notice",
17977
- "info": "rp_FHUyRq_info",
17978
- "message": "rp_FHUyRq_message"
18203
+ "page": "rp_FHUyRq_page",
18204
+ "fits": "rp_FHUyRq_fits",
18205
+ "starters": "rp_FHUyRq_starters",
18206
+ "toolbarActions": "rp_FHUyRq_toolbarActions",
18207
+ "toolbar": "rp_FHUyRq_toolbar"
17979
18208
  };
17980
18209
  // src/client/pages/worlds/StarterWorlds.tsx
17981
18210
  /** The worlds that ship with the plugin and are not yet the person's, offered where the list of worlds is empty. */
@@ -18129,6 +18358,257 @@ window.__ModuleLoader__.load({
18129
18358
  children: failure
18130
18359
  })] });
18131
18360
  }
18361
+ // src/client/pages/worlds/playtest-api.ts
18362
+ const address = (worldId) => `${API_PREFIX}/worlds/playtest?id=${encodeURIComponent(worldId)}`;
18363
+ async function playtestStatus(worldId, signal) {
18364
+ return await answer$1(await fetch(address(worldId), {
18365
+ credentials: "same-origin",
18366
+ ...signal === void 0 ? {} : { signal }
18367
+ }));
18368
+ }
18369
+ async function startPlaytest(worldId, body) {
18370
+ return await answer$1(await fetch(address(worldId), {
18371
+ method: "POST",
18372
+ credentials: "same-origin",
18373
+ headers: { "content-type": "application/json" },
18374
+ body: JSON.stringify(body)
18375
+ }));
18376
+ }
18377
+ async function stopPlaytest(worldId) {
18378
+ return await answer$1(await fetch(address(worldId), {
18379
+ method: "DELETE",
18380
+ credentials: "same-origin"
18381
+ }));
18382
+ }
18383
+ async function playableCharacters(worldId, signal) {
18384
+ return (await answer$1(await fetch(`${API_PREFIX}/worlds/characters?id=${encodeURIComponent(worldId)}`, {
18385
+ credentials: "same-origin",
18386
+ ...signal === void 0 ? {} : { signal }
18387
+ }))).characters.filter((character) => character.role === "playable");
18388
+ }
18389
+ // src/client/pages/worlds/PlaytestDialog.tsx
18390
+ const POLL_MS$2 = 2e3;
18391
+ const DEFAULT_TURNS = 3;
18392
+ function Report({ t, report }) {
18393
+ const list = (items) => items.length === 0 ? t("pt_none") : items.join(", ");
18394
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
18395
+ className: StartSessionDialog_module_css_default.form,
18396
+ "data-testid": "roleplay-playtest-report",
18397
+ children: [
18398
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18399
+ className: StartSessionDialog_module_css_default.message,
18400
+ children: t("pt_summary", {
18401
+ played: report.played,
18402
+ asked: report.asked,
18403
+ seconds: report.seconds
18404
+ })
18405
+ }),
18406
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18407
+ className: StartSessionDialog_module_css_default.message,
18408
+ children: t("pt_places", {
18409
+ visited: list(report.places.visited),
18410
+ unvisited: list(report.places.unvisited)
18411
+ })
18412
+ }),
18413
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18414
+ className: StartSessionDialog_module_css_default.message,
18415
+ children: t("pt_triggers", {
18416
+ fired: list(report.triggers.fired),
18417
+ waiting: list(report.triggers.waiting)
18418
+ })
18419
+ }),
18420
+ report.turns.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", { children: report.turns.map((turn) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("pt_turn", {
18421
+ player: turn.player,
18422
+ seconds: turn.seconds,
18423
+ place: turn.place
18424
+ }) }, turn.turn)) }),
18425
+ report.changes.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18426
+ className: StartSessionDialog_module_css_default.message,
18427
+ children: t("pt_changes", { count: report.changes.length })
18428
+ }),
18429
+ report.changes.slice(0, 12).map((change, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
18430
+ className: StartSessionDialog_module_css_default.message,
18431
+ children: [
18432
+ change.subject,
18433
+ ": ",
18434
+ change.a ?? t("pt_nothing"),
18435
+ " → ",
18436
+ change.b ?? t("pt_nothing")
18437
+ ]
18438
+ }, index)),
18439
+ report.findings.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18440
+ className: StartSessionDialog_module_css_default.message,
18441
+ children: t("pt_findings", { count: report.findings.length })
18442
+ }),
18443
+ report.findings.slice(0, 10).map((finding, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
18444
+ className: StartSessionDialog_module_css_default.message,
18445
+ children: [
18446
+ finding.severity,
18447
+ ": ",
18448
+ finding.message
18449
+ ]
18450
+ }, index)),
18451
+ report.problems.map((problem, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18452
+ className: StartSessionDialog_module_css_default.error,
18453
+ children: problem
18454
+ }, index))
18455
+ ]
18456
+ });
18457
+ }
18458
+ /**
18459
+ * Asks for a bounded test play of a world (who plays, how many turns), shows what it costs, runs it and reports. The test story is removed by the host afterwards and the world
18460
+ * is only read.
18461
+ */
18462
+ function PlaytestDialog({ t, worldId, worldName, onClose }) {
18463
+ const [reading, setReading] = (0, react.useState)({ state: "idle" });
18464
+ const [players, setPlayers] = (0, react.useState)();
18465
+ const [player, setPlayer] = (0, react.useState)("");
18466
+ const [turns, setTurns] = (0, react.useState)(String(DEFAULT_TURNS));
18467
+ const [error, setError] = (0, react.useState)();
18468
+ const running = reading.state === "running";
18469
+ (0, react.useEffect)(() => {
18470
+ const abort = new AbortController();
18471
+ playtestStatus(worldId, abort.signal).then(setReading, () => void 0);
18472
+ playableCharacters(worldId, abort.signal).then((found) => {
18473
+ setPlayers(found);
18474
+ setPlayer(found[0]?.id ?? "");
18475
+ }, (failure) => {
18476
+ if (!abort.signal.aborted) setError(failure instanceof Error ? failure.message : String(failure));
18477
+ });
18478
+ return () => {
18479
+ abort.abort();
18480
+ };
18481
+ }, [worldId]);
18482
+ (0, react.useEffect)(() => {
18483
+ if (!running) return void 0;
18484
+ const timer = setInterval(() => {
18485
+ playtestStatus(worldId).then(setReading, () => void 0);
18486
+ }, POLL_MS$2);
18487
+ return () => {
18488
+ clearInterval(timer);
18489
+ };
18490
+ }, [running, worldId]);
18491
+ const count = Number(turns);
18492
+ const valid = Number.isInteger(count) && count >= 1 && count <= 10;
18493
+ const begin = () => {
18494
+ setError(void 0);
18495
+ startPlaytest(worldId, {
18496
+ turns: count,
18497
+ ...player === "" ? {} : { playerCharacterId: player },
18498
+ language: t("language")
18499
+ }).then(setReading, (failure) => {
18500
+ setError(failure instanceof Error ? failure.message : String(failure));
18501
+ });
18502
+ };
18503
+ const stop = () => {
18504
+ stopPlaytest(worldId).then(setReading, (failure) => {
18505
+ setError(failure instanceof Error ? failure.message : String(failure));
18506
+ });
18507
+ };
18508
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
18509
+ open: true,
18510
+ onClose,
18511
+ title: t("pt_title"),
18512
+ description: worldName,
18513
+ closeLabel: t("close"),
18514
+ footer: running ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
18515
+ variant: "ghost",
18516
+ onClick: onClose,
18517
+ children: t("close")
18518
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
18519
+ variant: "primary",
18520
+ onClick: stop,
18521
+ children: t("pt_stop")
18522
+ })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
18523
+ variant: "ghost",
18524
+ onClick: onClose,
18525
+ children: t("close")
18526
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
18527
+ variant: "primary",
18528
+ disabled: !valid || players?.length === 0,
18529
+ onClick: begin,
18530
+ children: t("pt_start")
18531
+ })] }),
18532
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
18533
+ className: StartSessionDialog_module_css_default.form,
18534
+ children: [
18535
+ !running && reading.state !== "done" && reading.state !== "stopped" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
18536
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18537
+ className: StartSessionDialog_module_css_default.message,
18538
+ children: t("pt_help", { max: 10 })
18539
+ }),
18540
+ players?.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18541
+ className: StartSessionDialog_module_css_default.error,
18542
+ children: t("pt_noPlayer")
18543
+ }),
18544
+ players !== void 0 && players.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
18545
+ className: StartSessionDialog_module_css_default.field,
18546
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("playAs") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
18547
+ value: player,
18548
+ onChange: (event) => {
18549
+ setPlayer(event.target.value);
18550
+ },
18551
+ children: players.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
18552
+ value: entry.id,
18553
+ children: entry.name
18554
+ }, entry.id))
18555
+ })]
18556
+ }),
18557
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
18558
+ className: StartSessionDialog_module_css_default.field,
18559
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("pt_turns") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
18560
+ value: turns,
18561
+ inputMode: "numeric",
18562
+ onChange: (event) => {
18563
+ setTurns(event.target.value);
18564
+ }
18565
+ })]
18566
+ }),
18567
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18568
+ className: StartSessionDialog_module_css_default.message,
18569
+ children: valid ? t("pt_cost", { turns: count }) : t("pt_turnsInvalid", { max: 10 })
18570
+ })
18571
+ ] }),
18572
+ running && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18573
+ className: StartSessionDialog_module_css_default.message,
18574
+ role: "status",
18575
+ children: t("pt_running", {
18576
+ played: reading.played,
18577
+ turns: reading.turns,
18578
+ step: reading.step
18579
+ })
18580
+ }),
18581
+ reading.state === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18582
+ className: StartSessionDialog_module_css_default.error,
18583
+ role: "alert",
18584
+ children: t("pt_failed", { message: reading.error ?? "" })
18585
+ }),
18586
+ (reading.state === "done" || reading.state === "stopped") && reading.error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18587
+ className: StartSessionDialog_module_css_default.error,
18588
+ role: "alert",
18589
+ children: reading.error
18590
+ }),
18591
+ (reading.state === "done" || reading.state === "stopped") && reading.report !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Report, {
18592
+ t,
18593
+ report: reading.report
18594
+ }),
18595
+ (reading.state === "done" || reading.state === "stopped" || reading.state === "failed") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
18596
+ variant: "outline",
18597
+ size: "sm",
18598
+ onClick: () => {
18599
+ setReading({ state: "idle" });
18600
+ },
18601
+ children: t("pt_again")
18602
+ }),
18603
+ error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
18604
+ className: StartSessionDialog_module_css_default.error,
18605
+ role: "alert",
18606
+ children: error
18607
+ })
18608
+ ]
18609
+ })
18610
+ });
18611
+ }
18132
18612
  // src/client/pages/worlds/RevertUpdateDialog.tsx
18133
18613
  /** Asks before a world goes back to how it was before its last card update. */
18134
18614
  function RevertUpdateDialog({ t, revert, onDone, onClose }) {
@@ -18185,6 +18665,7 @@ window.__ModuleLoader__.load({
18185
18665
  const [reverting, setReverting] = (0, react.useState)(false);
18186
18666
  const updatePicker = (0, react.useRef)(null);
18187
18667
  const [updateBusy, setUpdateBusy] = (0, react.useState)(false);
18668
+ const [playtesting, setPlaytesting] = (0, react.useState)(false);
18188
18669
  const [uploading, setUploading] = (0, react.useState)(false);
18189
18670
  const [importNotice, setImportNotice] = (0, react.useState)();
18190
18671
  const [importDone, setImportDone] = (0, react.useState)();
@@ -18368,6 +18849,14 @@ window.__ModuleLoader__.load({
18368
18849
  },
18369
18850
  children: presetBusy ? t("presetReading") : t("importPreset")
18370
18851
  }),
18852
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
18853
+ variant: "outline",
18854
+ size: "sm",
18855
+ onClick: () => {
18856
+ setPlaytesting(true);
18857
+ },
18858
+ children: t("playtest")
18859
+ }),
18371
18860
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
18372
18861
  variant: "outline",
18373
18862
  size: "sm",
@@ -18450,6 +18939,14 @@ window.__ModuleLoader__.load({
18450
18939
  refresh();
18451
18940
  }
18452
18941
  }),
18942
+ playtesting && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PlaytestDialog, {
18943
+ t,
18944
+ worldId: editing.id,
18945
+ worldName: editing.name,
18946
+ onClose: () => {
18947
+ setPlaytesting(false);
18948
+ }
18949
+ }),
18453
18950
  addingAvatars && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AddAvatarsDialog, {
18454
18951
  t,
18455
18952
  worldId: editing.id,
@@ -18699,6 +19196,10 @@ window.__ModuleLoader__.load({
18699
19196
  triggersMaxFiresHelp: "The most triggers that fire in one look, after a round or at the start of a turn. The rest wait for the next look.",
18700
19197
  triggersBeatTurns: "Turns a beat stays pending",
18701
19198
  triggersBeatTurnsHelp: "A beat is something the world makes happen that the game master is told to weave into the story. If it does not within this many turns, it is let go.",
19199
+ rewindRolls: "Dice when a turn is played again",
19200
+ rewindRollsHelp: "Reroll rolls the dice afresh when you regenerate a turn or play another from the same place. Keep lets a turn played again from the same place meet the same dice in the same order, so only your words and the story change, not the luck. The numbers follow the order of the rolls, not what they are for.",
19201
+ rewindRollsReroll: "Roll again",
19202
+ rewindRollsKeep: "Keep the dice",
18702
19203
  rewindKeep: "Turns that can be gone back to",
18703
19204
  rewindKeepHelp: "How many of the latest turns keep a copy of the story's state, so that you can rewind to them, regenerate, or swap a turn for another. Older turns cannot be returned to. 0 turns rewinding off. Each copy takes the size of the session's database.",
18704
19205
  previewEnabled: "Preview of the scene",
@@ -18908,6 +19409,10 @@ window.__ModuleLoader__.load({
18908
19409
  triggersMaxFiresHelp: "每次检查(一轮之后或一回合开始时)最多触发的触发器数量,其余等待下一次检查。",
18909
19410
  triggersBeatTurns: "情节提示保留的回合数",
18910
19411
  triggersBeatTurnsHelp: "情节提示是世界促成、要求主持人写进故事的事。若在这么多回合内都没有写入,就会被放弃。",
19412
+ rewindRolls: "重播回合时的骰子",
19413
+ rewindRollsHelp: "“重掷”会在你重新生成回合、或从同一处另打一个回合时重新掷骰。“保留”让从同一处重播的回合按相同顺序遇到相同的骰点,变化的只有你的话和故事,不是运气。骰点按掷骰的先后顺序对应,与掷骰的用途无关。",
19414
+ rewindRollsReroll: "重新掷骰",
19415
+ rewindRollsKeep: "保留骰点",
18911
19416
  rewindKeep: "可回退的回合数",
18912
19417
  rewindKeepHelp: "最近的这么多个回合会保存一份故事状态的副本,因此可以回退到它们、重新生成,或把某一回合换成另一个。更早的回合无法回到。0 表示关闭回退。每份副本的大小等于会话数据库的大小。",
18913
19418
  previewEnabled: "场景预览",
@@ -19140,6 +19645,26 @@ window.__ModuleLoader__.load({
19140
19645
  presetReading: "Reading…",
19141
19646
  presetFailed: "Could not import the preset: {message}",
19142
19647
  presetNotStarted: "The authoring chat opened but the preset was not applied: {message}. Ask it to apply the preset you uploaded.",
19648
+ playtest: "Playtest",
19649
+ pt_title: "Playtest this world",
19650
+ pt_help: "Plays a few turns of a story made from this world to see where it goes, what it sets off and how long it takes. The test player takes what the story itself suggests. Up to {max} turns. The test story is removed afterwards; the world is only read, never changed.",
19651
+ pt_noPlayer: "This world has no character a player can play.",
19652
+ pt_turns: "Turns to play",
19653
+ pt_turnsInvalid: "Turns must be a whole number from 1 to {max}.",
19654
+ pt_cost: "This plays {turns} full turn(s) with the models you have selected: the game master, the characters asked, the record keeper and the writer of the suggestions each time, one turn after another. It takes as long as the same turns would in play, and uses the same models and limits.",
19655
+ pt_start: "Start the test",
19656
+ pt_stop: "Stop after this turn",
19657
+ pt_again: "Test again",
19658
+ pt_running: "Turn {played} of {turns} done. {step}",
19659
+ pt_failed: "The test play failed: {message}",
19660
+ pt_summary: "Played {played} of {asked} turns in {seconds} s.",
19661
+ pt_places: "Places visited: {visited}. Not visited: {unvisited}.",
19662
+ pt_triggers: "Triggers that fired: {fired}. Still waiting: {waiting}.",
19663
+ pt_turn: "“{player}” took {seconds} s and ended in {place}",
19664
+ pt_changes: "{count} things changed from the start to the end:",
19665
+ pt_findings: "The world's own checks found {count}:",
19666
+ pt_none: "none",
19667
+ pt_nothing: "(nothing)",
19143
19668
  authorWorld: "Author with AI",
19144
19669
  openingAuthor: "Opening…",
19145
19670
  authorWorldFailed: "Could not open the authoring chat: {message}",
@@ -19255,6 +19780,26 @@ window.__ModuleLoader__.load({
19255
19780
  presetReading: "正在读取…",
19256
19781
  presetFailed: "无法导入预设:{message}",
19257
19782
  presetNotStarted: "世界编辑对话已打开,但预设没有应用:{message}。可以请它应用你上传的预设。",
19783
+ playtest: "试玩",
19784
+ pt_title: "试玩这个世界",
19785
+ pt_help: "用这个世界开一个存档,玩几个回合,看看会走向哪里、触发什么、要多久。试玩者会选取故事自己给出的建议。最多 {max} 个回合。试玩的存档之后会被删除;世界只会被读取,不会被修改。",
19786
+ pt_noPlayer: "这个世界没有可供玩家扮演的角色。",
19787
+ pt_turns: "试玩回合数",
19788
+ pt_turnsInvalid: "回合数必须是 1 到 {max} 的整数。",
19789
+ pt_cost: "这将用你选择的模型完整地玩 {turns} 个回合:每个回合都有游戏主持人、被询问的角色、记录员和建议撰写者参与,并且一个接一个地进行。耗时与实际游玩同样的回合相同,使用相同的模型和限制。",
19790
+ pt_start: "开始试玩",
19791
+ pt_stop: "本回合结束后停止",
19792
+ pt_again: "再试一次",
19793
+ pt_running: "已完成第 {played}/{turns} 回合。{step}",
19794
+ pt_failed: "试玩失败:{message}",
19795
+ pt_summary: "在 {seconds} 秒内玩了 {played}/{asked} 个回合。",
19796
+ pt_places: "到过的地点:{visited}。未到过:{unvisited}。",
19797
+ pt_triggers: "已触发的触发器:{fired}。仍在等待:{waiting}。",
19798
+ pt_turn: "“{player}”用了 {seconds} 秒,结束于{place}",
19799
+ pt_changes: "从开始到结束有 {count} 处变化:",
19800
+ pt_findings: "世界自带的检查发现了 {count} 项:",
19801
+ pt_none: "无",
19802
+ pt_nothing: "(无)",
19258
19803
  authorWorld: "使用 AI 编辑",
19259
19804
  openingAuthor: "正在打开…",
19260
19805
  authorWorldFailed: "无法打开世界编辑对话:{message}",
@@ -19647,10 +20192,10 @@ window.__ModuleLoader__.load({
19647
20192
  }
19648
20193
  tag$12.textContent = css$12;
19649
20194
  var BranchDialog_module_css_default = {
19650
- "field": "rp_Dy1TaW_field",
19651
20195
  "error": "rp_Dy1TaW_error",
19652
- "label": "rp_Dy1TaW_label",
19653
- "form": "rp_Dy1TaW_form"
20196
+ "form": "rp_Dy1TaW_form",
20197
+ "field": "rp_Dy1TaW_field",
20198
+ "label": "rp_Dy1TaW_label"
19654
20199
  };
19655
20200
  // src/client/branch/BranchDialog.tsx
19656
20201
  /** Asks for the name of a session that was just branched off another. */
@@ -19768,12 +20313,12 @@ window.__ModuleLoader__.load({
19768
20313
  }
19769
20314
  tag$11.textContent = css$11;
19770
20315
  var SidebarGuideEntry_module_css_default = {
19771
- "main": "rp_Okaj1q_main",
19772
- "text": "rp_Okaj1q_text",
19773
- "icon": "rp_Okaj1q_icon",
19774
20316
  "entry": "rp_Okaj1q_entry",
20317
+ "main": "rp_Okaj1q_main",
19775
20318
  "title": "rp_Okaj1q_title",
19776
- "description": "rp_Okaj1q_description"
20319
+ "icon": "rp_Okaj1q_icon",
20320
+ "description": "rp_Okaj1q_description",
20321
+ "text": "rp_Okaj1q_text"
19777
20322
  };
19778
20323
  // src/client/widgets/sidebar-guide/SidebarGuideEntry.tsx
19779
20324
  /** A card of the right sidebar's new-tab guide, drawn like DSH's own entries. */
@@ -19820,9 +20365,9 @@ window.__ModuleLoader__.load({
19820
20365
  }
19821
20366
  tag$10.textContent = css$10;
19822
20367
  var GalleryTab_module_css_default = {
20368
+ "bar": "rp_W688Pa_bar",
19823
20369
  "message": "rp_W688Pa_message",
19824
- "page": "rp_W688Pa_page",
19825
- "bar": "rp_W688Pa_bar"
20370
+ "page": "rp_W688Pa_page"
19826
20371
  };
19827
20372
  // src/client/gallery/GalleryTab.tsx
19828
20373
  /** The kind of the tab type, and the identity it registers its card and body under. */
@@ -20211,16 +20756,16 @@ window.__ModuleLoader__.load({
20211
20756
  }
20212
20757
  tag$9.textContent = css$9;
20213
20758
  var SidebarPage_module_css_default = {
20214
- "content": "rp_Ptco8a_content",
20215
- "text": "rp_Ptco8a_text",
20216
- "main": "rp_Ptco8a_main",
20217
- "page": "rp_Ptco8a_page",
20218
- "name": "rp_Ptco8a_name",
20219
20759
  "message": "rp_Ptco8a_message",
20220
- "title": "rp_Ptco8a_title",
20760
+ "name": "rp_Ptco8a_name",
20761
+ "main": "rp_Ptco8a_main",
20762
+ "content": "rp_Ptco8a_content",
20221
20763
  "icon": "rp_Ptco8a_icon",
20222
- "description": "rp_Ptco8a_description",
20223
20764
  "entry": "rp_Ptco8a_entry",
20765
+ "title": "rp_Ptco8a_title",
20766
+ "page": "rp_Ptco8a_page",
20767
+ "text": "rp_Ptco8a_text",
20768
+ "description": "rp_Ptco8a_description",
20224
20769
  "bar": "rp_Ptco8a_bar"
20225
20770
  };
20226
20771
  // src/client/interface/SidebarPage.tsx
@@ -20561,24 +21106,24 @@ window.__ModuleLoader__.load({
20561
21106
  }
20562
21107
  tag$8.textContent = css$8;
20563
21108
  var RecallTab_module_css_default = {
20564
- "place": "rp_jl9CIq_place",
20565
- "label": "rp_jl9CIq_label",
21109
+ "list": "rp_jl9CIq_list",
21110
+ "heading": "rp_jl9CIq_heading",
21111
+ "bar": "rp_jl9CIq_bar",
20566
21112
  "actions": "rp_jl9CIq_actions",
20567
- "item": "rp_jl9CIq_item",
20568
- "hint": "rp_jl9CIq_hint",
21113
+ "form": "rp_jl9CIq_form",
20569
21114
  "meta": "rp_jl9CIq_meta",
21115
+ "label": "rp_jl9CIq_label",
20570
21116
  "area": "rp_jl9CIq_area",
20571
- "bar": "rp_jl9CIq_bar",
20572
- "heading": "rp_jl9CIq_heading",
20573
- "field": "rp_jl9CIq_field",
20574
- "note": "rp_jl9CIq_note",
20575
- "error": "rp_jl9CIq_error",
20576
- "body": "rp_jl9CIq_body",
20577
- "form": "rp_jl9CIq_form",
21117
+ "hint": "rp_jl9CIq_hint",
21118
+ "field": "rp_jl9CIq_field",
21119
+ "place": "rp_jl9CIq_place",
21120
+ "item": "rp_jl9CIq_item",
20578
21121
  "person": "rp_jl9CIq_person",
20579
- "name": "rp_jl9CIq_name",
20580
21122
  "page": "rp_jl9CIq_page",
20581
- "list": "rp_jl9CIq_list"
21123
+ "error": "rp_jl9CIq_error",
21124
+ "note": "rp_jl9CIq_note",
21125
+ "name": "rp_jl9CIq_name",
21126
+ "body": "rp_jl9CIq_body"
20582
21127
  };
20583
21128
  // src/client/recall/RecallTab.tsx
20584
21129
  /** The kind of the tab type, and the identity it registers its card and body under. */
@@ -20953,10 +21498,10 @@ window.__ModuleLoader__.load({
20953
21498
  tag$7.textContent = css$7;
20954
21499
  var ReferenceTab_module_css_default = {
20955
21500
  "nav": "rp_7BGO2a_nav",
21501
+ "body": "rp_7BGO2a_body",
20956
21502
  "bar": "rp_7BGO2a_bar",
20957
21503
  "page": "rp_7BGO2a_page",
20958
- "message": "rp_7BGO2a_message",
20959
- "body": "rp_7BGO2a_body"
21504
+ "message": "rp_7BGO2a_message"
20960
21505
  };
20961
21506
  // src/client/reference/ReferenceTab.tsx
20962
21507
  /** The kind of the tab type, and the identity it registers its card and body under. */
@@ -21077,27 +21622,27 @@ window.__ModuleLoader__.load({
21077
21622
  tag$6.textContent = css$6;
21078
21623
  var Page_module_css_default = {
21079
21624
  "heading": "rp_bG1sCa_heading",
21080
- "entry": "rp_bG1sCa_entry",
21625
+ "block": "rp_bG1sCa_block",
21081
21626
  "head": "rp_bG1sCa_head",
21082
- "name": "rp_bG1sCa_name",
21627
+ "placeName": "rp_bG1sCa_placeName",
21628
+ "meta": "rp_bG1sCa_meta",
21629
+ "entry": "rp_bG1sCa_entry",
21630
+ "opened": "rp_bG1sCa_opened",
21083
21631
  "message": "rp_bG1sCa_message",
21084
- "sub": "rp_bG1sCa_sub",
21085
- "tag": "rp_bG1sCa_tag",
21086
- "block": "rp_bG1sCa_block",
21087
21632
  "closedWay": "rp_bG1sCa_closedWay",
21088
21633
  "journal": "rp_bG1sCa_journal",
21089
21634
  "map": "rp_bG1sCa_map",
21090
- "placeName": "rp_bG1sCa_placeName",
21091
- "text": "rp_bG1sCa_text",
21635
+ "notes": "rp_bG1sCa_notes",
21092
21636
  "title": "rp_bG1sCa_title",
21093
- "meta": "rp_bG1sCa_meta",
21094
- "place": "rp_bG1sCa_place",
21095
21637
  "way": "rp_bG1sCa_way",
21096
- "opened": "rp_bG1sCa_opened",
21097
- "link": "rp_bG1sCa_link",
21098
- "notes": "rp_bG1sCa_notes",
21099
21638
  "list": "rp_bG1sCa_list",
21100
- "here": "rp_bG1sCa_here"
21639
+ "name": "rp_bG1sCa_name",
21640
+ "sub": "rp_bG1sCa_sub",
21641
+ "text": "rp_bG1sCa_text",
21642
+ "link": "rp_bG1sCa_link",
21643
+ "here": "rp_bG1sCa_here",
21644
+ "place": "rp_bG1sCa_place",
21645
+ "tag": "rp_bG1sCa_tag"
21101
21646
  };
21102
21647
  // src/client/reference/sections/Journal.tsx
21103
21648
  /** How long typing pauses before the notes are saved. */
@@ -21960,28 +22505,28 @@ window.__ModuleLoader__.load({
21960
22505
  }
21961
22506
  tag$5.textContent = css$5;
21962
22507
  var ChatSettingsView_module_css_default = {
22508
+ "pre": "rp_wLpbxW_pre",
22509
+ "table": "rp_wLpbxW_table",
22510
+ "view": "rp_wLpbxW_view",
21963
22511
  "link": "rp_wLpbxW_link",
21964
- "activity": "rp_wLpbxW_activity",
21965
- "title": "rp_wLpbxW_title",
21966
- "activityBody": "rp_wLpbxW_activityBody",
22512
+ "error": "rp_wLpbxW_error",
21967
22513
  "run": "rp_wLpbxW_run",
21968
- "view": "rp_wLpbxW_view",
21969
- "select": "rp_wLpbxW_select",
21970
- "list": "rp_wLpbxW_list",
22514
+ "actions": "rp_wLpbxW_actions",
22515
+ "saved": "rp_wLpbxW_saved",
22516
+ "reasons": "rp_wLpbxW_reasons",
22517
+ "notice": "rp_wLpbxW_notice",
22518
+ "title": "rp_wLpbxW_title",
21971
22519
  "label": "rp_wLpbxW_label",
21972
22520
  "description": "rp_wLpbxW_description",
21973
- "notice": "rp_wLpbxW_notice",
21974
- "row": "rp_wLpbxW_row",
21975
- "saved": "rp_wLpbxW_saved",
21976
- "field": "rp_wLpbxW_field",
21977
- "message": "rp_wLpbxW_message",
22521
+ "activityBody": "rp_wLpbxW_activityBody",
21978
22522
  "tableViewport": "rp_wLpbxW_tableViewport",
21979
- "table": "rp_wLpbxW_table",
21980
- "pre": "rp_wLpbxW_pre",
21981
- "reasons": "rp_wLpbxW_reasons",
22523
+ "field": "rp_wLpbxW_field",
22524
+ "list": "rp_wLpbxW_list",
22525
+ "row": "rp_wLpbxW_row",
22526
+ "activity": "rp_wLpbxW_activity",
22527
+ "select": "rp_wLpbxW_select",
21982
22528
  "help": "rp_wLpbxW_help",
21983
- "error": "rp_wLpbxW_error",
21984
- "actions": "rp_wLpbxW_actions"
22529
+ "message": "rp_wLpbxW_message"
21985
22530
  };
21986
22531
  // src/client/chat-settings/settings-api.ts
21987
22532
  /** The chat is not a roleplay session, so it has no settings. */
@@ -22824,7 +23369,8 @@ window.__ModuleLoader__.load({
22824
23369
  "command",
22825
23370
  "pacing",
22826
23371
  "rules",
22827
- "roll"
23372
+ "roll",
23373
+ "wait"
22828
23374
  ];
22829
23375
  const dictionaries$3 = {
22830
23376
  en: {
@@ -22858,6 +23404,8 @@ window.__ModuleLoader__.load({
22858
23404
  traceLookupRow: "{tool}: {text}",
22859
23405
  traceCharactersTitle: "What each character was given",
22860
23406
  traceCharactersHelp: "Given is what went into the brief; withheld is what the story holds that the character has no knowledge of. Turn on \"Keep what the helpers were told\" to see the names behind the withheld counts.",
23407
+ traceExact: "Exactly what it was told",
23408
+ traceExactOff: "not kept (turn on “Keep what helpers are told” in Diagnostics)",
22861
23409
  traceGiven: "Given",
22862
23410
  traceWithheld: "Withheld",
22863
23411
  traceMemories: "memories: {clear} clear, {faded} faded, {vague} vague",
@@ -22884,6 +23432,7 @@ window.__ModuleLoader__.load({
22884
23432
  traceSection_pacing: "Pacing",
22885
23433
  traceSection_rules: "Rules",
22886
23434
  traceSection_roll: "Player's roll",
23435
+ traceSection_wait: "Waiting",
22887
23436
  traceKind_people: "people",
22888
23437
  traceKind_places: "places",
22889
23438
  traceKind_things: "things",
@@ -22928,6 +23477,8 @@ window.__ModuleLoader__.load({
22928
23477
  traceLookupRow: "{tool}:{text}",
22929
23478
  traceCharactersTitle: "每个角色得到了什么",
22930
23479
  traceCharactersHelp: "“得到”指进入简报的内容;“未给”指故事里有、但该角色并不知道的内容。打开“保留助手收到的内容”,可看到未给内容的名称。",
23480
+ traceExact: "确切收到的内容",
23481
+ traceExactOff: "未保存(在“诊断”中开启“保存辅助者收到的内容”)",
22931
23482
  traceGiven: "得到",
22932
23483
  traceWithheld: "未给",
22933
23484
  traceMemories: "记忆:清晰 {clear}、模糊 {faded}、依稀 {vague}",
@@ -22954,6 +23505,7 @@ window.__ModuleLoader__.load({
22954
23505
  traceSection_pacing: "节奏",
22955
23506
  traceSection_rules: "规则",
22956
23507
  traceSection_roll: "玩家的掷骰",
23508
+ traceSection_wait: "等待",
22957
23509
  traceKind_people: "人物",
22958
23510
  traceKind_places: "地点",
22959
23511
  traceKind_things: "物品",
@@ -23075,7 +23627,12 @@ window.__ModuleLoader__.load({
23075
23627
  return [t("traceMemories", memories), ...nonzero(t, counts)].join(" · ");
23076
23628
  }
23077
23629
  const withheldText = (t, access) => nonzero(t, access.withheld).join(" · ");
23078
- function TurnBody({ t, trace, activity }) {
23630
+ /** The stored run of a character's activation in a turn, when the chat kept it: the nth activation of that character in the turn is the nth attempt's run. */
23631
+ function runOf(activity, turn, access) {
23632
+ const runs = activity.filter((entry) => entry.turn === turn && entry.label === access.character && entry.cause === void 0);
23633
+ return runs[Math.min(access.attempt, runs.length) - 1]?.run;
23634
+ }
23635
+ function TurnBody({ t, session, trace, activity }) {
23079
23636
  const times = turnTimes(trace, activity);
23080
23637
  const refusals = refusalsOf(trace, times.helpers);
23081
23638
  const fullest = fullestRequest(trace);
@@ -23181,14 +23738,23 @@ window.__ModuleLoader__.load({
23181
23738
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
23182
23739
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {}),
23183
23740
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("traceGiven") }),
23184
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("traceWithheld") })
23741
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("traceWithheld") }),
23742
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("traceExact") })
23185
23743
  ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: trace.access.map((access, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
23186
23744
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: access.attempt > 1 ? `${access.character} (${t("traceRetry")})` : access.character }),
23187
23745
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: givenText(t, access) }),
23188
23746
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", { children: [withheldText(t, access), access.names !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
23189
23747
  className: ChatSettingsView_module_css_default.description,
23190
23748
  children: t("traceNames", { names: Object.values(access.names).flat().join(", ") })
23191
- })] })
23749
+ })] }),
23750
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: runOf(activity, trace.turn, access) === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
23751
+ className: ChatSettingsView_module_css_default.description,
23752
+ children: t("traceExactOff")
23753
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RunToggle, {
23754
+ t,
23755
+ session,
23756
+ run: runOf(activity, trace.turn, access)
23757
+ }) })
23192
23758
  ] }, index)) })]
23193
23759
  })
23194
23760
  ] })
@@ -23196,7 +23762,7 @@ window.__ModuleLoader__.load({
23196
23762
  });
23197
23763
  }
23198
23764
  /** Where each of the latest turns went, newest first: the time before and after delivery, the game master's prompt by part, what was refused, what it was reminded of, and what each character was given. */
23199
- function TraceList({ t, trace, activity }) {
23765
+ function TraceList({ t, session, trace, activity }) {
23200
23766
  const shown = trace.slice(-10).reverse();
23201
23767
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
23202
23768
  className: ChatSettingsView_module_css_default.activity,
@@ -23221,6 +23787,7 @@ window.__ModuleLoader__.load({
23221
23787
  refused: total
23222
23788
  }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TurnBody, {
23223
23789
  t,
23790
+ session,
23224
23791
  trace: entry,
23225
23792
  activity
23226
23793
  })] }, entry.turn);
@@ -23245,6 +23812,16 @@ window.__ModuleLoader__.load({
23245
23812
  ...request.ms === void 0 ? [] : [t("reqTook", { time: seconds(request.ms) })],
23246
23813
  ...request.stop === "max-tokens" ? [t("reqCutOff")] : request.stop === "error" ? [t("reqError")] : []
23247
23814
  ].join(" · ");
23815
+ function BriefList({ t, brief }) {
23816
+ if (brief === void 0 || brief.length === 0) return null;
23817
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
23818
+ "data-testid": "roleplay-brief",
23819
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: t("briefCount", { count: brief.length }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
23820
+ className: ChatSettingsView_module_css_default.reasons,
23821
+ children: [...brief].sort((a, b) => b.tokens - a.tokens).map((part, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: `${part.title === "" ? t("briefOpening") : part.title}: ${t("briefTokens", { count: count(part.tokens) })}` }, index))
23822
+ })]
23823
+ });
23824
+ }
23248
23825
  function RequestList({ t, requests }) {
23249
23826
  if (requests === void 0 || requests.length === 0) return null;
23250
23827
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
@@ -23347,14 +23924,21 @@ window.__ModuleLoader__.load({
23347
23924
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {})
23348
23925
  ] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: shown.flatMap((entry) => [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
23349
23926
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: new Date(entry.at).toLocaleTimeString() }),
23350
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: entry.label }),
23927
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", { children: [entry.label, entry.cause === void 0 ? null : ` (${entry.cause === "off stage" ? t("causeOffStage") : entry.cause})`] }),
23351
23928
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: entry.model === "" ? t("activityOwnModel") : entry.model }),
23352
23929
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: seconds(entry.ms) }),
23353
23930
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: entry.calls }),
23354
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", { children: [entry.tokens === void 0 ? "" : tokenText(t, entry.tokens), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestList, {
23355
- t,
23356
- requests: entry.requests
23357
- })] }),
23931
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", { children: [
23932
+ entry.tokens === void 0 ? "" : tokenText(t, entry.tokens),
23933
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestList, {
23934
+ t,
23935
+ requests: entry.requests
23936
+ }),
23937
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BriefList, {
23938
+ t,
23939
+ brief: entry.brief
23940
+ })
23941
+ ] }),
23358
23942
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
23359
23943
  className: entry.error === void 0 ? void 0 : ChatSettingsView_module_css_default.error,
23360
23944
  title: entry.error,
@@ -23462,6 +24046,116 @@ window.__ModuleLoader__.load({
23462
24046
  })]
23463
24047
  ].join(" · ");
23464
24048
  }
24049
+ /** A link that shows exactly what a helper's run was told and did, when the chat kept it. */
24050
+ function RunToggle({ t, session, run }) {
24051
+ const [detail, setDetail] = (0, react.useState)();
24052
+ const toggle = () => {
24053
+ if (detail !== void 0) {
24054
+ setDetail(void 0);
24055
+ return;
24056
+ }
24057
+ setDetail("loading");
24058
+ loadRun(session, run, new AbortController().signal).then((found) => {
24059
+ setDetail(found ?? "gone");
24060
+ }, (failure) => {
24061
+ setDetail({ error: failure instanceof Error ? failure.message : String(failure) });
24062
+ });
24063
+ };
24064
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
24065
+ type: "button",
24066
+ className: ChatSettingsView_module_css_default.link,
24067
+ onClick: toggle,
24068
+ children: detail === void 0 ? t("runShow") : t("runHide")
24069
+ }), detail !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RunView, {
24070
+ t,
24071
+ detail
24072
+ })] });
24073
+ }
24074
+ // src/client/chat-settings/StatisticsSection.tsx
24075
+ async function loadStatistics(id) {
24076
+ const response = await fetch(`${API_PREFIX}/sessions/statistics?id=${encodeURIComponent(id)}`, { credentials: "same-origin" });
24077
+ if (!response.ok) throw new Error((await response.json().catch(() => ({}))).message ?? `${response.status} ${response.statusText}`.trim());
24078
+ return await response.json();
24079
+ }
24080
+ const clock = (ms) => {
24081
+ const seconds = Math.round(ms / 1e3);
24082
+ return seconds < 120 ? `${seconds} s` : `${Math.round(seconds / 60)} min`;
24083
+ };
24084
+ /** How long a stretch of story time is, in the largest unit that keeps it readable. */
24085
+ function storySpan(seconds, t) {
24086
+ if (seconds < 3600) return t("statsMinutes", { count: Math.round(seconds / 60) });
24087
+ if (seconds < 172800) return t("statsHours", { count: Math.round(seconds / 360) / 10 });
24088
+ return t("statsDays", { count: Math.round(seconds / 8640) / 10 });
24089
+ }
24090
+ /** The shape of the played story: its length, the time it took and covers, who spoke, what is open, how it branched and what the models used. Read when opened. */
24091
+ function StatisticsSection({ t, session }) {
24092
+ const [stats, setStats] = (0, react.useState)();
24093
+ const load = () => {
24094
+ setStats("loading");
24095
+ loadStatistics(session).then(setStats, (failure) => {
24096
+ setStats({ error: failure instanceof Error ? failure.message : String(failure) });
24097
+ });
24098
+ };
24099
+ const total = stats !== void 0 && stats !== "loading" && !("error" in stats) ? stats.speaking.reduce((sum, voice) => sum + voice.length, 0) + stats.narration.length : 0;
24100
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
24101
+ className: ChatSettingsView_module_css_default.activity,
24102
+ "data-testid": "roleplay-statistics",
24103
+ onToggle: (event) => {
24104
+ if (event.currentTarget.open && stats === void 0) load();
24105
+ },
24106
+ children: [
24107
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: t("statsTitle") }),
24108
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
24109
+ className: ChatSettingsView_module_css_default.description,
24110
+ children: t("statsHelp")
24111
+ }),
24112
+ stats === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
24113
+ className: ChatSettingsView_module_css_default.description,
24114
+ children: t("loading")
24115
+ }),
24116
+ stats !== void 0 && stats !== "loading" && "error" in stats && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
24117
+ className: ChatSettingsView_module_css_default.error,
24118
+ role: "alert",
24119
+ children: t("statsFailed", { message: stats.error })
24120
+ }),
24121
+ stats !== void 0 && stats !== "loading" && !("error" in stats) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
24122
+ className: ChatSettingsView_module_css_default.reasons,
24123
+ children: [
24124
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsTurns", { count: stats.turns }) }),
24125
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsWaited", { time: clock(stats.realTime.waitedMs) }) }),
24126
+ stats.storyTime.elapsedSeconds !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsStoryTime", { span: storySpan(stats.storyTime.elapsedSeconds, t) }) }),
24127
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsScenes", { count: stats.scenes }) }),
24128
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsNarration", {
24129
+ passages: stats.narration.passages,
24130
+ share: total === 0 ? 0 : Math.round(stats.narration.length * 100 / total)
24131
+ }) }),
24132
+ stats.speaking.map((voice) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsVoice", {
24133
+ name: voice.name,
24134
+ lines: voice.lines,
24135
+ share: total === 0 ? 0 : Math.round(voice.length * 100 / total)
24136
+ }) }, voice.name)),
24137
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsThreads", {
24138
+ open: stats.threads.open,
24139
+ resolved: stats.threads.resolved
24140
+ }) }),
24141
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsRelationships", {
24142
+ changed: stats.relationships.changed,
24143
+ total: stats.relationships.total
24144
+ }) }),
24145
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsBranches", {
24146
+ points: stats.branches.branchPoints,
24147
+ aside: stats.branches.setAside
24148
+ }) }),
24149
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: t("statsUsage", {
24150
+ runs: stats.usage.runs,
24151
+ master: stats.usage.masterTokens.toLocaleString(),
24152
+ helpers: stats.usage.helperTokens.toLocaleString()
24153
+ }) })
24154
+ ]
24155
+ })
24156
+ ]
24157
+ });
24158
+ }
23465
24159
  // src/client/chat-settings/InterventionList.tsx
23466
24160
  /** What the story's triggers delivered lately, and whether the game master or the characters took it up, newest first. */
23467
24161
  function InterventionList({ t, entries }) {
@@ -23743,12 +24437,17 @@ window.__ModuleLoader__.load({
23743
24437
  t,
23744
24438
  entries: payload.interventions
23745
24439
  }),
24440
+ session !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatisticsSection, {
24441
+ t,
24442
+ session
24443
+ }),
23746
24444
  session !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageTable, {
23747
24445
  t,
23748
24446
  usage: payload.usage
23749
24447
  }),
23750
24448
  session !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TraceList, {
23751
24449
  t,
24450
+ session,
23752
24451
  trace: payload.trace,
23753
24452
  activity: payload.activity
23754
24453
  }),
@@ -23858,6 +24557,26 @@ window.__ModuleLoader__.load({
23858
24557
  reqCutOff: "cut off by the output limit",
23859
24558
  reqError: "failed",
23860
24559
  reqCount: "{count} requests",
24560
+ statsTitle: "Story statistics",
24561
+ statsHelp: "Counted from what the story keeps; nothing here is a judgement. Shares are of the words delivered on the way the story went.",
24562
+ statsFailed: "Could not count the story: {message}",
24563
+ statsTurns: "{count} turns on the way the story went",
24564
+ statsWaited: "You waited {time} for the game master in all (the helpers worked beside it)",
24565
+ statsStoryTime: "{span} of story time have passed",
24566
+ statsMinutes: "{count} minutes",
24567
+ statsHours: "{count} hours",
24568
+ statsDays: "{count} days",
24569
+ statsScenes: "{count} scenes (stretches of events in one place)",
24570
+ statsNarration: "Narration: {passages} passages, {share}% of the words",
24571
+ statsVoice: "{name}: {lines} lines, {share}% of the words",
24572
+ statsThreads: "Threads: {open} open, {resolved} closed",
24573
+ statsRelationships: "Relationships: {changed} of {total} have changed in play",
24574
+ statsBranches: "Branches: {points} turns were played more than once from the same state; {aside} turns were set aside",
24575
+ statsUsage: "Models: {runs} helper runs; {master} tokens for the game master, {helpers} for the helpers",
24576
+ briefCount: "brief in {count} parts",
24577
+ briefOpening: "(opening)",
24578
+ briefTokens: "about {count} tokens",
24579
+ causeOffStage: "off stage",
23861
24580
  usageEmpty: "No turn has been counted yet.",
23862
24581
  activityResult: "Result",
23863
24582
  activityOwnModel: "chat model",
@@ -24047,6 +24766,26 @@ window.__ModuleLoader__.load({
24047
24766
  reqCutOff: "被输出上限截断",
24048
24767
  reqError: "失败",
24049
24768
  reqCount: "{count} 次请求",
24769
+ statsTitle: "故事统计",
24770
+ statsHelp: "根据故事保存的内容统计,没有任何评判。占比是故事实际走过的回合中已交付文字的占比。",
24771
+ statsFailed: "无法统计这个故事:{message}",
24772
+ statsTurns: "故事实际走过 {count} 个回合",
24773
+ statsWaited: "你一共等待游戏主持人 {time}(助手与它同时工作)",
24774
+ statsStoryTime: "故事里已过去 {span}",
24775
+ statsMinutes: "{count} 分钟",
24776
+ statsHours: "{count} 小时",
24777
+ statsDays: "{count} 天",
24778
+ statsScenes: "{count} 个场景(同一地点连续发生的事件)",
24779
+ statsNarration: "旁白:{passages} 段,占文字的 {share}%",
24780
+ statsVoice: "{name}:{lines} 句,占文字的 {share}%",
24781
+ statsThreads: "线索:{open} 条未完结,{resolved} 条已完结",
24782
+ statsRelationships: "关系:{total} 条中有 {changed} 条在游玩中发生了变化",
24783
+ statsBranches: "分支:有 {points} 个回合从同一状态被玩了不止一次;{aside} 个回合被搁置",
24784
+ statsUsage: "模型:助手运行 {runs} 次;游戏主持人用了 {master} 个词元,助手用了 {helpers} 个",
24785
+ briefCount: "简报分为 {count} 部分",
24786
+ briefOpening: "(开头)",
24787
+ briefTokens: "约 {count} 个词元",
24788
+ causeOffStage: "场外",
24050
24789
  usageEmpty: "还没有统计过任何回合。",
24051
24790
  activityResult: "结果",
24052
24791
  activityOwnModel: "对话模型",
@@ -24199,16 +24938,16 @@ window.__ModuleLoader__.load({
24199
24938
  }
24200
24939
  tag$4.textContent = css$4;
24201
24940
  var CatalogueSettings_module_css_default = {
24202
- "hint": "rp_KPhXDa_hint",
24203
- "field": "rp_KPhXDa_field",
24204
- "problem": "rp_KPhXDa_problem",
24205
- "keyHint": "rp_KPhXDa_keyHint",
24206
24941
  "title": "rp_KPhXDa_title",
24207
24942
  "section": "rp_KPhXDa_section",
24208
- "row": "rp_KPhXDa_row",
24943
+ "problem": "rp_KPhXDa_problem",
24944
+ "hint": "rp_KPhXDa_hint",
24209
24945
  "keyArea": "rp_KPhXDa_keyArea",
24210
- "actions": "rp_KPhXDa_actions",
24211
- "label": "rp_KPhXDa_label"
24946
+ "label": "rp_KPhXDa_label",
24947
+ "row": "rp_KPhXDa_row",
24948
+ "keyHint": "rp_KPhXDa_keyHint",
24949
+ "field": "rp_KPhXDa_field",
24950
+ "actions": "rp_KPhXDa_actions"
24212
24951
  };
24213
24952
  // src/client/settings/AuthoringToolSettings.tsx
24214
24953
  const boardOf = (text) => {
@@ -24440,18 +25179,18 @@ window.__ModuleLoader__.load({
24440
25179
  }
24441
25180
  tag$3.textContent = css$3;
24442
25181
  var AssistantSettings_module_css_default = {
24443
- "badges": "rp_ZwzM4q_badges",
24444
25182
  "label": "rp_ZwzM4q_label",
24445
- "fieldHint": "rp_ZwzM4q_fieldHint",
24446
- "hint": "rp_ZwzM4q_hint",
24447
25183
  "invalid": "rp_ZwzM4q_invalid",
25184
+ "field": "rp_ZwzM4q_field",
24448
25185
  "section": "rp_ZwzM4q_section",
24449
25186
  "select": "rp_ZwzM4q_select",
24450
- "reset": "rp_ZwzM4q_reset",
24451
- "fields": "rp_ZwzM4q_fields",
24452
- "field": "rp_ZwzM4q_field",
24453
25187
  "head": "rp_ZwzM4q_head",
24454
- "title": "rp_ZwzM4q_title"
25188
+ "title": "rp_ZwzM4q_title",
25189
+ "fieldHint": "rp_ZwzM4q_fieldHint",
25190
+ "hint": "rp_ZwzM4q_hint",
25191
+ "fields": "rp_ZwzM4q_fields",
25192
+ "badges": "rp_ZwzM4q_badges",
25193
+ "reset": "rp_ZwzM4q_reset"
24455
25194
  };
24456
25195
  // src/client/settings/AssistantSettings.tsx
24457
25196
  function ChoiceField({ t, spec, state, disabled, onEdit, onReset }) {
@@ -25728,28 +26467,28 @@ window.__ModuleLoader__.load({
25728
26467
  }
25729
26468
  tag$2.textContent = css$2;
25730
26469
  var NarrationView_module_css_default = {
25731
- "diceList": "rp_NFPimG_diceList",
25732
- "avatar": "rp_NFPimG_avatar",
25733
- "note": "rp_NFPimG_note",
25734
- "oocNote": "rp_NFPimG_oocNote",
25735
- "line": "rp_NFPimG_line",
25736
- "imageStatus": "rp_NFPimG_imageStatus",
25737
- "playAll": "rp_NFPimG_playAll",
25738
26470
  "words": "rp_NFPimG_words",
25739
- "narration": "rp_NFPimG_narration",
25740
- "oocRefused": "rp_NFPimG_oocRefused",
25741
- "oocLabel": "rp_NFPimG_oocLabel",
25742
26471
  "name": "rp_NFPimG_name",
25743
- "diceSummary": "rp_NFPimG_diceSummary",
25744
26472
  "speech": "rp_NFPimG_speech",
25745
- "imageButton": "rp_NFPimG_imageButton",
25746
- "output": "rp_NFPimG_output",
25747
26473
  "sceneImage": "rp_NFPimG_sceneImage",
25748
- "playLine": "rp_NFPimG_playLine",
25749
- "dice": "rp_NFPimG_dice",
26474
+ "imageButton": "rp_NFPimG_imageButton",
26475
+ "imageStatus": "rp_NFPimG_imageStatus",
26476
+ "line": "rp_NFPimG_line",
26477
+ "images": "rp_NFPimG_images",
25750
26478
  "imageError": "rp_NFPimG_imageError",
26479
+ "oocLabel": "rp_NFPimG_oocLabel",
26480
+ "narration": "rp_NFPimG_narration",
25751
26481
  "preview": "rp_NFPimG_preview",
25752
- "images": "rp_NFPimG_images"
26482
+ "note": "rp_NFPimG_note",
26483
+ "playAll": "rp_NFPimG_playAll",
26484
+ "playLine": "rp_NFPimG_playLine",
26485
+ "dice": "rp_NFPimG_dice",
26486
+ "oocRefused": "rp_NFPimG_oocRefused",
26487
+ "diceSummary": "rp_NFPimG_diceSummary",
26488
+ "avatar": "rp_NFPimG_avatar",
26489
+ "oocNote": "rp_NFPimG_oocNote",
26490
+ "diceList": "rp_NFPimG_diceList",
26491
+ "output": "rp_NFPimG_output"
25753
26492
  };
25754
26493
  // src/client/transcript/PreviewNode.tsx
25755
26494
  /**
@@ -26009,10 +26748,10 @@ window.__ModuleLoader__.load({
26009
26748
  }
26010
26749
  tag$1.textContent = css$1;
26011
26750
  var SuggestionsDock_module_css_default = {
26012
- "label": "rp_rWH4DG_label",
26013
- "card": "rp_rWH4DG_card",
26014
26751
  "lines": "rp_rWH4DG_lines",
26752
+ "label": "rp_rWH4DG_label",
26015
26753
  "dock": "rp_rWH4DG_dock",
26754
+ "card": "rp_rWH4DG_card",
26016
26755
  "chip": "rp_rWH4DG_chip"
26017
26756
  };
26018
26757
  // src/client/transcript/SuggestionsDock.tsx
@@ -26120,7 +26859,7 @@ window.__ModuleLoader__.load({
26120
26859
  });
26121
26860
  }
26122
26861
  // \0css-module:/home/runner/work/dsh-agentic-roleplay/dsh-agentic-roleplay/packages/dsh-agentic-roleplay-core/src/client/transcript/TurnsDock.module.css.mjs
26123
- const css = ".rp_f4YLlq_dock{box-sizing:border-box;width:min(800px,100%);min-width:0;color:var(--dsw-alias-label-tertiary);flex-wrap:wrap;align-items:center;gap:4px 8px;margin:0 auto 8px;padding:0 16px;font-size:12px;display:flex}.rp_f4YLlq_group{align-items:center;gap:2px;display:flex}.rp_f4YLlq_button{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);min-height:28px;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;background:0 0;padding:2px 10px;line-height:18px}.rp_f4YLlq_button:hover:not(:disabled),.rp_f4YLlq_button:focus-visible{border-color:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary);outline:none}.rp_f4YLlq_button:disabled{opacity:.5;cursor:default}.rp_f4YLlq_count{text-align:center;min-width:32px}.rp_f4YLlq_select{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);min-width:96px;max-width:220px;min-height:28px;color:var(--dsw-alias-label-secondary);font:inherit;background:0 0;padding:2px 6px}.rp_f4YLlq_error{color:var(--dsw-alias-state-error-primary)}@media (pointer:coarse){.rp_f4YLlq_button,.rp_f4YLlq_select{min-height:44px}}";
26862
+ const css = ".rp_f4YLlq_dock{box-sizing:border-box;width:min(800px,100%);min-width:0;color:var(--dsw-alias-label-tertiary);flex-wrap:wrap;align-items:center;gap:4px 8px;margin:0 auto 8px;padding:0 16px;font-size:12px;display:flex}.rp_f4YLlq_group{align-items:center;gap:2px;display:flex}.rp_f4YLlq_button{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);min-height:28px;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;background:0 0;padding:2px 10px;line-height:18px}.rp_f4YLlq_button:hover:not(:disabled),.rp_f4YLlq_button:focus-visible{border-color:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary);outline:none}.rp_f4YLlq_button:disabled{opacity:.5;cursor:default}.rp_f4YLlq_count{text-align:center;min-width:32px}.rp_f4YLlq_select{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);min-width:96px;max-width:220px;min-height:28px;color:var(--dsw-alias-label-secondary);font:inherit;background:0 0;padding:2px 6px}.rp_f4YLlq_error{color:var(--dsw-alias-state-error-primary)}@media (pointer:coarse){.rp_f4YLlq_button,.rp_f4YLlq_select{min-height:44px}}.rp_f4YLlq_comparison{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);flex:100%;max-height:160px;padding:6px 10px;overflow-y:auto}.rp_f4YLlq_comparisonHead{color:var(--dsw-alias-label-secondary);justify-content:space-between;align-items:center;gap:8px;margin-bottom:4px;display:flex}.rp_f4YLlq_comparisonLine{margin:0;line-height:18px}.rp_f4YLlq_comparisonSubject{color:var(--dsw-alias-label-secondary)}";
26124
26863
  const key = "src/client/transcript/TurnsDock.module.css";
26125
26864
  let tag = document.querySelector("style[data-plugin-css=" + JSON.stringify(key) + "]");
26126
26865
  if (tag === null) {
@@ -26132,11 +26871,15 @@ window.__ModuleLoader__.load({
26132
26871
  tag.textContent = css;
26133
26872
  var TurnsDock_module_css_default = {
26134
26873
  "select": "rp_f4YLlq_select",
26874
+ "comparisonHead": "rp_f4YLlq_comparisonHead",
26135
26875
  "error": "rp_f4YLlq_error",
26136
- "count": "rp_f4YLlq_count",
26137
- "button": "rp_f4YLlq_button",
26876
+ "dock": "rp_f4YLlq_dock",
26138
26877
  "group": "rp_f4YLlq_group",
26139
- "dock": "rp_f4YLlq_dock"
26878
+ "comparison": "rp_f4YLlq_comparison",
26879
+ "button": "rp_f4YLlq_button",
26880
+ "comparisonLine": "rp_f4YLlq_comparisonLine",
26881
+ "comparisonSubject": "rp_f4YLlq_comparisonSubject",
26882
+ "count": "rp_f4YLlq_count"
26140
26883
  };
26141
26884
  // src/client/transcript/withdrawn.ts
26142
26885
  /** The rows of the transcript that belong to turns the story is not at, by the key DSH gives each row. */
@@ -26152,12 +26895,14 @@ window.__ModuleLoader__.load({
26152
26895
  * The turns of the story: swap the last one for another that was played from the same state, play it again, go back to before
26153
26896
  * any turn, or forward again. What belongs to the turns the story is not at is left out of the transcript (the log keeps it).
26154
26897
  */
26155
- function TurnsDock({ useChat, useSession, timeline, move, fill, branch, t }) {
26898
+ function TurnsDock({ useChat, useSession, timeline, move, mark, compare, fill, branch, t }) {
26156
26899
  const running = useSession((session) => session.running);
26157
26900
  const [view, setView] = (0, react.useState)();
26158
26901
  const [busy, setBusy] = (0, react.useState)(false);
26159
26902
  const [problem, setProblem] = (0, react.useState)();
26160
26903
  const [refresh, setRefresh] = (0, react.useState)(0);
26904
+ const [naming, setNaming] = (0, react.useState)();
26905
+ const [comparison, setComparison] = (0, react.useState)();
26161
26906
  const marks = useChat((chat) => {
26162
26907
  const nodes = [...chat.nodes.values()];
26163
26908
  return `${nodes.length}:${nodes.reduce((latest, node) => Math.max(latest, node.anchorSeq ?? 0), 0)}`;
@@ -26199,6 +26944,21 @@ window.__ModuleLoader__.load({
26199
26944
  });
26200
26945
  };
26201
26946
  const off = running || busy;
26947
+ const checkpoints = view.path.filter((turn) => turn.label !== void 0 && turn.restorable);
26948
+ const save = () => {
26949
+ const label = naming?.trim() ?? "";
26950
+ if (label === "") return;
26951
+ setBusy(true);
26952
+ setProblem(void 0);
26953
+ mark(last.id, label).then(() => {
26954
+ setNaming(void 0);
26955
+ setRefresh((count) => count + 1);
26956
+ }).catch((error) => {
26957
+ setProblem(error instanceof Error ? error.message : String(error));
26958
+ }).finally(() => {
26959
+ setBusy(false);
26960
+ });
26961
+ };
26202
26962
  const label = (text) => text.length > LABEL_LENGTH ? `${text.slice(0, 39)}…` : text;
26203
26963
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
26204
26964
  className: TurnsDock_module_css_default.dock,
@@ -26261,18 +27021,87 @@ window.__ModuleLoader__.load({
26261
27021
  if (draft !== void 0) fill(draft, false);
26262
27022
  });
26263
27023
  },
26264
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
26265
- value: "",
26266
- children: t("rewind")
26267
- }), [...view.path].reverse().map((turn, index, list) => {
26268
- const before = list[index + 1]?.id ?? START;
26269
- const restorable = index === list.length - 1 || list[index + 1].restorable;
26270
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
26271
- value: before,
26272
- disabled: !restorable,
26273
- children: `${t("before")} ${label(turn.player)}`
26274
- }, turn.id);
26275
- })]
27024
+ children: [
27025
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
27026
+ value: "",
27027
+ children: t("rewind")
27028
+ }),
27029
+ checkpoints.map((turn) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
27030
+ value: turn.id,
27031
+ title: turn.note,
27032
+ children: `◆ ${turn.label}`
27033
+ }, `checkpoint-${turn.id}`)),
27034
+ [...view.path].reverse().map((turn, index, list) => {
27035
+ const before = list[index + 1]?.id ?? START;
27036
+ const restorable = index === list.length - 1 || list[index + 1].restorable;
27037
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
27038
+ value: before,
27039
+ disabled: !restorable,
27040
+ children: `${t("before")} ${label(turn.player)}`
27041
+ }, turn.id);
27042
+ })
27043
+ ]
27044
+ }),
27045
+ naming === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
27046
+ type: "button",
27047
+ className: TurnsDock_module_css_default.button,
27048
+ disabled: off,
27049
+ title: last.label === void 0 ? t("checkpointHint") : t("checkpointNamed", { name: last.label }),
27050
+ onClick: () => {
27051
+ setNaming(last.label ?? "");
27052
+ },
27053
+ children: t("checkpoint")
27054
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
27055
+ className: TurnsDock_module_css_default.group,
27056
+ children: [
27057
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
27058
+ className: TurnsDock_module_css_default.select,
27059
+ autoFocus: true,
27060
+ maxLength: 80,
27061
+ value: naming,
27062
+ placeholder: t("checkpointName"),
27063
+ "aria-label": t("checkpointName"),
27064
+ onChange: (event) => {
27065
+ setNaming(event.target.value);
27066
+ },
27067
+ onKeyDown: (event) => {
27068
+ if (event.key === "Enter") save();
27069
+ if (event.key === "Escape") setNaming(void 0);
27070
+ }
27071
+ }),
27072
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
27073
+ type: "button",
27074
+ className: TurnsDock_module_css_default.button,
27075
+ disabled: off || naming.trim() === "",
27076
+ onClick: save,
27077
+ children: t("checkpointSave")
27078
+ }),
27079
+ last.label !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
27080
+ type: "button",
27081
+ className: TurnsDock_module_css_default.button,
27082
+ disabled: off,
27083
+ onClick: () => {
27084
+ setBusy(true);
27085
+ mark(last.id, "").then(() => {
27086
+ setNaming(void 0);
27087
+ setRefresh((count) => count + 1);
27088
+ }).catch((error) => {
27089
+ setProblem(error instanceof Error ? error.message : String(error));
27090
+ }).finally(() => {
27091
+ setBusy(false);
27092
+ });
27093
+ },
27094
+ children: t("checkpointRemove")
27095
+ }),
27096
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
27097
+ type: "button",
27098
+ className: TurnsDock_module_css_default.button,
27099
+ onClick: () => {
27100
+ setNaming(void 0);
27101
+ },
27102
+ children: t("checkpointCancel")
27103
+ })
27104
+ ]
26276
27105
  }),
26277
27106
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
26278
27107
  className: TurnsDock_module_css_default.select,
@@ -26300,6 +27129,45 @@ window.__ModuleLoader__.load({
26300
27129
  children: `${t("after")} ${label(turn.player)}`
26301
27130
  }, turn.id))]
26302
27131
  }),
27132
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
27133
+ className: TurnsDock_module_css_default.select,
27134
+ disabled: off,
27135
+ value: "",
27136
+ title: t("compareHint"),
27137
+ "aria-label": t("compare"),
27138
+ onChange: (event) => {
27139
+ const turn = event.target.value;
27140
+ if (turn === "") return;
27141
+ setBusy(true);
27142
+ setProblem(void 0);
27143
+ compare(turn).then(setComparison).catch((error) => {
27144
+ setProblem(error instanceof Error ? error.message : String(error));
27145
+ }).finally(() => {
27146
+ setBusy(false);
27147
+ });
27148
+ },
27149
+ children: [
27150
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
27151
+ value: "",
27152
+ children: t("compare")
27153
+ }),
27154
+ checkpoints.map((turn) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
27155
+ value: turn.id,
27156
+ disabled: !turn.restorable,
27157
+ children: `◆ ${turn.label}`
27158
+ }, `compare-${turn.id}`)),
27159
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
27160
+ value: START,
27161
+ disabled: !view.canStart,
27162
+ children: t("compareStart")
27163
+ }),
27164
+ [...view.path].reverse().map((turn) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
27165
+ value: turn.id,
27166
+ disabled: !turn.restorable,
27167
+ children: `${t("after")} ${label(turn.player)}`
27168
+ }, `compare-turn-${turn.id}`))
27169
+ ]
27170
+ }),
26303
27171
  view.forward.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
26304
27172
  type: "button",
26305
27173
  className: TurnsDock_module_css_default.button,
@@ -26315,6 +27183,39 @@ window.__ModuleLoader__.load({
26315
27183
  problem !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
26316
27184
  className: TurnsDock_module_css_default.error,
26317
27185
  children: problem
27186
+ }),
27187
+ comparison !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
27188
+ className: TurnsDock_module_css_default.comparison,
27189
+ "data-testid": "roleplay-comparison",
27190
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
27191
+ className: TurnsDock_module_css_default.comparisonHead,
27192
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("compareHeading", {
27193
+ a: comparison.a,
27194
+ b: comparison.b
27195
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
27196
+ type: "button",
27197
+ className: TurnsDock_module_css_default.button,
27198
+ onClick: () => {
27199
+ setComparison(void 0);
27200
+ },
27201
+ children: t("checkpointCancel")
27202
+ })]
27203
+ }), comparison.changes.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
27204
+ className: TurnsDock_module_css_default.comparisonLine,
27205
+ children: t("compareSame")
27206
+ }) : comparison.changes.map((change, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
27207
+ className: TurnsDock_module_css_default.comparisonLine,
27208
+ children: [
27209
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
27210
+ className: TurnsDock_module_css_default.comparisonSubject,
27211
+ children: change.subject
27212
+ }),
27213
+ ": ",
27214
+ change.a === void 0 ? t("compareNone") : change.a,
27215
+ " → ",
27216
+ change.b === void 0 ? t("compareNone") : change.b
27217
+ ]
27218
+ }, index))]
26318
27219
  })
26319
27220
  ]
26320
27221
  });
@@ -26340,6 +27241,19 @@ window.__ModuleLoader__.load({
26340
27241
  after: "After",
26341
27242
  branchHint: "Start a new session from the story as it stands after a turn; this one stays as it is",
26342
27243
  branchFailed: "Could not branch the story: {message}",
27244
+ checkpoint: "◆ Checkpoint",
27245
+ checkpointHint: "Name the story as it stands now, so it can be gone back to and found again",
27246
+ checkpointNamed: "This turn is the checkpoint “{name}”: rename it or take the name off",
27247
+ checkpointName: "Name of the checkpoint",
27248
+ checkpointSave: "Save",
27249
+ checkpointRemove: "Remove",
27250
+ checkpointCancel: "Cancel",
27251
+ compare: "⇄ Compare with…",
27252
+ compareHint: "See what differs between the story now and its state after a turn",
27253
+ compareStart: "The start",
27254
+ compareHeading: "{a} → {b}",
27255
+ compareSame: "Nothing differs.",
27256
+ compareNone: "(none)",
26343
27257
  redoHint: "Go forward again to the turn that was taken back",
26344
27258
  repaired: "Corrected so that every spoken line is exactly what the character said.",
26345
27259
  suggestions: "You could",
@@ -26380,6 +27294,19 @@ window.__ModuleLoader__.load({
26380
27294
  after: "在此之后:",
26381
27295
  branchHint: "从某一回合之后的故事另起一个新会话,当前会话保持不变",
26382
27296
  branchFailed: "无法创建分支:{message}",
27297
+ checkpoint: "◆ 检查点",
27298
+ checkpointHint: "给当前的故事起个名字,以便日后回到这里",
27299
+ checkpointNamed: "这一回合是检查点“{name}”:可以改名或取消",
27300
+ checkpointName: "检查点名称",
27301
+ checkpointSave: "保存",
27302
+ checkpointRemove: "移除",
27303
+ checkpointCancel: "取消",
27304
+ compare: "⇄ 对比…",
27305
+ compareHint: "查看现在的故事与某一回合之后的状态有什么不同",
27306
+ compareStart: "开头",
27307
+ compareHeading: "{a} → {b}",
27308
+ compareSame: "没有差别。",
27309
+ compareNone: "(无)",
26383
27310
  redoHint: "重新前进到被回退的回合",
26384
27311
  repaired: "已修正,确保每句台词与角色原话一致。",
26385
27312
  suggestions: "你可以",
@@ -26425,6 +27352,28 @@ window.__ModuleLoader__.load({
26425
27352
  if (!response.ok) throw new Error((await response.json().catch(() => ({}))).message ?? `the story could not be taken there (${response.status})`);
26426
27353
  return await response.json();
26427
27354
  }
27355
+ /** Names a turn as a checkpoint (an empty name takes it off). */
27356
+ async function markTurn(chat, turn, label, note) {
27357
+ const id = roleplaySessionOf(chat);
27358
+ if (id === void 0) throw new Error("this chat is not a roleplay session");
27359
+ const response = await fetch(`roleplay-api/sessions/timeline/checkpoint?id=${encodeURIComponent(id)}&turn=${encodeURIComponent(turn)}`, {
27360
+ method: "POST",
27361
+ headers: { "content-type": "application/json" },
27362
+ body: JSON.stringify({
27363
+ label,
27364
+ ...note === void 0 ? {} : { note }
27365
+ })
27366
+ });
27367
+ if (!response.ok) throw new Error((await response.json().catch(() => ({}))).message ?? `the checkpoint could not be made (${response.status})`);
27368
+ }
27369
+ /** What differs between the story now and the state after a turn. */
27370
+ async function compareWith(chat, turn) {
27371
+ const id = roleplaySessionOf(chat);
27372
+ if (id === void 0) throw new Error("this chat is not a roleplay session");
27373
+ const response = await fetch(`roleplay-api/sessions/compare?id=${encodeURIComponent(id)}&a=${encodeURIComponent(turn)}&b=head`);
27374
+ if (!response.ok) throw new Error((await response.json().catch(() => ({}))).message ?? `the states could not be compared (${response.status})`);
27375
+ return await response.json();
27376
+ }
26428
27377
  /** Branches a roleplay chat after the turn that ended at `atSeq`, and shows the new chat. Resolved on use, so a client without the services fails at the click. */
26429
27378
  async function branchAt(scope, chat, atSeq) {
26430
27379
  const sessions = scope.get("sessions");
@@ -26460,6 +27409,8 @@ window.__ModuleLoader__.load({
26460
27409
  inject: (sessionId) => ({
26461
27410
  timeline: () => timelineOf(sessionId),
26462
27411
  move: (to) => moveTo(sessionId, to),
27412
+ mark: (turn, label, note) => markTurn(sessionId, turn, label, note),
27413
+ compare: (turn) => compareWith(sessionId, turn),
26463
27414
  fill: facadeOf(scope, sessionId).fill,
26464
27415
  branch: (atSeq) => branchAt(scope, sessionId, atSeq)
26465
27416
  })