@dxos/shell 0.6.14-main.f49f251 → 0.6.14-staging.8758a12

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 (65) hide show
  1. package/dist/bundle/shell.mjs +1365 -1355
  2. package/dist/bundle/shell.mjs.map +1 -1
  3. package/dist/bundle/shell.umd.js +29 -29
  4. package/dist/bundle/shell.umd.js.map +1 -1
  5. package/dist/bundle/style.css +1 -1
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/react.mjs +11 -8
  8. package/dist/lib/browser/react.mjs.map +3 -3
  9. package/dist/lib/browser/testing/index.mjs +1 -39
  10. package/dist/lib/browser/testing/index.mjs.map +4 -4
  11. package/dist/lib/node/chunk-Q7SFCCGT.cjs +33 -0
  12. package/dist/lib/node/chunk-Q7SFCCGT.cjs.map +7 -0
  13. package/dist/lib/node/meta.json +1 -0
  14. package/dist/lib/node/react.cjs +4766 -0
  15. package/dist/lib/node/react.cjs.map +7 -0
  16. package/dist/lib/node/react.css +7 -0
  17. package/dist/lib/node/react.css.map +7 -0
  18. package/dist/lib/node/testing/index.cjs +181 -0
  19. package/dist/lib/node/testing/index.cjs.map +7 -0
  20. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  21. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  22. package/dist/lib/node-esm/meta.json +1 -0
  23. package/dist/lib/node-esm/react.css +7 -0
  24. package/dist/lib/node-esm/react.css.map +7 -0
  25. package/dist/lib/node-esm/react.mjs +4812 -0
  26. package/dist/lib/node-esm/react.mjs.map +7 -0
  27. package/dist/lib/node-esm/testing/index.mjs +161 -0
  28. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  29. package/dist/types/src/components/IdentityList/SpaceMemberList.stories.js +2 -2
  30. package/dist/types/src/components/IdentityList/SpaceMemberList.stories.js.map +1 -1
  31. package/dist/types/src/components/InvitationList/InvitationList.stories.js +10 -10
  32. package/dist/types/src/components/InvitationList/InvitationList.stories.js.map +1 -1
  33. package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -1
  34. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +13 -6
  35. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
  36. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +1 -0
  37. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -1
  38. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +1 -1
  39. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
  40. package/dist/types/src/panels/IdentityPanel/useEdgeAgentsHandlers.d.ts.map +1 -1
  41. package/dist/types/src/panels/IdentityPanel/useEdgeAgentsHandlers.js +5 -0
  42. package/dist/types/src/panels/IdentityPanel/useEdgeAgentsHandlers.js.map +1 -1
  43. package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js +15 -15
  44. package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js.map +1 -1
  45. package/dist/types/src/playwright/invitations-manager.d.ts +1 -2
  46. package/dist/types/src/playwright/invitations-manager.d.ts.map +1 -1
  47. package/dist/types/src/playwright/invitations-manager.js +2 -3
  48. package/dist/types/src/playwright/invitations-manager.js.map +1 -1
  49. package/dist/types/src/playwright/invitations.spec.js +13 -9
  50. package/dist/types/src/playwright/invitations.spec.js.map +1 -1
  51. package/dist/types/src/testing/index.d.ts +0 -1
  52. package/dist/types/src/testing/index.d.ts.map +1 -1
  53. package/dist/types/src/testing/index.js +1 -1
  54. package/dist/types/src/testing/index.js.map +1 -1
  55. package/package.json +38 -27
  56. package/src/components/IdentityList/SpaceMemberList.stories.tsx +1 -1
  57. package/src/components/InvitationList/InvitationList.stories.tsx +1 -1
  58. package/src/panels/IdentityPanel/IdentityPanel.tsx +13 -3
  59. package/src/panels/IdentityPanel/IdentityPanelProps.ts +1 -0
  60. package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +1 -1
  61. package/src/panels/IdentityPanel/useEdgeAgentsHandlers.ts +7 -0
  62. package/src/panels/SpacePanel/SpacePanel.stories.tsx +1 -1
  63. package/src/playwright/invitations-manager.ts +2 -3
  64. package/src/playwright/invitations.spec.ts +14 -9
  65. package/src/testing/index.ts +2 -1
@@ -0,0 +1,4766 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var react_exports = {};
30
+ __export(react_exports, {
31
+ Action: () => Action,
32
+ Actions: () => Actions,
33
+ AgentConfig: () => AgentConfig,
34
+ AuthCode: () => AuthCode,
35
+ BifurcatedAction: () => BifurcatedAction,
36
+ Centered: () => Centered,
37
+ ClipboardContext: () => ClipboardContext,
38
+ ClipboardProvider: () => ClipboardProvider,
39
+ CloseButton: () => CloseButton,
40
+ CompoundButton: () => CompoundButton,
41
+ ConfirmReset: () => ConfirmReset,
42
+ ConfirmResetImpl: () => ConfirmResetImpl,
43
+ CopyButton: () => CopyButton,
44
+ CopyButtonIconOnly: () => CopyButtonIconOnly,
45
+ DeviceList: () => DeviceList,
46
+ Emoji: () => Emoji,
47
+ EmojiPickerBlock: () => EmojiPickerBlock,
48
+ EmojiPickerToolbarButton: () => EmojiPickerToolbarButton,
49
+ Heading: () => Heading,
50
+ HuePickerBlock: () => HuePickerBlock,
51
+ HuePickerToolbarButton: () => HuePickerToolbarButton,
52
+ IdentityDialog: () => IdentityDialog,
53
+ IdentityListItem: () => IdentityListItem,
54
+ IdentityPanel: () => IdentityPanel,
55
+ IdentityPanelImpl: () => IdentityPanelImpl,
56
+ Input: () => Input,
57
+ InvitationList: () => InvitationList,
58
+ InvitationListContainer: () => InvitationListContainer,
59
+ InvitationListItem: () => InvitationListItem,
60
+ InvitationListItemImpl: () => InvitationListItemImpl,
61
+ InvitationManager: () => InvitationManager,
62
+ JoinDialog: () => JoinDialog,
63
+ JoinPanel: () => JoinPanel,
64
+ JoinPanelImpl: () => JoinPanelImpl,
65
+ Label: () => Label,
66
+ Shell: () => Shell,
67
+ ShellContext: () => ShellContext,
68
+ ShellProvider: () => ShellProvider,
69
+ SpaceDialog: () => SpaceDialog,
70
+ SpaceListItem: () => SpaceListItem,
71
+ SpaceMemberList: () => SpaceMemberList,
72
+ SpaceMemberListImpl: () => SpaceMemberListImpl,
73
+ SpacePanel: () => SpacePanel,
74
+ SpacePanelImpl: () => SpacePanelImpl,
75
+ StatusPanel: () => StatusPanel,
76
+ StepHeading: () => StepHeading,
77
+ Viewport: () => Viewport,
78
+ activeBgColor: () => activeBgColor,
79
+ activeStrokeColor: () => activeStrokeColor,
80
+ activeTextColor: () => activeTextColor,
81
+ cancelledBgColor: () => cancelledBgColor,
82
+ cancelledStrokeColor: () => cancelledStrokeColor,
83
+ cancelledTextColor: () => cancelledTextColor,
84
+ createViewportScope: () => createViewportScope,
85
+ errorBgColor: () => errorBgColor,
86
+ errorStrokeColor: () => errorStrokeColor,
87
+ errorTextColor: () => errorTextColor,
88
+ inactiveBgColor: () => inactiveBgColor,
89
+ inactiveStrokeColor: () => inactiveStrokeColor,
90
+ inactiveTextColor: () => inactiveTextColor,
91
+ osTranslations: () => osTranslations,
92
+ resolvedBgColor: () => resolvedBgColor,
93
+ resolvedStrokeColor: () => resolvedStrokeColor,
94
+ resolvedTextColor: () => resolvedTextColor,
95
+ runShell: () => runShell,
96
+ stepStyles: () => stepStyles,
97
+ successBgColor: () => successBgColor,
98
+ successStrokeColor: () => successStrokeColor,
99
+ successTextColor: () => successTextColor,
100
+ useClipboardContext: () => useClipboardContext,
101
+ useShell: () => useShell,
102
+ useViewportContext: () => useViewportContext
103
+ });
104
+ module.exports = __toCommonJS(react_exports);
105
+ var import_chunk_Q7SFCCGT = require("./chunk-Q7SFCCGT.cjs");
106
+ var import_react = require("@phosphor-icons/react");
107
+ var import_react2 = __toESM(require("react"));
108
+ var import_react_ui = require("@dxos/react-ui");
109
+ var import_react_ui_theme = require("@dxos/react-ui-theme");
110
+ var import_react3 = require("@phosphor-icons/react");
111
+ var import_react4 = __toESM(require("react"));
112
+ var import_react_ui2 = require("@dxos/react-ui");
113
+ var import_react_ui_theme2 = require("@dxos/react-ui-theme");
114
+ var import_react5 = __toESM(require("react"));
115
+ var import_react6 = __toESM(require("react"));
116
+ var import_react_ui3 = require("@dxos/react-ui");
117
+ var import_react_ui_theme3 = require("@dxos/react-ui-theme");
118
+ var import_data = __toESM(require("@emoji-mart/data"));
119
+ var import_react7 = __toESM(require("@emoji-mart/react"));
120
+ var import_react8 = require("@phosphor-icons/react");
121
+ var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
122
+ var import_react9 = __toESM(require("react"));
123
+ var import_react_ui4 = require("@dxos/react-ui");
124
+ var import_react_ui_theme4 = require("@dxos/react-ui-theme");
125
+ var import_react10 = require("@phosphor-icons/react");
126
+ var import_react_use_controllable_state2 = require("@radix-ui/react-use-controllable-state");
127
+ var import_react11 = __toESM(require("react"));
128
+ var import_react_ui5 = require("@dxos/react-ui");
129
+ var import_react_ui_theme5 = require("@dxos/react-ui-theme");
130
+ var import_react12 = __toESM(require("react"));
131
+ var import_display_name = require("@dxos/display-name");
132
+ var import_echo = require("@dxos/react-client/echo");
133
+ var import_react_ui6 = require("@dxos/react-ui");
134
+ var import_react_ui_theme6 = require("@dxos/react-ui-theme");
135
+ var import_util = require("@dxos/util");
136
+ var import_react13 = __toESM(require("react"));
137
+ var import_react_client = require("@dxos/react-client");
138
+ var import_echo2 = require("@dxos/react-client/echo");
139
+ var import_react_ui7 = require("@dxos/react-ui");
140
+ var import_react_ui_theme7 = require("@dxos/react-ui-theme");
141
+ var import_react14 = require("@phosphor-icons/react");
142
+ var import_react15 = __toESM(require("react"));
143
+ var import_react_ui8 = require("@dxos/react-ui");
144
+ var import_react_ui_theme8 = require("@dxos/react-ui-theme");
145
+ var import_react16 = require("@phosphor-icons/react");
146
+ var import_react17 = __toESM(require("react"));
147
+ var import_display_name2 = require("@dxos/display-name");
148
+ var import_halo = require("@dxos/react-client/halo");
149
+ var import_mesh = require("@dxos/react-client/mesh");
150
+ var import_react_ui9 = require("@dxos/react-ui");
151
+ var import_react_ui_theme9 = require("@dxos/react-ui-theme");
152
+ var import_util2 = require("@dxos/util");
153
+ var import_react18 = require("@phosphor-icons/react");
154
+ var import_date_fns = require("date-fns");
155
+ var import_react19 = __toESM(require("react"));
156
+ var import_invitations = require("@dxos/react-client/invitations");
157
+ var import_react_ui10 = require("@dxos/react-ui");
158
+ var import_react_ui_theme10 = require("@dxos/react-ui-theme");
159
+ var import_util3 = require("@dxos/util");
160
+ var import_react20 = __toESM(require("react"));
161
+ var import_react_ui_theme11 = require("@dxos/react-ui-theme");
162
+ var import_react21 = __toESM(require("react"));
163
+ var import_echo3 = require("@dxos/react-client/echo");
164
+ var import_react22 = __toESM(require("react"));
165
+ var import_react_ui11 = require("@dxos/react-ui");
166
+ var import_react_ui_theme12 = require("@dxos/react-ui-theme");
167
+ var import_react23 = require("@phosphor-icons/react");
168
+ var import_react_use_controllable_state3 = require("@radix-ui/react-use-controllable-state");
169
+ var import_react24 = __toESM(require("react"));
170
+ var import_react_ui12 = require("@dxos/react-ui");
171
+ var import_react_ui_theme13 = require("@dxos/react-ui-theme");
172
+ var import_react25 = __toESM(require("react"));
173
+ var import_react_ui_theme14 = require("@dxos/react-ui-theme");
174
+ var import_react26 = require("@phosphor-icons/react");
175
+ var import_react27 = __toESM(require("react"));
176
+ var import_react_ui13 = require("@dxos/react-ui");
177
+ var import_react_ui_theme15 = require("@dxos/react-ui-theme");
178
+ var import_react28 = __toESM(require("react"));
179
+ var import_react_ui_theme16 = require("@dxos/react-ui-theme");
180
+ var import_react29 = __toESM(require("react"));
181
+ var import_react_ui_theme17 = require("@dxos/react-ui-theme");
182
+ var import_react30 = __toESM(require("react"));
183
+ var import_react_ui_theme18 = require("@dxos/react-ui-theme");
184
+ var import_react31 = __toESM(require("react"));
185
+ var import_react_ui14 = require("@dxos/react-ui");
186
+ var import_react32 = __toESM(require("react"));
187
+ var import_react_ui_theme19 = require("@dxos/react-ui-theme");
188
+ var import_react_tabster = require("@fluentui/react-tabster");
189
+ var import_react_context = require("@radix-ui/react-context");
190
+ var import_react_use_controllable_state4 = require("@radix-ui/react-use-controllable-state");
191
+ var import_react33 = __toESM(require("react"));
192
+ var import_react_ui15 = require("@dxos/react-ui");
193
+ var import_react_ui_theme20 = require("@dxos/react-ui-theme");
194
+ var import_react34 = __toESM(require("react"));
195
+ var import_react_ui16 = require("@dxos/react-ui");
196
+ var import_react_ui_theme21 = require("@dxos/react-ui-theme");
197
+ var import_util4 = require("@dxos/util");
198
+ var import_react35 = __toESM(require("react"));
199
+ var import_react_ui17 = require("@dxos/react-ui");
200
+ var import_react36 = require("@phosphor-icons/react");
201
+ var import_react37 = __toESM(require("react"));
202
+ var import_display_name3 = require("@dxos/display-name");
203
+ var import_invariant = require("@dxos/invariant");
204
+ var import_log = require("@dxos/log");
205
+ var import_react_client2 = require("@dxos/react-client");
206
+ var import_halo2 = require("@dxos/react-client/halo");
207
+ var import_invitations2 = require("@dxos/react-client/invitations");
208
+ var import_mesh2 = require("@dxos/react-client/mesh");
209
+ var import_react_ui18 = require("@dxos/react-ui");
210
+ var import_react_ui_theme22 = require("@dxos/react-ui-theme");
211
+ var import_util5 = require("@dxos/util");
212
+ var import_react38 = require("@xstate/react");
213
+ var import_xstate = require("xstate");
214
+ var import_log2 = require("@dxos/log");
215
+ var import_react39 = __toESM(require("react"));
216
+ var import_log3 = require("@dxos/log");
217
+ var import_react_client3 = require("@dxos/react-client");
218
+ var import_halo3 = require("@dxos/react-client/halo");
219
+ var import_invitations3 = require("@dxos/react-client/invitations");
220
+ var import_react40 = __toESM(require("react"));
221
+ var import_log4 = require("@dxos/log");
222
+ var import_react_ui19 = require("@dxos/react-ui");
223
+ var import_util6 = require("@dxos/util");
224
+ var import_react_client4 = require("@dxos/react-client");
225
+ var import_react41 = require("react");
226
+ var import_invariant2 = require("@dxos/invariant");
227
+ var import_services = require("@dxos/protocols/proto/dxos/client/services");
228
+ var import_metadata = require("@dxos/protocols/proto/dxos/echo/metadata");
229
+ var import_react_client5 = require("@dxos/react-client");
230
+ var import_react42 = require("react");
231
+ var import_invariant3 = require("@dxos/invariant");
232
+ var import_log5 = require("@dxos/log");
233
+ var import_react_client6 = require("@dxos/react-client");
234
+ var import_invitations4 = require("@dxos/react-client/invitations");
235
+ var import_react43 = require("@phosphor-icons/react");
236
+ var import_react44 = __toESM(require("react"));
237
+ var import_react_qr_rounded = require("react-qr-rounded");
238
+ var import_react_ui20 = require("@dxos/react-ui");
239
+ var import_react_ui_theme23 = require("@dxos/react-ui-theme");
240
+ var import_util7 = require("@dxos/util");
241
+ var import_invitations5 = require("@dxos/react-client/invitations");
242
+ var import_react45 = require("@phosphor-icons/react");
243
+ var import_react46 = __toESM(require("react"));
244
+ var import_log6 = require("@dxos/log");
245
+ var import_react_ui21 = require("@dxos/react-ui");
246
+ var import_react_ui_theme24 = require("@dxos/react-ui-theme");
247
+ var import_react47 = __toESM(require("react"));
248
+ var import_log7 = require("@dxos/log");
249
+ var import_react_client7 = require("@dxos/react-client");
250
+ var import_halo4 = require("@dxos/react-client/halo");
251
+ var import_react_ui22 = require("@dxos/react-ui");
252
+ var import_react48 = require("@phosphor-icons/react");
253
+ var import_react49 = __toESM(require("react"));
254
+ var import_react_ui23 = require("@dxos/react-ui");
255
+ var import_react_ui_theme25 = require("@dxos/react-ui-theme");
256
+ var import_react50 = require("@xstate/react");
257
+ var import_react51 = require("react");
258
+ var import_xstate2 = require("xstate");
259
+ var import_log8 = require("@dxos/log");
260
+ var import_react_client8 = require("@dxos/react-client");
261
+ var import_invitations6 = require("@dxos/react-client/invitations");
262
+ var import_react52 = require("@phosphor-icons/react");
263
+ var import_react53 = __toESM(require("react"));
264
+ var import_react_ui24 = require("@dxos/react-ui");
265
+ var import_react_ui_theme26 = require("@dxos/react-ui-theme");
266
+ var import_react54 = __toESM(require("react"));
267
+ var import_display_name4 = require("@dxos/display-name");
268
+ var import_react_ui25 = require("@dxos/react-ui");
269
+ var import_react_ui_theme27 = require("@dxos/react-ui-theme");
270
+ var import_util8 = require("@dxos/util");
271
+ var import_react55 = __toESM(require("react"));
272
+ var import_log9 = require("@dxos/log");
273
+ var import_react_client9 = require("@dxos/react-client");
274
+ var import_react_ui26 = require("@dxos/react-ui");
275
+ var import_react56 = __toESM(require("react"));
276
+ var import_react_ui27 = require("@dxos/react-ui");
277
+ var import_react57 = __toESM(require("react"));
278
+ var import_log10 = require("@dxos/log");
279
+ var import_react_ui28 = require("@dxos/react-ui");
280
+ var import_react58 = __toESM(require("react"));
281
+ var import_react_ui29 = require("@dxos/react-ui");
282
+ var import_react_ui_theme28 = require("@dxos/react-ui-theme");
283
+ var import_react59 = __toESM(require("react"));
284
+ var import_invitations7 = require("@dxos/react-client/invitations");
285
+ var import_react_ui30 = require("@dxos/react-ui");
286
+ var import_react_ui_theme29 = require("@dxos/react-ui-theme");
287
+ var import_util9 = require("@dxos/util");
288
+ var import_invitations8 = require("@dxos/react-client/invitations");
289
+ var import_react60 = require("@phosphor-icons/react");
290
+ var import_react61 = __toESM(require("react"));
291
+ var import_log11 = require("@dxos/log");
292
+ var import_invitations9 = require("@dxos/react-client/invitations");
293
+ var import_react_ui31 = require("@dxos/react-ui");
294
+ var import_react62 = require("@xstate/react");
295
+ var import_xstate3 = require("xstate");
296
+ var import_log12 = require("@dxos/log");
297
+ var import_react63 = require("@phosphor-icons/react");
298
+ var import_react64 = __toESM(require("react"));
299
+ var import_log13 = require("@dxos/log");
300
+ var import_react_client10 = require("@dxos/react-client");
301
+ var import_echo4 = require("@dxos/react-client/echo");
302
+ var import_invitations10 = require("@dxos/react-client/invitations");
303
+ var import_react_ui32 = require("@dxos/react-ui");
304
+ var import_react_ui_theme30 = require("@dxos/react-ui-theme");
305
+ var import_react65 = __toESM(require("react"));
306
+ var import_react_ui33 = require("@dxos/react-ui");
307
+ var import_react66 = __toESM(require("react"));
308
+ var import_react_ui34 = require("@dxos/react-ui");
309
+ var import_react67 = __toESM(require("react"));
310
+ var import_client = require("react-dom/client");
311
+ var import_client_protocol = require("@dxos/client-protocol");
312
+ var import_react_client11 = require("@dxos/react-client");
313
+ var import_react_ui35 = require("@dxos/react-ui");
314
+ var import_react_ui_theme31 = require("@dxos/react-ui-theme");
315
+ var import_rpc_tunnel = require("@dxos/rpc-tunnel");
316
+ var import_react68 = __toESM(require("react"));
317
+ var import_log14 = require("@dxos/log");
318
+ var import_react_client12 = require("@dxos/react-client");
319
+ var import_react_client13 = require("@dxos/react-client");
320
+ var import_echo5 = require("@dxos/react-client/echo");
321
+ var import_react69 = __toESM(require("react"));
322
+ var import_react_ui36 = require("@dxos/react-ui");
323
+ var import_react70 = __toESM(require("react"));
324
+ var import_react_ui37 = require("@dxos/react-ui");
325
+ var import_async = require("@dxos/async");
326
+ var import_client_protocol2 = require("@dxos/client-protocol");
327
+ var import_invariant4 = require("@dxos/invariant");
328
+ var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
329
+ var import_rpc = require("@dxos/rpc");
330
+ var import_react71 = __toESM(require("react"));
331
+ var import_react_client14 = require("@dxos/react-client");
332
+ var import_halo5 = require("@dxos/react-client/halo");
333
+ var import_react_ui_theme32 = require("@dxos/react-ui-theme");
334
+ var import_async2 = require("@dxos/async");
335
+ var import_react_client15 = require("@dxos/react-client");
336
+ var AgentConfig = ({ agentStatus, validationMessage, onAgentDestroy, onAgentCreate, onAgentRefresh }) => {
337
+ const { t } = (0, import_react_ui.useTranslation)("os");
338
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h2", {
339
+ className: (0, import_react_ui_theme.mx)(import_react_ui_theme.descriptionText, "text-center mbs-4")
340
+ }, t("agent heading")), validationMessage && /* @__PURE__ */ import_react2.default.createElement("p", {
341
+ role: "alert",
342
+ className: (0, import_react_ui_theme.mx)((0, import_react_ui_theme.valenceColorText)("error"), "mlb-2")
343
+ }, validationMessage), agentStatus === "created" || agentStatus === "creating" || agentStatus === "getting" || agentStatus === "destroying" ? /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", {
344
+ role: "group",
345
+ className: "mlb-2 flex gap-2 items-center",
346
+ "aria-describedby": "devices-panel.create-agent.description"
347
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Avatar.Root, {
348
+ status: agentStatus === "created" ? "warning" : "inactive",
349
+ variant: "square"
350
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Avatar.Frame, {
351
+ classNames: "place-self-center"
352
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react.Database, {
353
+ weight: "duotone",
354
+ width: 24,
355
+ height: 24,
356
+ x: 8,
357
+ y: 8,
358
+ ...agentStatus !== "created" && {
359
+ className: "opacity-50"
360
+ }
361
+ })), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Avatar.Label, {
362
+ classNames: "flex-1 text-sm truncate"
363
+ }, t(agentStatus === "created" ? "agent requested label" : agentStatus === "creating" ? "creating agent label" : agentStatus === "destroying" ? "destroying agent label" : "getting agent label"))), agentStatus === "created" && /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Tooltip.Root, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Tooltip.Trigger, {
364
+ asChild: true
365
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Button, {
366
+ variant: "ghost",
367
+ classNames: "pli-0 is-[--rail-action] bs-[--rail-action]",
368
+ "data-testid": "agent.destroy",
369
+ onClick: onAgentDestroy
370
+ }, /* @__PURE__ */ import_react2.default.createElement("span", {
371
+ className: "sr-only"
372
+ }, t("destroy agent label")), /* @__PURE__ */ import_react2.default.createElement(import_react.Power, {
373
+ className: (0, import_react_ui_theme.getSize)(5)
374
+ }))), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Tooltip.Portal, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Tooltip.Content, {
375
+ side: "bottom",
376
+ classNames: "z-50"
377
+ }, t("destroy agent label"))))), agentStatus === "created" && /* @__PURE__ */ import_react2.default.createElement("p", {
378
+ id: "devices-panel.create-agent.description",
379
+ className: (0, import_react_ui_theme.mx)(import_react_ui_theme.descriptionText, "mlb-2")
380
+ }, t("agent requested description"))) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Button, {
381
+ variant: "ghost",
382
+ classNames: "mlb-2 is-full justify-start gap-2 !pis-0 !pie-3",
383
+ "data-testid": agentStatus === "creatable" ? "devices-panel.create-agent" : "devices-panel.agent-error",
384
+ onClick: agentStatus === "creatable" ? onAgentCreate : onAgentRefresh,
385
+ "aria-describedby": "devices-panel.create-agent.description"
386
+ }, /* @__PURE__ */ import_react2.default.createElement("div", {
387
+ role: "img",
388
+ className: (0, import_react_ui_theme.mx)((0, import_react_ui_theme.getSize)(8), "m-1 rounded-sm bg-input grid place-items-center")
389
+ }, agentStatus === "creatable" ? /* @__PURE__ */ import_react2.default.createElement(import_react.Plus, {
390
+ weight: "light",
391
+ className: (0, import_react_ui_theme.getSize)(6)
392
+ }) : /* @__PURE__ */ import_react2.default.createElement(import_react.ArrowsClockwise, {
393
+ weight: "light",
394
+ className: (0, import_react_ui_theme.getSize)(6)
395
+ })), /* @__PURE__ */ import_react2.default.createElement("span", {
396
+ className: "grow font-medium text-start"
397
+ }, t(agentStatus === "creatable" ? "create agent label" : ""))), agentStatus === "creatable" && /* @__PURE__ */ import_react2.default.createElement("div", {
398
+ role: "none",
399
+ className: "space-y-2",
400
+ id: "devices-panel.create-agent.description"
401
+ }, /* @__PURE__ */ import_react2.default.createElement("p", {
402
+ className: import_react_ui_theme.descriptionText
403
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Trans, {
404
+ t,
405
+ i18nKey: "create agent clickwrap",
406
+ components: {
407
+ tosLink: /* @__PURE__ */ import_react2.default.createElement(import_react_ui.Link, {
408
+ target: "_blank",
409
+ rel: "noreferrer"
410
+ })
411
+ }
412
+ })), /* @__PURE__ */ import_react2.default.createElement("p", {
413
+ className: import_react_ui_theme.descriptionText
414
+ }, t("create agent description")))));
415
+ };
416
+ var ClipboardContext = /* @__PURE__ */ (0, import_react5.createContext)({
417
+ textValue: "",
418
+ setTextValue: async (_) => {
419
+ }
420
+ });
421
+ var useClipboardContext = () => (0, import_react5.useContext)(ClipboardContext);
422
+ var ClipboardProvider = ({ children }) => {
423
+ const [textValue, setInternalTextValue] = (0, import_react5.useState)("");
424
+ const setTextValue = (0, import_react5.useCallback)(async (nextValue) => {
425
+ await navigator.clipboard.writeText(nextValue);
426
+ return setInternalTextValue(nextValue);
427
+ }, []);
428
+ return /* @__PURE__ */ import_react5.default.createElement(ClipboardContext.Provider, {
429
+ value: {
430
+ textValue,
431
+ setTextValue
432
+ }
433
+ }, children);
434
+ };
435
+ var inactiveLabelStyles = "invisible bs-px -mbe-px overflow-hidden";
436
+ var CopyButton = ({ value, classNames, iconProps: iconProps2, ...props }) => {
437
+ const { t } = (0, import_react_ui2.useTranslation)("os");
438
+ const { textValue, setTextValue } = useClipboardContext();
439
+ const isCopied = textValue === value;
440
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Button, {
441
+ ...props,
442
+ classNames: [
443
+ "inline-flex flex-col justify-center",
444
+ classNames
445
+ ],
446
+ onClick: () => setTextValue(value),
447
+ "data-testid": "copy-invitation"
448
+ }, /* @__PURE__ */ import_react4.default.createElement("div", {
449
+ role: "none",
450
+ className: (0, import_react_ui_theme2.mx)("flex gap-1 items-center", isCopied && inactiveLabelStyles)
451
+ }, /* @__PURE__ */ import_react4.default.createElement("span", {
452
+ className: "pli-1"
453
+ }, t("copy invitation code label")), /* @__PURE__ */ import_react4.default.createElement(import_react3.Copy, {
454
+ className: (0, import_react_ui_theme2.getSize)(5),
455
+ ...iconProps2
456
+ })), /* @__PURE__ */ import_react4.default.createElement("div", {
457
+ role: "none",
458
+ className: (0, import_react_ui_theme2.mx)("flex gap-1 items-center", !isCopied && inactiveLabelStyles)
459
+ }, /* @__PURE__ */ import_react4.default.createElement("span", {
460
+ className: "pli-1"
461
+ }, t("copy success label")), /* @__PURE__ */ import_react4.default.createElement(import_react3.Check, {
462
+ className: (0, import_react_ui_theme2.getSize)(5),
463
+ ...iconProps2
464
+ })));
465
+ };
466
+ var CopyButtonIconOnly = ({ value, classNames, iconProps: iconProps2, variant, ...props }) => {
467
+ const { t } = (0, import_react_ui2.useTranslation)("os");
468
+ const { textValue, setTextValue } = useClipboardContext();
469
+ const isCopied = textValue === value;
470
+ const label = isCopied ? t("copy success label") : t("copy invitation code label");
471
+ const [open, setOpen] = (0, import_react4.useState)(false);
472
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Root, {
473
+ delayDuration: 1500,
474
+ open,
475
+ onOpenChange: setOpen
476
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Content, {
477
+ side: "bottom",
478
+ sideOffset: 12,
479
+ classNames: "z-30"
480
+ }, /* @__PURE__ */ import_react4.default.createElement("span", null, label), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Arrow, null))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Tooltip.Trigger, {
481
+ "aria-label": label,
482
+ ...props,
483
+ onClick: () => setTextValue(value).then(() => setOpen(true)),
484
+ "data-testid": "copy-invitation",
485
+ asChild: true
486
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Button, {
487
+ variant,
488
+ classNames: [
489
+ "inline-flex flex-col justify-center",
490
+ classNames
491
+ ]
492
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react3.Copy, {
493
+ className: (0, import_react_ui_theme2.getSize)(5),
494
+ ...iconProps2
495
+ }))));
496
+ };
497
+ var CompoundButton = ({ children, description, before, after, variant = "default", elevation: propsElevation, slots = {}, ...buttonProps }) => {
498
+ const labelId = (0, import_react_ui3.useId)("compoundButton-label");
499
+ const descriptionId = (0, import_react_ui3.useId)("compoundButton-description");
500
+ const { tx } = (0, import_react_ui3.useThemeContext)();
501
+ const elevation = (0, import_react_ui3.useElevationContext)(propsElevation);
502
+ const styleProps = {
503
+ ...buttonProps,
504
+ variant,
505
+ elevation,
506
+ textWrap: true
507
+ };
508
+ const buttonClassName = tx("button.root", "button button--compound", styleProps, "flex items-center gap-4 plb-2.5", slots.root?.className);
509
+ return /* @__PURE__ */ import_react6.default.createElement("button", {
510
+ ...buttonProps,
511
+ ...slots.root,
512
+ className: buttonClassName,
513
+ "aria-labelledby": labelId,
514
+ ...description && {
515
+ "aria-describedby": descriptionId
516
+ }
517
+ }, before && /* @__PURE__ */ import_react6.default.createElement("div", {
518
+ role: "none",
519
+ className: "grow-0"
520
+ }, before), /* @__PURE__ */ import_react6.default.createElement("div", {
521
+ role: "none",
522
+ ...slots.middle,
523
+ className: (0, import_react_ui_theme3.mx)("grow whitespace-normal flex flex-col gap-1 text-left", slots.middle?.className)
524
+ }, /* @__PURE__ */ import_react6.default.createElement("p", {
525
+ ...slots.label,
526
+ id: labelId,
527
+ className: (0, import_react_ui_theme3.mx)(slots.label?.className)
528
+ }, children), description && /* @__PURE__ */ import_react6.default.createElement("p", {
529
+ id: descriptionId,
530
+ ...slots.description,
531
+ className: (0, import_react_ui_theme3.mx)("text-xs mbe-1 font-normal", variant === "primary" ? import_react_ui_theme3.descriptionTextPrimary : import_react_ui_theme3.descriptionText, slots.description?.className)
532
+ }, description)), after && /* @__PURE__ */ import_react6.default.createElement("div", {
533
+ role: "none",
534
+ className: "grow-0"
535
+ }, after));
536
+ };
537
+ var EmojiPickerToolbarButton = ({ disabled, defaultEmoji, emoji, onChangeEmoji, classNames }) => {
538
+ const { t } = (0, import_react_ui4.useTranslation)("os");
539
+ const { themeMode } = (0, import_react_ui4.useThemeContext)();
540
+ const [_emojiValue, setEmojiValue] = (0, import_react_use_controllable_state.useControllableState)({
541
+ prop: emoji,
542
+ onChange: onChangeEmoji,
543
+ defaultProp: defaultEmoji
544
+ });
545
+ const [emojiPickerOpen, setEmojiPickerOpen] = (0, import_react9.useState)(false);
546
+ const suppressNextTooltip = (0, import_react9.useRef)(false);
547
+ const [triggerTooltipOpen, setTriggerTooltipOpen] = (0, import_react9.useState)(false);
548
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Root, {
549
+ open: triggerTooltipOpen,
550
+ onOpenChange: (nextOpen) => {
551
+ if (suppressNextTooltip.current) {
552
+ setTriggerTooltipOpen(false);
553
+ suppressNextTooltip.current = false;
554
+ } else {
555
+ setTriggerTooltipOpen(nextOpen);
556
+ }
557
+ }
558
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Root, {
559
+ open: emojiPickerOpen,
560
+ onOpenChange: (nextOpen) => {
561
+ setEmojiPickerOpen(nextOpen);
562
+ suppressNextTooltip.current = true;
563
+ }
564
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Trigger, {
565
+ asChild: true
566
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Trigger, {
567
+ asChild: true
568
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Toolbar.Button, {
569
+ classNames: [
570
+ "gap-2 text-2xl plb-1",
571
+ classNames
572
+ ],
573
+ disabled
574
+ }, /* @__PURE__ */ import_react9.default.createElement("span", {
575
+ className: "sr-only"
576
+ }, t("select emoji label")), /* @__PURE__ */ import_react9.default.createElement(import_react8.UserCircle, {
577
+ className: (0, import_react_ui_theme4.getSize)(5)
578
+ })))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Content, {
579
+ side: "bottom",
580
+ classNames: "z-50"
581
+ }, t("select emoji label"), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Arrow, null))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Content, {
582
+ side: "bottom",
583
+ onKeyDownCapture: (event) => {
584
+ if (event.key === "Escape") {
585
+ event.stopPropagation();
586
+ setEmojiPickerOpen(false);
587
+ suppressNextTooltip.current = true;
588
+ }
589
+ }
590
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react7.default, {
591
+ data: import_data.default,
592
+ onEmojiSelect: ({ native }) => {
593
+ if (native) {
594
+ setEmojiValue(native);
595
+ setEmojiPickerOpen(false);
596
+ }
597
+ },
598
+ autoFocus: true,
599
+ maxFrequentRows: 0,
600
+ noCountryFlags: true,
601
+ theme: themeMode
602
+ }), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Arrow, null))));
603
+ };
604
+ var EmojiPickerBlock = ({ disabled, defaultEmoji, emoji, onChangeEmoji, onClickClear }) => {
605
+ const { t } = (0, import_react_ui4.useTranslation)("os");
606
+ const [isMd] = (0, import_react_ui4.useMediaQuery)("md", {
607
+ ssr: false
608
+ });
609
+ const [emojiValue, setEmojiValue] = (0, import_react_use_controllable_state.useControllableState)({
610
+ prop: emoji,
611
+ onChange: onChangeEmoji,
612
+ defaultProp: defaultEmoji
613
+ });
614
+ const [emojiPickerOpen, setEmojiPickerOpen] = (0, import_react9.useState)(false);
615
+ return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Root, {
616
+ open: emojiPickerOpen,
617
+ onOpenChange: setEmojiPickerOpen
618
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Trigger, {
619
+ asChild: true
620
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Button, {
621
+ variant: "ghost",
622
+ classNames: "gap-2 text-2xl plb-1",
623
+ disabled
624
+ }, /* @__PURE__ */ import_react9.default.createElement("span", {
625
+ className: "sr-only"
626
+ }, t("select emoji label")), /* @__PURE__ */ import_react9.default.createElement("span", {
627
+ className: "grow pis-14"
628
+ }, emojiValue), /* @__PURE__ */ import_react9.default.createElement(import_react8.CaretDown, {
629
+ className: (0, import_react_ui_theme4.getSize)(4)
630
+ }))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Content, {
631
+ side: "right",
632
+ sideOffset: isMd ? 0 : -310,
633
+ onKeyDownCapture: (event) => {
634
+ if (event.key === "Escape") {
635
+ event.stopPropagation();
636
+ setEmojiPickerOpen(false);
637
+ }
638
+ }
639
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react7.default, {
640
+ data: import_data.default,
641
+ onEmojiSelect: ({ native }) => {
642
+ if (native) {
643
+ setEmojiValue(native);
644
+ setEmojiPickerOpen(false);
645
+ }
646
+ },
647
+ autoFocus: true,
648
+ maxFrequentRows: 0,
649
+ noCountryFlags: true
650
+ }), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Popover.Arrow, null))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Trigger, {
651
+ asChild: true
652
+ }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Button, {
653
+ variant: "ghost",
654
+ onClick: onClickClear,
655
+ disabled
656
+ }, /* @__PURE__ */ import_react9.default.createElement("span", {
657
+ className: "sr-only"
658
+ }, t("clear label")), /* @__PURE__ */ import_react9.default.createElement(import_react8.ArrowCounterClockwise, null))), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Content, {
659
+ style: {
660
+ zIndex: 70
661
+ },
662
+ side: "right"
663
+ }, t("clear label"), /* @__PURE__ */ import_react9.default.createElement(import_react_ui4.Tooltip.Arrow, null)))));
664
+ };
665
+ var HuePreview = ({ hue }) => {
666
+ const { tx } = (0, import_react_ui5.useThemeContext)();
667
+ const size = 20;
668
+ return /* @__PURE__ */ import_react11.default.createElement("svg", {
669
+ width: size,
670
+ height: size,
671
+ viewBox: `0 0 ${size} ${size}`
672
+ }, /* @__PURE__ */ import_react11.default.createElement("rect", {
673
+ x: 0,
674
+ y: 0,
675
+ width: size,
676
+ height: size,
677
+ className: tx("hue.fill", "select--hue__preview", {
678
+ hue
679
+ })
680
+ }));
681
+ };
682
+ var hueTokens = Object.keys(import_react_ui_theme5.hueTokenThemes).slice(0, 16);
683
+ var HuePickerToolbarButton = ({ disabled, hue, onChangeHue, classNames, defaultHue }) => {
684
+ const { t } = (0, import_react_ui5.useTranslation)("os");
685
+ const [hueValue, setHueValue] = (0, import_react_use_controllable_state2.useControllableState)({
686
+ prop: hue,
687
+ onChange: onChangeHue,
688
+ defaultProp: defaultHue
689
+ });
690
+ const [huePickerOpen, setHuePickerOpen] = (0, import_react11.useState)(false);
691
+ const suppressNextTooltip = (0, import_react11.useRef)(false);
692
+ const [triggerTooltipOpen, setTriggerTooltipOpen] = (0, import_react11.useState)(false);
693
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Root, {
694
+ open: triggerTooltipOpen,
695
+ onOpenChange: (nextOpen) => {
696
+ if (suppressNextTooltip.current) {
697
+ setTriggerTooltipOpen(false);
698
+ suppressNextTooltip.current = false;
699
+ } else {
700
+ setTriggerTooltipOpen(nextOpen);
701
+ }
702
+ }
703
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Root, {
704
+ modal: false,
705
+ open: huePickerOpen,
706
+ onOpenChange: (nextOpen) => {
707
+ setHuePickerOpen(nextOpen);
708
+ suppressNextTooltip.current = true;
709
+ }
710
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Trigger, {
711
+ asChild: true
712
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Trigger, {
713
+ asChild: true
714
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Toolbar.Button, {
715
+ classNames: (0, import_react_ui_theme5.mx)("gap-2 plb-1", classNames),
716
+ disabled
717
+ }, /* @__PURE__ */ import_react11.default.createElement("span", {
718
+ className: "sr-only"
719
+ }, t("select hue label")), /* @__PURE__ */ import_react11.default.createElement(import_react10.Palette, {
720
+ className: (0, import_react_ui_theme5.getSize)(5)
721
+ })))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Portal, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Content, {
722
+ side: "bottom",
723
+ classNames: "z-50"
724
+ }, t("select hue label"), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Arrow, null))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Content, {
725
+ side: "bottom",
726
+ classNames: "!w-40"
727
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Viewport, {
728
+ classNames: "grid grid-cols-4"
729
+ }, hueTokens.map((hue2) => {
730
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.CheckboxItem, {
731
+ key: hue2,
732
+ checked: hue2 === hueValue,
733
+ onCheckedChange: () => setHueValue(hue2),
734
+ classNames: "px-0 py-2 items-center justify-center"
735
+ }, /* @__PURE__ */ import_react11.default.createElement(HuePreview, {
736
+ hue: hue2
737
+ }));
738
+ })))));
739
+ };
740
+ var HuePickerBlock = ({ disabled, hue, onChangeHue, defaultHue, onClickClear }) => {
741
+ const { t } = (0, import_react_ui5.useTranslation)("os");
742
+ const [hueValue, setHueValue] = (0, import_react_use_controllable_state2.useControllableState)({
743
+ prop: hue,
744
+ onChange: onChangeHue,
745
+ defaultProp: defaultHue
746
+ });
747
+ return /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Root, {
748
+ modal: false
749
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Trigger, {
750
+ asChild: true
751
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Button, {
752
+ variant: "ghost",
753
+ classNames: "gap-2 plb-1",
754
+ disabled
755
+ }, /* @__PURE__ */ import_react11.default.createElement("span", {
756
+ className: "sr-only"
757
+ }, t("select hue label")), /* @__PURE__ */ import_react11.default.createElement("div", {
758
+ role: "none",
759
+ className: "pis-14 grow flex items-center justify-center gap-2"
760
+ }, /* @__PURE__ */ import_react11.default.createElement(HuePreview, {
761
+ hue: hueValue
762
+ }), /* @__PURE__ */ import_react11.default.createElement("span", null, t(`${hueValue} label`))), /* @__PURE__ */ import_react11.default.createElement(import_react10.CaretDown, {
763
+ className: (0, import_react_ui_theme5.getSize)(4)
764
+ }))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Content, {
765
+ side: "right"
766
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Viewport, null, Object.keys(import_react_ui_theme5.hueTokenThemes).map((hue2) => {
767
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.CheckboxItem, {
768
+ key: hue2,
769
+ checked: hue2 === hueValue,
770
+ onCheckedChange: () => setHueValue(hue2)
771
+ }, /* @__PURE__ */ import_react11.default.createElement(HuePreview, {
772
+ hue: hue2
773
+ }), /* @__PURE__ */ import_react11.default.createElement("span", {
774
+ className: "grow"
775
+ }, t(`${hue2} label`)), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.ItemIndicator, null, /* @__PURE__ */ import_react11.default.createElement(import_react10.Check, null)));
776
+ })), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.DropdownMenu.Arrow, null))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Root, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Trigger, {
777
+ asChild: true
778
+ }, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Button, {
779
+ variant: "ghost",
780
+ onClick: onClickClear,
781
+ disabled
782
+ }, /* @__PURE__ */ import_react11.default.createElement("span", {
783
+ className: "sr-only"
784
+ }, t("clear label")), /* @__PURE__ */ import_react11.default.createElement(import_react10.ArrowCounterClockwise, null))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Portal, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Content, {
785
+ style: {
786
+ zIndex: 70
787
+ },
788
+ side: "right"
789
+ }, t("clear label"), /* @__PURE__ */ import_react11.default.createElement(import_react_ui5.Tooltip.Arrow, null)))));
790
+ };
791
+ var IdentityListItem = /* @__PURE__ */ (0, import_react12.forwardRef)(({ identity, presence, onClick, classNames, ...props }, forwardedRef) => {
792
+ const fallbackValue = (0, import_util.keyToFallback)(identity.identityKey);
793
+ const labelId = (0, import_react_ui6.useId)("identityListItem__label");
794
+ const displayName = identity.profile?.displayName ?? (0, import_display_name.generateName)(identity.identityKey.toHex());
795
+ return /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.ListItem.Root, {
796
+ ...props,
797
+ classNames: (0, import_react_ui_theme6.mx)("flex gap-2 pis-3 pie-1 items-center", onClick && "cursor-pointer", classNames),
798
+ onClick: () => onClick?.(),
799
+ "data-testid": "identity-list-item",
800
+ labelId,
801
+ ref: forwardedRef
802
+ }, /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.Avatar.Root, {
803
+ status: presence === import_echo.SpaceMember.PresenceState.ONLINE ? "active" : "inactive",
804
+ labelId,
805
+ hue: identity.profile?.data?.hue || fallbackValue.hue
806
+ }, /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.Avatar.Frame, {
807
+ classNames: "place-self-center"
808
+ }, /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.Avatar.Fallback, {
809
+ text: identity.profile?.data?.emoji || fallbackValue.emoji
810
+ })), /* @__PURE__ */ import_react12.default.createElement(import_react_ui6.Avatar.Label, {
811
+ classNames: "text-sm truncate pli-2"
812
+ }, displayName)));
813
+ });
814
+ var SpaceMemberList = ({ spaceKey, includeSelf, onSelect }) => {
815
+ const client = (0, import_react_client.useClient)();
816
+ const allUnsortedMembers = (0, import_echo2.useMembers)(spaceKey);
817
+ const members = (0, import_react13.useMemo)(() => includeSelf ? allUnsortedMembers.sort((member) => member.identity.identityKey.equals(client.halo.identity.get().identityKey) ? -1 : 1) : allUnsortedMembers.filter((member) => !member.identity.identityKey.equals(client.halo.identity.get().identityKey)), [
818
+ allUnsortedMembers
819
+ ]);
820
+ return /* @__PURE__ */ import_react13.default.createElement(SpaceMemberListImpl, {
821
+ members,
822
+ onSelect
823
+ });
824
+ };
825
+ var SpaceMemberListImpl = ({ members, onSelect }) => {
826
+ const { t } = (0, import_react_ui7.useTranslation)("os");
827
+ const visibleMembers = members.filter((member) => member.identity);
828
+ return visibleMembers.length > 0 ? /* @__PURE__ */ import_react13.default.createElement(import_react_ui7.List, {
829
+ classNames: "flex flex-col gap-2",
830
+ "data-testid": "space-members-list"
831
+ }, visibleMembers.map((member) => {
832
+ return /* @__PURE__ */ import_react13.default.createElement(IdentityListItem, {
833
+ key: member.identity.identityKey.toHex(),
834
+ identity: member.identity,
835
+ presence: member.presence,
836
+ onClick: onSelect && (() => onSelect(member))
837
+ });
838
+ })) : /* @__PURE__ */ import_react13.default.createElement("div", {
839
+ role: "none",
840
+ className: "grow flex items-center p-2"
841
+ }, /* @__PURE__ */ import_react13.default.createElement("p", {
842
+ className: (0, import_react_ui_theme7.mx)(import_react_ui_theme7.descriptionText, "text-center is-full mlb-2")
843
+ }, t("empty space members message")));
844
+ };
845
+ var iconProps = {
846
+ weight: "duotone",
847
+ width: 24,
848
+ height: 24,
849
+ x: 8,
850
+ y: 8
851
+ };
852
+ var DeviceListItem = /* @__PURE__ */ (0, import_react17.forwardRef)(({ device, onClickAdd, onClickEdit, onClickReset, onClickRecover, onClickJoinExisting, classNames, connectionState, onAgentDestroy, ...props }, forwardedRef) => {
853
+ const { t } = (0, import_react_ui9.useTranslation)("os");
854
+ const fallbackValue = (0, import_util2.keyToFallback)(device.deviceKey);
855
+ const labelId = (0, import_react_ui9.useId)("identityListItem__label");
856
+ const displayName = device.profile ? t("device name placeholder", {
857
+ os: device.profile.os,
858
+ platform: device.profile.platform
859
+ }) : (0, import_display_name2.generateName)(device.deviceKey.toHex());
860
+ const isCurrent = device.kind === import_halo.DeviceKind.CURRENT;
861
+ return /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.ListItem.Root, {
862
+ ...props,
863
+ classNames: [
864
+ "flex gap-2 items-center mlb-2",
865
+ classNames
866
+ ],
867
+ "data-testid": `device-list-item${isCurrent ? "-current" : ""}`,
868
+ labelId,
869
+ ref: forwardedRef
870
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Avatar.Root, {
871
+ status: isCurrent && connectionState === import_mesh.ConnectionState.OFFLINE ? "error" : device.presence === import_halo.Device.PresenceState.ONLINE ? "active" : "inactive",
872
+ labelId,
873
+ hue: fallbackValue.hue,
874
+ variant: "square"
875
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Avatar.Frame, {
876
+ classNames: "place-self-center"
877
+ }, device.profile?.type ? device.profile.type === import_halo.DeviceType.AGENT_MANAGED ? /* @__PURE__ */ import_react17.default.createElement(import_react16.Database, iconProps) : device.profile.type === import_halo.DeviceType.BROWSER ? /* @__PURE__ */ import_react17.default.createElement(import_react16.Compass, iconProps) : device.profile.type === import_halo.DeviceType.NATIVE ? /* @__PURE__ */ import_react17.default.createElement(import_react16.Desktop, iconProps) : [
878
+ import_halo.DeviceType.AGENT,
879
+ import_halo.DeviceType.AGENT_MANAGED
880
+ ].includes(device.profile.type) ? /* @__PURE__ */ import_react17.default.createElement(import_react16.Robot, iconProps) : device.profile.type === import_halo.DeviceType.MOBILE ? /* @__PURE__ */ import_react17.default.createElement(import_react16.DeviceMobile, iconProps) : /* @__PURE__ */ import_react17.default.createElement(import_react16.Devices, iconProps) : /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Avatar.Fallback, {
881
+ text: fallbackValue.emoji
882
+ })), /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Avatar.Label, {
883
+ classNames: "flex-1 text-sm truncate"
884
+ }, displayName), isCurrent && /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Tag, {
885
+ color: "primary"
886
+ }, t("current device tag label")), device.profile?.type === import_halo.DeviceType.AGENT_MANAGED ? /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Tooltip.Root, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Tooltip.Trigger, {
887
+ asChild: true
888
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Button, {
889
+ variant: "ghost",
890
+ classNames: "pli-0 is-[--rail-action] bs-[--rail-action]",
891
+ "data-testid": "agent.destroy",
892
+ onClick: onAgentDestroy
893
+ }, /* @__PURE__ */ import_react17.default.createElement("span", {
894
+ className: "sr-only"
895
+ }, t("destroy agent label")), /* @__PURE__ */ import_react17.default.createElement(import_react16.Power, {
896
+ className: (0, import_react_ui_theme9.getSize)(5)
897
+ }))), /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Tooltip.Portal, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Tooltip.Content, {
898
+ side: "bottom",
899
+ classNames: "z-50"
900
+ }, t("destroy agent label")))) : device.kind === import_halo.DeviceKind.CURRENT && /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Root, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Trigger, {
901
+ asChild: true
902
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.Button, {
903
+ variant: "ghost",
904
+ classNames: "pli-0 is-[--rail-action] bs-[--rail-action]",
905
+ "data-testid": `device-list-item${isCurrent ? "-current" : ""}.options`
906
+ }, /* @__PURE__ */ import_react17.default.createElement("span", {
907
+ className: "sr-only"
908
+ }, t("more options label")), /* @__PURE__ */ import_react17.default.createElement(import_react16.DotsThree, {
909
+ className: (0, import_react_ui_theme9.getSize)(5)
910
+ }))), /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Content, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Item, {
911
+ "data-testid": "device-list-item-current.join-existing",
912
+ onClick: onClickJoinExisting
913
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react16.ShareFat, {
914
+ className: (0, import_react_ui_theme9.getSize)(5)
915
+ }), t("choose join new identity label")), onClickRecover && /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Item, {
916
+ "data-testid": "device-list-item-current.recover",
917
+ onClick: onClickRecover
918
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react16.FirstAidKit, {
919
+ className: (0, import_react_ui_theme9.getSize)(5)
920
+ }), t("choose recover identity label")), /* @__PURE__ */ import_react17.default.createElement(import_react_ui9.DropdownMenu.Item, {
921
+ "data-testid": "device-list-item-current.reset",
922
+ onClick: onClickReset
923
+ }, /* @__PURE__ */ import_react17.default.createElement(import_react16.Power, {
924
+ className: (0, import_react_ui_theme9.getSize)(5)
925
+ }), t("reset device label")))))));
926
+ });
927
+ var DeviceList = ({ devices, connectionState, onClickAdd, onClickEdit, onClickReset, onClickRecover, onClickJoinExisting, onAgentDestroy }) => {
928
+ const { t } = (0, import_react_ui8.useTranslation)("os");
929
+ return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, /* @__PURE__ */ import_react15.default.createElement("h2", {
930
+ className: (0, import_react_ui_theme8.mx)(import_react_ui_theme8.descriptionText, "text-center mbs-4")
931
+ }, t("devices heading")), devices.length > 0 && /* @__PURE__ */ import_react15.default.createElement(import_react_ui8.List, null, devices.map((device) => {
932
+ return /* @__PURE__ */ import_react15.default.createElement(DeviceListItem, {
933
+ key: device.deviceKey.toHex(),
934
+ device,
935
+ onClickEdit: () => onClickEdit?.(device),
936
+ onClickReset,
937
+ onClickRecover,
938
+ onClickJoinExisting,
939
+ connectionState,
940
+ onAgentDestroy
941
+ });
942
+ })), /* @__PURE__ */ import_react15.default.createElement(import_react_ui8.Button, {
943
+ variant: "ghost",
944
+ classNames: "justify-start gap-2 !pis-0 !pie-3 is-full",
945
+ "data-testid": "devices-panel.create-invitation",
946
+ onClick: onClickAdd
947
+ }, /* @__PURE__ */ import_react15.default.createElement("div", {
948
+ role: "img",
949
+ className: (0, import_react_ui_theme8.mx)((0, import_react_ui_theme8.getSize)(8), "m-1 rounded-sm bg-input grid place-items-center")
950
+ }, /* @__PURE__ */ import_react15.default.createElement(import_react14.Plus, {
951
+ weight: "light",
952
+ className: (0, import_react_ui_theme8.getSize)(6)
953
+ })), /* @__PURE__ */ import_react15.default.createElement("span", {
954
+ className: "grow font-medium text-start"
955
+ }, t("choose add device label")), /* @__PURE__ */ import_react15.default.createElement(import_react14.CaretRight, {
956
+ weight: "bold",
957
+ className: (0, import_react_ui_theme8.getSize)(4)
958
+ })));
959
+ };
960
+ var AuthCode = (props) => {
961
+ const { code, large, classNames } = props;
962
+ const l = code?.length ?? 0;
963
+ const left = code?.slice(0, l / 2);
964
+ const right = code?.slice(l / 2);
965
+ const codeRef = (0, import_react20.useRef)(null);
966
+ const handleClick = () => {
967
+ if (codeRef.current) {
968
+ const selection = window.getSelection();
969
+ selection?.removeAllRanges();
970
+ const range = document.createRange();
971
+ range.selectNodeContents(codeRef.current);
972
+ selection?.addRange(range);
973
+ }
974
+ void navigator.clipboard.writeText(code ?? "");
975
+ };
976
+ return /* @__PURE__ */ import_react20.default.createElement("span", {
977
+ className: (0, import_react_ui_theme11.mx)(large ? "text-6xl" : "text-2xl", "font-mono pli-2.5 rounded cursor-pointer", classNames),
978
+ onClick: handleClick,
979
+ ref: codeRef
980
+ }, /* @__PURE__ */ import_react20.default.createElement("span", {
981
+ className: "mie-[0.4em]"
982
+ }, left), /* @__PURE__ */ import_react20.default.createElement("span", null, right));
983
+ };
984
+ var InvitationListItem = (props) => {
985
+ const { invitation } = props;
986
+ const invitationStatus = (0, import_invitations.useInvitationStatus)(invitation);
987
+ return /* @__PURE__ */ import_react19.default.createElement(InvitationListItemImpl, {
988
+ ...props,
989
+ invitationStatus
990
+ });
991
+ };
992
+ var avatarProps = {
993
+ size: 10,
994
+ variant: "circle"
995
+ };
996
+ var AvatarStackEffect = ({ animation, status, reverseEffects }) => {
997
+ const { tx } = (0, import_react_ui10.useThemeContext)();
998
+ return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement("span", {
999
+ role: "none",
1000
+ className: (0, import_react_ui_theme10.mx)("absolute inline-end-auto opacity-20", reverseEffects ? "inline-start-3" : "inline-start-1", (0, import_react_ui_theme10.getSize)(avatarProps.size))
1001
+ }, /* @__PURE__ */ import_react19.default.createElement("span", {
1002
+ role: "none",
1003
+ className: tx("avatar.ring", "avatar__ring", {
1004
+ ...avatarProps,
1005
+ status,
1006
+ animation
1007
+ }),
1008
+ style: {
1009
+ animationDelay: "400ms"
1010
+ }
1011
+ })), /* @__PURE__ */ import_react19.default.createElement("span", {
1012
+ role: "none",
1013
+ className: (0, import_react_ui_theme10.mx)("absolute inline-end-auto opacity-50", reverseEffects ? "inline-start-2" : "inline-start-2", (0, import_react_ui_theme10.getSize)(avatarProps.size))
1014
+ }, /* @__PURE__ */ import_react19.default.createElement("span", {
1015
+ role: "none",
1016
+ className: tx("avatar.ring", "avatar__ring", {
1017
+ ...avatarProps,
1018
+ status,
1019
+ animation
1020
+ }),
1021
+ style: {
1022
+ animationDelay: "200ms"
1023
+ }
1024
+ })));
1025
+ };
1026
+ var InvitationListItemImpl = ({ invitation, invitationStatus: propsInvitationStatus, send, onClickRemove, createInvitationUrl, reverseEffects, ...props }) => {
1027
+ const { t } = (0, import_react_ui10.useTranslation)("os");
1028
+ const { cancel, status: invitationStatus, invitationCode, authCode, multiUse, shareable } = propsInvitationStatus;
1029
+ const isCancellable = !([
1030
+ import_invitations.Invitation.State.ERROR,
1031
+ import_invitations.Invitation.State.TIMEOUT,
1032
+ import_invitations.Invitation.State.CANCELLED
1033
+ ].indexOf(invitationStatus) >= 0);
1034
+ const showShare = shareable && (multiUse || [
1035
+ import_invitations.Invitation.State.INIT,
1036
+ import_invitations.Invitation.State.CONNECTING,
1037
+ import_invitations.Invitation.State.CONNECTED
1038
+ ].indexOf(invitationStatus) >= 0);
1039
+ const showAuthCode = invitationStatus === import_invitations.Invitation.State.READY_FOR_AUTHENTICATION;
1040
+ const handleClickRemove = (0, import_react19.useCallback)(() => onClickRemove?.(invitation), [
1041
+ invitation,
1042
+ onClickRemove
1043
+ ]);
1044
+ const invitationUrl = invitationCode && createInvitationUrl(invitationCode);
1045
+ const invitationId = invitation?.get().invitationId;
1046
+ const invitationHasLifetime = invitation?.get().lifetime;
1047
+ const invitationTimeLeft = invitation?.expiry ? (0, import_date_fns.formatDistanceToNow)(invitation?.expiry, {
1048
+ addSuffix: true
1049
+ }) : void 0;
1050
+ const avatarAnimation = [
1051
+ import_invitations.Invitation.State.INIT,
1052
+ import_invitations.Invitation.State.CONNECTING,
1053
+ import_invitations.Invitation.State.CONNECTED,
1054
+ import_invitations.Invitation.State.READY_FOR_AUTHENTICATION,
1055
+ import_invitations.Invitation.State.AUTHENTICATING
1056
+ ].includes(invitationStatus) ? "pulse" : "none";
1057
+ const avatarError = [
1058
+ import_invitations.Invitation.State.ERROR,
1059
+ import_invitations.Invitation.State.TIMEOUT,
1060
+ import_invitations.Invitation.State.CANCELLED
1061
+ ].includes(invitationStatus);
1062
+ const avatarGreen = [
1063
+ import_invitations.Invitation.State.CONNECTED,
1064
+ import_invitations.Invitation.State.READY_FOR_AUTHENTICATION,
1065
+ import_invitations.Invitation.State.AUTHENTICATING,
1066
+ import_invitations.Invitation.State.SUCCESS
1067
+ ].includes(invitationStatus);
1068
+ const avatarStatus = avatarError ? "error" : avatarGreen ? "active" : "inactive";
1069
+ return /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.ListItem.Root, {
1070
+ id: invitationCode,
1071
+ ...props,
1072
+ classNames: [
1073
+ "flex gap-2 pis-3 pie-1 items-center relative",
1074
+ props.classNames
1075
+ ]
1076
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.ListItem.Heading, {
1077
+ classNames: "sr-only"
1078
+ }, t(multiUse ? "invite many list item label" : "invite one list item label")), multiUse && /* @__PURE__ */ import_react19.default.createElement(AvatarStackEffect, {
1079
+ status: avatarStatus,
1080
+ animation: avatarAnimation,
1081
+ reverseEffects
1082
+ }), /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Root, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Avatar.Root, {
1083
+ ...avatarProps,
1084
+ animation: avatarAnimation,
1085
+ status: avatarStatus
1086
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Trigger, {
1087
+ asChild: true
1088
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Avatar.Frame, {
1089
+ tabIndex: 0,
1090
+ classNames: [
1091
+ import_react_ui_theme10.focusRing,
1092
+ "relative rounded-full place-self-center"
1093
+ ]
1094
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Avatar.Fallback, {
1095
+ text: (0, import_util3.hexToEmoji)(invitationId)
1096
+ })))), /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Portal, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Content, {
1097
+ side: "left",
1098
+ classNames: "z-[70]"
1099
+ }, t(multiUse ? "invite many qr label" : "invite one qr label"), /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Arrow, null)))), showShare && invitationUrl ? /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Root, null, /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Trigger, {
1100
+ asChild: true
1101
+ }, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Button, {
1102
+ variant: "ghost",
1103
+ classNames: "grow justify-start font-medium",
1104
+ onClick: () => send({
1105
+ type: "selectInvitation",
1106
+ invitation
1107
+ }),
1108
+ "data-testid": "show-qrcode"
1109
+ }, /* @__PURE__ */ import_react19.default.createElement("span", null, t("open share panel label")))), /* @__PURE__ */ import_react19.default.createElement(CopyButtonIconOnly, {
1110
+ variant: "ghost",
1111
+ value: invitationUrl
1112
+ })), /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Portal, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Tooltip.Content, {
1113
+ side: "left",
1114
+ classNames: "z-[70]"
1115
+ }, invitationHasLifetime && /* @__PURE__ */ import_react19.default.createElement("span", null, "Expires ", invitationTimeLeft)))) : showAuthCode ? /* @__PURE__ */ import_react19.default.createElement(AuthCode, {
1116
+ code: authCode,
1117
+ classNames: "grow"
1118
+ }) : invitationStatus === import_invitations.Invitation.State.CONNECTING ? /* @__PURE__ */ import_react19.default.createElement("span", {
1119
+ className: "pli-2 grow text-neutral-500"
1120
+ }, "Connecting...") : invitationStatus === import_invitations.Invitation.State.AUTHENTICATING ? /* @__PURE__ */ import_react19.default.createElement("span", {
1121
+ className: "pli-2 grow text-neutral-500"
1122
+ }, "Authenticating...") : invitationStatus === import_invitations.Invitation.State.ERROR || invitationStatus === import_invitations.Invitation.State.TIMEOUT ? /* @__PURE__ */ import_react19.default.createElement("span", {
1123
+ className: "pli-2 grow text-neutral-500"
1124
+ }, "Failed") : invitationStatus === import_invitations.Invitation.State.CANCELLED ? /* @__PURE__ */ import_react19.default.createElement("span", {
1125
+ className: "pli-2 grow text-neutral-500"
1126
+ }, "Cancelled") : invitationStatus === import_invitations.Invitation.State.SUCCESS ? /* @__PURE__ */ import_react19.default.createElement("span", {
1127
+ className: "pli-2 grow truncate"
1128
+ }, "User joined") : !shareable ? /* @__PURE__ */ import_react19.default.createElement("span", {
1129
+ className: "pli-2 grow text-neutral-500"
1130
+ }, "Pending Invitation") : /* @__PURE__ */ import_react19.default.createElement("span", {
1131
+ className: "grow"
1132
+ }, " "), isCancellable ? /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Button, {
1133
+ variant: "ghost",
1134
+ classNames: "flex gap-1 pli-0",
1135
+ onClick: cancel,
1136
+ "data-testid": "cancel-invitation"
1137
+ }, /* @__PURE__ */ import_react19.default.createElement("span", {
1138
+ className: "sr-only"
1139
+ }, t("cancel invitation label")), /* @__PURE__ */ import_react19.default.createElement(import_react18.X, {
1140
+ className: (0, import_react_ui_theme10.getSize)(4)
1141
+ })) : /* @__PURE__ */ import_react19.default.createElement(import_react_ui10.Button, {
1142
+ variant: "ghost",
1143
+ classNames: "flex gap-1 pli-0",
1144
+ onClick: handleClickRemove,
1145
+ "data-testid": "remove-invitation"
1146
+ }, /* @__PURE__ */ import_react19.default.createElement("span", {
1147
+ className: "sr-only"
1148
+ }, t("remove invitation label")), /* @__PURE__ */ import_react19.default.createElement(import_react18.X, {
1149
+ className: (0, import_react_ui_theme10.getSize)(4)
1150
+ })));
1151
+ };
1152
+ var InvitationList = ({ invitations, send, ...invitationProps }) => {
1153
+ const { className, InvitationListItem: Item = InvitationListItem } = invitationProps;
1154
+ return /* @__PURE__ */ import_react22.default.createElement(import_react_ui11.List, {
1155
+ classNames: (0, import_react_ui_theme12.mx)("flex flex-col gap-2", className)
1156
+ }, invitations.map((invitation) => {
1157
+ const value = invitation.get().invitationId;
1158
+ return /* @__PURE__ */ import_react22.default.createElement(Item, {
1159
+ key: value,
1160
+ send,
1161
+ invitation,
1162
+ ...invitationProps
1163
+ });
1164
+ }));
1165
+ };
1166
+ var InvitationListContainer = ({ spaceKey, createInvitationUrl, send }) => {
1167
+ const space = (0, import_echo3.useSpace)(spaceKey);
1168
+ const invitations = (0, import_echo3.useSpaceInvitations)(spaceKey);
1169
+ const handleClickRemove = (0, import_react21.useCallback)((invitation) => {
1170
+ void invitation.cancel();
1171
+ }, [
1172
+ space
1173
+ ]);
1174
+ return /* @__PURE__ */ import_react21.default.createElement(InvitationList, {
1175
+ invitations,
1176
+ onClickRemove: handleClickRemove,
1177
+ createInvitationUrl,
1178
+ send
1179
+ });
1180
+ };
1181
+ var defaultActions = {
1182
+ noopAction: {
1183
+ label: "No-op",
1184
+ description: "",
1185
+ icon: import_react23.Placeholder,
1186
+ onClick: () => {
1187
+ }
1188
+ }
1189
+ };
1190
+ var BifurcatedAction = /* @__PURE__ */ (0, import_react24.forwardRef)((props, forwardedRef) => {
1191
+ const { classNames, variant, isFull = true, actions = defaultActions, activeAction: propsActiveAction, onChangeActiveAction, defaultActiveAction, ...rest } = props;
1192
+ const [activeActionKey2 = Object.keys(actions)[0], setActiveAction] = (0, import_react_use_controllable_state3.useControllableState)({
1193
+ prop: propsActiveAction,
1194
+ onChange: onChangeActiveAction,
1195
+ defaultProp: defaultActiveAction
1196
+ });
1197
+ const activeAction = actions[activeActionKey2] ?? {};
1198
+ const { t } = (0, import_react_ui12.useTranslation)("os");
1199
+ return /* @__PURE__ */ import_react24.default.createElement("div", {
1200
+ role: "none",
1201
+ className: (0, import_react_ui_theme13.mx)("mbs-2 flex gap-px items-center", isFull && "is-full")
1202
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.Button, {
1203
+ ...rest,
1204
+ classNames: [
1205
+ "bs-11 flex-1 min-is-0 flex gap-2 rounded-ie-none",
1206
+ classNames
1207
+ ],
1208
+ ref: forwardedRef,
1209
+ variant,
1210
+ onClick: activeAction.onClick
1211
+ }, activeAction.icon && /* @__PURE__ */ import_react24.default.createElement(activeAction.icon, {
1212
+ className: (0, import_react_ui_theme13.getSize)(5)
1213
+ }), /* @__PURE__ */ import_react24.default.createElement("span", null, activeAction.label)), /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Root, null, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Trigger, {
1214
+ asChild: true
1215
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.Button, {
1216
+ classNames: [
1217
+ "bs-11 flex-none rounded-is-none",
1218
+ classNames
1219
+ ]
1220
+ }, /* @__PURE__ */ import_react24.default.createElement("span", {
1221
+ className: "sr-only"
1222
+ }, t("invite options label")), /* @__PURE__ */ import_react24.default.createElement(import_react23.CaretDown, {
1223
+ className: (0, import_react_ui_theme13.getSize)(4)
1224
+ }))), /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Content, null, /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Viewport, null, Object.entries(actions).map(([id, action]) => {
1225
+ return /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.CheckboxItem, {
1226
+ key: id,
1227
+ "aria-labelledby": `${id}__label`,
1228
+ "aria-describedby": `${id}__description`,
1229
+ checked: activeActionKey2 === id,
1230
+ onCheckedChange: (checked) => checked && setActiveAction(id),
1231
+ classNames: "gap-2"
1232
+ }, action.icon && /* @__PURE__ */ import_react24.default.createElement(action.icon, {
1233
+ className: (0, import_react_ui_theme13.getSize)(5)
1234
+ }), /* @__PURE__ */ import_react24.default.createElement("div", {
1235
+ role: "none",
1236
+ className: "flex-1 min-is-0 space-b-1"
1237
+ }, /* @__PURE__ */ import_react24.default.createElement("p", {
1238
+ id: `${id}__label`
1239
+ }, action.label), action.description && /* @__PURE__ */ import_react24.default.createElement("p", {
1240
+ id: `${id}__description`,
1241
+ className: import_react_ui_theme13.descriptionText
1242
+ }, action.description)), /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.ItemIndicator, {
1243
+ asChild: true
1244
+ }, /* @__PURE__ */ import_react24.default.createElement(import_react23.Check, {
1245
+ weight: "bold",
1246
+ className: (0, import_react_ui_theme13.getSize)(4)
1247
+ })));
1248
+ })), /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.DropdownMenu.Arrow, null))));
1249
+ });
1250
+ var Action = /* @__PURE__ */ (0, import_react24.forwardRef)((props, forwardedRef) => {
1251
+ const { children, classNames, variant, isFull = true, ...rest } = props;
1252
+ return /* @__PURE__ */ import_react24.default.createElement(import_react_ui12.Button, {
1253
+ ...rest,
1254
+ classNames: [
1255
+ isFull && "is-full",
1256
+ "bs-11 flex gap-2 mbs-2",
1257
+ classNames
1258
+ ],
1259
+ ref: forwardedRef,
1260
+ variant
1261
+ }, children);
1262
+ });
1263
+ var Actions = /* @__PURE__ */ (0, import_react25.forwardRef)(({ classNames, children, ...props }, forwardedRef) => {
1264
+ return /* @__PURE__ */ import_react25.default.createElement("div", {
1265
+ ...props,
1266
+ className: (0, import_react_ui_theme14.mx)("flex flex-col gap-2 mbs-2", Array.isArray(children) && children.length > 1 ? "justify-between" : "justify-center", classNames),
1267
+ ref: forwardedRef
1268
+ }, children);
1269
+ });
1270
+ var CloseButton = ({ onDone, ...props }) => {
1271
+ const { t } = (0, import_react_ui13.useTranslation)("os");
1272
+ return /* @__PURE__ */ import_react27.default.createElement(import_react_ui13.Button, {
1273
+ variant: "ghost",
1274
+ classNames: (0, import_react_ui_theme15.mx)("plb-0 pli-2 absolute block-start-0 inline-end-0 z-[1]"),
1275
+ onClick: () => onDone?.(),
1276
+ ...props
1277
+ }, /* @__PURE__ */ import_react27.default.createElement(import_react26.X, {
1278
+ weight: "bold",
1279
+ className: (0, import_react_ui_theme15.getSize)(4)
1280
+ }), /* @__PURE__ */ import_react27.default.createElement("span", {
1281
+ className: "sr-only"
1282
+ }, t("exit label")));
1283
+ };
1284
+ var Emoji = ({ text, className }) => {
1285
+ const size = 14;
1286
+ return /* @__PURE__ */ import_react28.default.createElement("div", {
1287
+ role: "none",
1288
+ className: (0, import_react_ui_theme16.mx)((0, import_react_ui_theme16.getSize)(size), "rounded relative pointer-events-none", className)
1289
+ }, /* @__PURE__ */ import_react28.default.createElement("svg", {
1290
+ viewBox: `0 0 ${size * 4} ${size * 4}`,
1291
+ width: size * 4,
1292
+ height: size * 4
1293
+ }, /* @__PURE__ */ import_react28.default.createElement("text", {
1294
+ x: "50%",
1295
+ y: "50%",
1296
+ textAnchor: "middle",
1297
+ dominantBaseline: "middle",
1298
+ baselineShift: "-0.25rem",
1299
+ fontSize: "2.25rem"
1300
+ }, text)));
1301
+ };
1302
+ var Centered = (props) => {
1303
+ const { children } = props;
1304
+ return /* @__PURE__ */ import_react28.default.createElement("div", {
1305
+ role: "none",
1306
+ className: "absolute inset-0 flex items-center justify-center"
1307
+ }, children);
1308
+ };
1309
+ var Heading = /* @__PURE__ */ (0, import_react29.forwardRef)(({ titleId, title, titleSrOnly, children, corner }, forwardedRef) => {
1310
+ return /* @__PURE__ */ import_react29.default.createElement("div", {
1311
+ role: "none",
1312
+ className: "pbe-2 relative",
1313
+ ref: forwardedRef
1314
+ }, corner, /* @__PURE__ */ import_react29.default.createElement("h1", {
1315
+ ...!titleSrOnly && {
1316
+ id: titleId
1317
+ },
1318
+ className: (0, import_react_ui_theme17.mx)(import_react_ui_theme17.descriptionText, "text-center mlb-2", titleSrOnly && "invisible")
1319
+ }, title), titleSrOnly && /* @__PURE__ */ import_react29.default.createElement("span", {
1320
+ id: titleId
1321
+ }, title), children);
1322
+ });
1323
+ var Label = (props) => {
1324
+ const { children } = props;
1325
+ return /* @__PURE__ */ import_react30.default.createElement("span", {
1326
+ className: (0, import_react_ui_theme18.mx)(import_react_ui_theme18.descriptionText, "text-center mli-6 whitespace-normal")
1327
+ }, children);
1328
+ };
1329
+ var Input = ({ validationMessage, label, ...props }) => {
1330
+ return /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.Root, null, /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.Label, null, label), /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.TextInput, {
1331
+ ...props,
1332
+ classNames: "plb-3 mbs-2 text-center"
1333
+ }), /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.DescriptionAndValidation, null, validationMessage && /* @__PURE__ */ import_react31.default.createElement(import_react_ui14.Input.Validation, null, validationMessage)));
1334
+ };
1335
+ var StepHeading = /* @__PURE__ */ (0, import_react32.forwardRef)(({ children, className, ...props }, forwardedRef) => {
1336
+ return /* @__PURE__ */ import_react32.default.createElement("h2", {
1337
+ ...props,
1338
+ className: (0, import_react_ui_theme19.mx)("font-normal text-sm mbe-4 mli-1 text-center", className),
1339
+ ref: forwardedRef
1340
+ }, children);
1341
+ });
1342
+ var VIEWPORT_NAME = "Viewport";
1343
+ var VIEWS_NAME = "ViewportViews";
1344
+ var VIEW_NAME = "ViewportView";
1345
+ var [createViewportContext, createViewportScope] = (0, import_react_context.createContextScope)(VIEWPORT_NAME, []);
1346
+ var [ViewportProvider, useViewportContext] = createViewportContext(VIEWPORT_NAME);
1347
+ var ViewportRoot = ({ __viewportScope, classNames, children, defaultActiveView, activeView: propsActiveView, focusManaged = false, onActiveViewChange, ...props }) => {
1348
+ const [activeView = "never", setActiveView] = (0, import_react_use_controllable_state4.useControllableState)({
1349
+ prop: propsActiveView,
1350
+ defaultProp: defaultActiveView,
1351
+ onChange: onActiveViewChange
1352
+ });
1353
+ return /* @__PURE__ */ import_react33.default.createElement(ViewportProvider, {
1354
+ focusManaged,
1355
+ activeView,
1356
+ setActiveView,
1357
+ scope: __viewportScope
1358
+ }, /* @__PURE__ */ import_react33.default.createElement("div", {
1359
+ role: "region",
1360
+ "aria-live": "polite",
1361
+ ...props,
1362
+ className: (0, import_react_ui_theme20.mx)("is-full overflow-hidden", classNames)
1363
+ }, children));
1364
+ };
1365
+ ViewportRoot.displayName = VIEWPORT_NAME;
1366
+ var ViewportViews = ({ classNames, children, ...props }) => {
1367
+ const size = {
1368
+ inlineSize: `${Math.ceil(children.length) * 100}%`
1369
+ };
1370
+ return /* @__PURE__ */ import_react33.default.createElement("div", {
1371
+ role: "none",
1372
+ style: size,
1373
+ ...props,
1374
+ className: (0, import_react_ui_theme20.mx)("flex", classNames)
1375
+ }, children);
1376
+ };
1377
+ ViewportViews.displayName = VIEWS_NAME;
1378
+ var ViewportView = /* @__PURE__ */ (0, import_react33.forwardRef)(({ __viewportScope, classNames, children, id, ...props }, forwardedRef) => {
1379
+ const { activeView, focusManaged } = useViewportContext(VIEW_NAME, __viewportScope);
1380
+ const isActive = id === activeView;
1381
+ const ref = (0, import_react_ui15.useForwardedRef)(forwardedRef);
1382
+ const { findFirstFocusable } = (0, import_react_tabster.useFocusFinders)();
1383
+ (0, import_react33.useEffect)(() => {
1384
+ if (!focusManaged && isActive && document.body.hasAttribute("data-is-keyboard") && ref.current) {
1385
+ findFirstFocusable(ref.current)?.focus();
1386
+ }
1387
+ }, [
1388
+ focusManaged,
1389
+ ref.current,
1390
+ isActive
1391
+ ]);
1392
+ return /* @__PURE__ */ import_react33.default.createElement("section", {
1393
+ ...props,
1394
+ ...!isActive && {
1395
+ "aria-hidden": true
1396
+ },
1397
+ className: (0, import_react_ui_theme20.mx)("min-is-0 flex-1 flex flex-col", isActive ? "order-2" : "order-4 invisible", classNames),
1398
+ ref
1399
+ }, children);
1400
+ });
1401
+ ViewportView.displayName = VIEW_NAME;
1402
+ var Viewport = {
1403
+ Root: ViewportRoot,
1404
+ Views: ViewportViews,
1405
+ View: ViewportView
1406
+ };
1407
+ var SpaceListItem = /* @__PURE__ */ (0, import_react34.forwardRef)(({ space, onClick }, ref) => {
1408
+ const fallbackValue = (0, import_util4.keyToEmoji)(space.key);
1409
+ const labelId = (0, import_react_ui16.useId)("identityListItem__label");
1410
+ const displayName = space.properties.name ?? (0, import_util4.humanize)(space.key.toHex());
1411
+ return /* @__PURE__ */ import_react34.default.createElement("li", {
1412
+ className: (0, import_react_ui_theme21.mx)("flex gap-2 items-center mbe-2", onClick && "cursor-pointer"),
1413
+ onClick: () => onClick?.(),
1414
+ ref,
1415
+ "data-testid": "space-list-item"
1416
+ }, /* @__PURE__ */ import_react34.default.createElement(import_react_ui16.Avatar.Root, {
1417
+ labelId
1418
+ }, /* @__PURE__ */ import_react34.default.createElement(import_react_ui16.Avatar.Frame, null, /* @__PURE__ */ import_react34.default.createElement(import_react_ui16.Avatar.Fallback, {
1419
+ text: fallbackValue
1420
+ })), /* @__PURE__ */ import_react34.default.createElement(import_react_ui16.Avatar.Label, {
1421
+ classNames: "text-sm truncate"
1422
+ }, displayName)));
1423
+ });
1424
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/identityMachine.ts";
1425
+ var identityMachine = (0, import_xstate.createMachine)({
1426
+ id: "identity",
1427
+ predictableActionArguments: true,
1428
+ context: {
1429
+ identity: null,
1430
+ identitySubscribable: null
1431
+ },
1432
+ initial: "choosingAction",
1433
+ invoke: {
1434
+ src: (context) => context.identitySubscribable
1435
+ },
1436
+ states: {
1437
+ unknown: {
1438
+ always: [
1439
+ {
1440
+ cond: "initiallyManagingDeviceInvitation",
1441
+ target: "managingDeviceInvitation",
1442
+ actions: "log"
1443
+ },
1444
+ {
1445
+ target: "choosingAction",
1446
+ actions: "log"
1447
+ }
1448
+ ]
1449
+ },
1450
+ choosingAction: {},
1451
+ managingDeviceInvitation: {},
1452
+ confirmingResetStorage: {},
1453
+ confirmingRecover: {},
1454
+ confirmingJoinNewIdentity: {}
1455
+ },
1456
+ on: {
1457
+ unchooseAction: {
1458
+ target: ".choosingAction",
1459
+ actions: [
1460
+ "unsetInvitation",
1461
+ "log"
1462
+ ]
1463
+ },
1464
+ deselectInvitation: {
1465
+ target: ".choosingAction",
1466
+ actions: [
1467
+ "unsetInvitation",
1468
+ "log"
1469
+ ]
1470
+ },
1471
+ selectInvitation: {
1472
+ target: ".managingDeviceInvitation",
1473
+ actions: [
1474
+ "setInvitation",
1475
+ "log"
1476
+ ]
1477
+ },
1478
+ chooseJoinNewIdentity: {
1479
+ target: ".confirmingJoinNewIdentity",
1480
+ actions: "log"
1481
+ },
1482
+ chooseRecoverIdentity: {
1483
+ target: ".confirmingRecover",
1484
+ actions: "log"
1485
+ },
1486
+ chooseResetStorage: {
1487
+ target: ".confirmingResetStorage",
1488
+ actions: "log"
1489
+ }
1490
+ }
1491
+ }, {
1492
+ guards: {
1493
+ initiallyManagingDeviceInvitation: ({ initialDisposition }, _event) => initialDisposition === "manage-device-invitation"
1494
+ },
1495
+ actions: {
1496
+ setIdentity: (0, import_xstate.assign)({
1497
+ identity: (context, event) => event?.identity ?? null
1498
+ }),
1499
+ setInvitation: (0, import_xstate.assign)({
1500
+ invitation: (context, event) => event?.invitation ?? null
1501
+ }),
1502
+ unsetInvitation: (0, import_xstate.assign)({
1503
+ invitation: () => void 0
1504
+ }),
1505
+ log: (context, event) => {
1506
+ (0, import_log2.log)("[transition]", {
1507
+ event,
1508
+ context
1509
+ }, {
1510
+ F: __dxlog_file,
1511
+ L: 98,
1512
+ S: void 0,
1513
+ C: (f, a) => f(...a)
1514
+ });
1515
+ }
1516
+ }
1517
+ });
1518
+ var useIdentityMachine = (client, options) => {
1519
+ return (0, import_react38.useMachine)(identityMachine, {
1520
+ ...options,
1521
+ context: {
1522
+ ...options?.context,
1523
+ identity: client.halo.identity.get(),
1524
+ identitySubscribable: client.halo.identity.map((identity) => ({
1525
+ type: "setIdentity",
1526
+ identity
1527
+ }))
1528
+ }
1529
+ });
1530
+ };
1531
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx";
1532
+ var IdentityActionChooser = (props) => {
1533
+ const { send } = props;
1534
+ const client = (0, import_react_client3.useClient)();
1535
+ const invitations = (0, import_halo3.useHaloInvitations)();
1536
+ const createInvitation = () => {
1537
+ invitations.forEach((invitation2) => invitation2.cancel());
1538
+ const invitation = client.halo.share();
1539
+ if (client.config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
1540
+ const subscription = invitation.subscribe((invitation2) => {
1541
+ const invitationCode = import_invitations3.InvitationEncoder.encode(invitation2);
1542
+ if (invitation2.state === import_invitations3.Invitation.State.CONNECTING) {
1543
+ import_log3.log.info(JSON.stringify({
1544
+ invitationCode,
1545
+ authCode: invitation2.authCode
1546
+ }), void 0, {
1547
+ F: __dxlog_file2,
1548
+ L: 29,
1549
+ S: void 0,
1550
+ C: (f, a) => f(...a)
1551
+ });
1552
+ subscription.unsubscribe();
1553
+ }
1554
+ });
1555
+ }
1556
+ send?.({
1557
+ type: "selectInvitation",
1558
+ invitation
1559
+ });
1560
+ };
1561
+ const isProduction = client.config.values.runtime?.app?.env?.DX_ENVIRONMENT === "production";
1562
+ return /* @__PURE__ */ import_react39.default.createElement(IdentityActionChooserImpl, {
1563
+ ...props,
1564
+ onClickAdd: createInvitation,
1565
+ onClickJoinExisting: () => send?.({
1566
+ type: "chooseJoinNewIdentity"
1567
+ }),
1568
+ onClickRecover: isProduction ? void 0 : () => send?.({
1569
+ type: "chooseRecoverIdentity"
1570
+ }),
1571
+ onClickReset: () => send?.({
1572
+ type: "chooseResetStorage"
1573
+ })
1574
+ });
1575
+ };
1576
+ var IdentityActionChooserImpl = ({ devices, connectionState, agentHostingEnabled, onClickAdd, onClickJoinExisting, onClickRecover, onClickReset, ...agentProps }) => {
1577
+ const managedDeviceAvailable = devices.find((device) => device.profile?.type === import_halo3.DeviceType.AGENT_MANAGED);
1578
+ return /* @__PURE__ */ import_react39.default.createElement("div", {
1579
+ role: "none",
1580
+ className: "bs-40 grow overflow-y-auto overflow-x-hidden"
1581
+ }, /* @__PURE__ */ import_react39.default.createElement(DeviceList, {
1582
+ devices,
1583
+ connectionState,
1584
+ onClickAdd,
1585
+ onClickJoinExisting,
1586
+ onClickRecover: agentProps.agentStatus === "created" ? onClickRecover : void 0,
1587
+ onClickReset,
1588
+ onAgentDestroy: agentProps.onAgentDestroy
1589
+ }), !managedDeviceAvailable && agentHostingEnabled && /* @__PURE__ */ import_react39.default.createElement(AgentConfig, agentProps));
1590
+ };
1591
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/useEdgeAgentsHandlers.ts";
1592
+ var useEdgeAgentHandlers = ({ identity }) => {
1593
+ const [validationMessage, setValidationMessage] = (0, import_react41.useState)("");
1594
+ const [lastReceivedStatus, setLastReceivedStatus] = (0, import_react41.useState)(import_services.QueryAgentStatusResponse.AgentStatus.UNKNOWN);
1595
+ const [agentStatus, setAgentStatus] = (0, import_react41.useState)("getting");
1596
+ const client = (0, import_react_client5.useClient)();
1597
+ const agentHostingEnabled = Boolean(client.config.values.runtime?.client?.edgeFeatures?.agents);
1598
+ const handleStatus = (status) => {
1599
+ switch (status) {
1600
+ case import_services.QueryAgentStatusResponse.AgentStatus.ACTIVE:
1601
+ case import_services.QueryAgentStatusResponse.AgentStatus.INACTIVE:
1602
+ setAgentStatus("created");
1603
+ break;
1604
+ case import_services.QueryAgentStatusResponse.AgentStatus.NOT_FOUND:
1605
+ setAgentStatus("creatable");
1606
+ break;
1607
+ case import_services.QueryAgentStatusResponse.AgentStatus.UNKNOWN:
1608
+ setAgentStatus("getting");
1609
+ break;
1610
+ }
1611
+ };
1612
+ (0, import_react41.useEffect)(() => {
1613
+ const stream = client.services.services.EdgeAgentService?.queryAgentStatus();
1614
+ stream?.subscribe(({ status }) => {
1615
+ setLastReceivedStatus(status);
1616
+ handleStatus(status);
1617
+ });
1618
+ return () => {
1619
+ void stream?.close().catch(() => {
1620
+ });
1621
+ };
1622
+ }, []);
1623
+ const onAgentCreate = async () => {
1624
+ (0, import_invariant2.invariant)(identity, "Identity not found", {
1625
+ F: __dxlog_file3,
1626
+ L: 58,
1627
+ S: void 0,
1628
+ A: [
1629
+ "identity",
1630
+ "'Identity not found'"
1631
+ ]
1632
+ });
1633
+ const service = client.services.services.EdgeAgentService;
1634
+ if (!service) {
1635
+ setAgentStatus("error");
1636
+ setValidationMessage("Agent service not initialized.");
1637
+ return;
1638
+ }
1639
+ if (!agentHostingEnabled) {
1640
+ setAgentStatus("error");
1641
+ setValidationMessage("Edge agents are disabled in config.");
1642
+ return;
1643
+ }
1644
+ setAgentStatus("creating");
1645
+ setValidationMessage("");
1646
+ try {
1647
+ await service.createAgent();
1648
+ await Promise.all(client.spaces.get().map((space) => space?.internal.setEdgeReplicationPreference(import_metadata.EdgeReplicationSetting.ENABLED)));
1649
+ setAgentStatus("created");
1650
+ } catch (err) {
1651
+ setAgentStatus("error");
1652
+ setValidationMessage(`Error creating an agent: ${err.message}`);
1653
+ }
1654
+ };
1655
+ const onAgentDestroy = async () => {
1656
+ setValidationMessage("Agents are non-destructible.");
1657
+ };
1658
+ const onAgentRefresh = async () => {
1659
+ setValidationMessage("");
1660
+ handleStatus(lastReceivedStatus);
1661
+ };
1662
+ return {
1663
+ onAgentCreate,
1664
+ onAgentDestroy,
1665
+ onAgentRefresh,
1666
+ validationMessage,
1667
+ agentStatus,
1668
+ agentHostingEnabled
1669
+ };
1670
+ };
1671
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/useKubeAgentHandlers.ts";
1672
+ var useKubeAgentHandlers = ({ invitations, identity }) => {
1673
+ const [validationMessage, setValidationMessage] = (0, import_react42.useState)("");
1674
+ const [agentStatus, setAgentStatus] = (0, import_react42.useState)("getting");
1675
+ const agentHostingProviderClient = (0, import_react_client6.useAgentHostingClient)();
1676
+ const client = (0, import_react_client6.useClient)();
1677
+ const updateAgentStatus = async () => {
1678
+ if (agentHostingProviderClient) {
1679
+ setAgentStatus("getting");
1680
+ try {
1681
+ const agentId = await agentHostingProviderClient?.getAgent(identity?.identityKey.truncate() ?? "never");
1682
+ if (agentId) {
1683
+ setAgentStatus("created");
1684
+ } else {
1685
+ setAgentStatus("creatable");
1686
+ }
1687
+ } catch (err) {
1688
+ setAgentStatus("error");
1689
+ setValidationMessage(`Couldn\u2019t check agent status: ${err.message}`);
1690
+ }
1691
+ } else {
1692
+ setAgentStatus("error");
1693
+ setValidationMessage("No agent provider configured.");
1694
+ }
1695
+ };
1696
+ const createAgent = async (invitationCode) => {
1697
+ (0, import_invariant3.invariant)(identity, "Identity not found", {
1698
+ F: __dxlog_file4,
1699
+ L: 50,
1700
+ S: void 0,
1701
+ A: [
1702
+ "identity",
1703
+ "'Identity not found'"
1704
+ ]
1705
+ });
1706
+ if (agentHostingProviderClient) {
1707
+ setAgentStatus("creating");
1708
+ setValidationMessage("");
1709
+ try {
1710
+ const agentId = await agentHostingProviderClient?.createAgent(invitationCode, identity.identityKey.truncate());
1711
+ if (agentId) {
1712
+ setAgentStatus("created");
1713
+ } else {
1714
+ setAgentStatus("creatable");
1715
+ setValidationMessage("Error creating agent.");
1716
+ }
1717
+ } catch (err) {
1718
+ setValidationMessage(`Error creating agent: ${err.message}`);
1719
+ return updateAgentStatus();
1720
+ }
1721
+ } else {
1722
+ setAgentStatus("error");
1723
+ setValidationMessage("No agent provider configured.");
1724
+ }
1725
+ };
1726
+ const destroyAgent = async () => {
1727
+ (0, import_invariant3.invariant)(identity, "Identity not found", {
1728
+ F: __dxlog_file4,
1729
+ L: 73,
1730
+ S: void 0,
1731
+ A: [
1732
+ "identity",
1733
+ "'Identity not found'"
1734
+ ]
1735
+ });
1736
+ if (agentHostingProviderClient) {
1737
+ setAgentStatus("destroying");
1738
+ setValidationMessage("");
1739
+ try {
1740
+ await agentHostingProviderClient?.destroyAgent(identity.identityKey.truncate());
1741
+ setAgentStatus("creatable");
1742
+ } catch (err) {
1743
+ setValidationMessage(`Error destroying agent: ${err.message}`);
1744
+ return updateAgentStatus();
1745
+ }
1746
+ } else {
1747
+ setAgentStatus("error");
1748
+ setValidationMessage("No agent provider configured.");
1749
+ }
1750
+ };
1751
+ (0, import_react42.useEffect)(() => {
1752
+ void updateAgentStatus();
1753
+ }, []);
1754
+ const handleAgentCreate = (0, import_react42.useCallback)(async (invitation) => {
1755
+ const invitationCode = import_invitations4.InvitationEncoder.encode(invitation);
1756
+ if (invitation.state === import_invitations4.Invitation.State.CONNECTING) {
1757
+ import_log5.log.info(JSON.stringify({
1758
+ invitationCode,
1759
+ authCode: invitation.authCode
1760
+ }), void 0, {
1761
+ F: __dxlog_file4,
1762
+ L: 97,
1763
+ S: void 0,
1764
+ C: (f, a) => f(...a)
1765
+ });
1766
+ return createAgent(invitationCode);
1767
+ }
1768
+ }, []);
1769
+ const onAgentCreate = async () => {
1770
+ invitations.forEach((invitation2) => invitation2.cancel());
1771
+ const invitation = client.halo.share({
1772
+ type: import_invitations4.Invitation.Type.INTERACTIVE,
1773
+ authMethod: import_invitations4.Invitation.AuthMethod.NONE,
1774
+ multiUse: true
1775
+ });
1776
+ invitation.subscribe(handleAgentCreate);
1777
+ };
1778
+ const onAgentRefresh = async () => {
1779
+ setValidationMessage("");
1780
+ await updateAgentStatus();
1781
+ };
1782
+ return {
1783
+ onAgentCreate,
1784
+ onAgentDestroy: destroyAgent,
1785
+ onAgentRefresh,
1786
+ validationMessage,
1787
+ agentStatus,
1788
+ agentHostingEnabled: !!agentHostingProviderClient
1789
+ };
1790
+ };
1791
+ var useAgentHandlers = (params) => {
1792
+ const client = (0, import_react_client4.useClient)();
1793
+ if (client.config.values?.runtime?.client?.edgeFeatures?.agents) {
1794
+ return useEdgeAgentHandlers(params);
1795
+ } else {
1796
+ return useKubeAgentHandlers(params);
1797
+ }
1798
+ };
1799
+ var invitationStatusValue = /* @__PURE__ */ new Map([
1800
+ [
1801
+ import_invitations5.Invitation.State.ERROR,
1802
+ -3
1803
+ ],
1804
+ [
1805
+ import_invitations5.Invitation.State.TIMEOUT,
1806
+ -2
1807
+ ],
1808
+ [
1809
+ import_invitations5.Invitation.State.CANCELLED,
1810
+ -1
1811
+ ],
1812
+ [
1813
+ import_invitations5.Invitation.State.INIT,
1814
+ 0
1815
+ ],
1816
+ [
1817
+ import_invitations5.Invitation.State.CONNECTING,
1818
+ 1
1819
+ ],
1820
+ [
1821
+ import_invitations5.Invitation.State.CONNECTED,
1822
+ 2
1823
+ ],
1824
+ [
1825
+ import_invitations5.Invitation.State.READY_FOR_AUTHENTICATION,
1826
+ 3
1827
+ ],
1828
+ [
1829
+ import_invitations5.Invitation.State.AUTHENTICATING,
1830
+ 4
1831
+ ],
1832
+ [
1833
+ import_invitations5.Invitation.State.SUCCESS,
1834
+ 5
1835
+ ]
1836
+ ]);
1837
+ var InvitationManagerView = ({ children, ...props }) => {
1838
+ return /* @__PURE__ */ import_react44.default.createElement(Viewport.View, {
1839
+ ...props,
1840
+ classNames: "grow flex flex-col justify-around items-center"
1841
+ }, children);
1842
+ };
1843
+ var InvitationManager = ({ invitationUrl, active, send, status, multiUse, authCode, id = "0" }) => {
1844
+ const { t } = (0, import_react_ui20.useTranslation)("os");
1845
+ const qrLabel = (0, import_react_ui20.useId)("invitation-manager__qr-code");
1846
+ const statusValue = multiUse ? 0 : invitationStatusValue.get(status) ?? 0;
1847
+ const showAuthCode = statusValue === 3;
1848
+ const emoji = (0, import_util7.hexToEmoji)(id);
1849
+ const activeView = (0, import_react44.useMemo)(() => {
1850
+ if (multiUse) {
1851
+ return "showing qr";
1852
+ }
1853
+ switch (true) {
1854
+ case statusValue === 5:
1855
+ case statusValue < 0:
1856
+ return "showing final";
1857
+ case statusValue === 3:
1858
+ return "showing auth code";
1859
+ default:
1860
+ return "showing qr";
1861
+ }
1862
+ }, [
1863
+ statusValue
1864
+ ]);
1865
+ return /* @__PURE__ */ import_react44.default.createElement(import_react44.default.Fragment, null, /* @__PURE__ */ import_react44.default.createElement(Viewport.Root, {
1866
+ activeView,
1867
+ classNames: "grow plb-1"
1868
+ }, /* @__PURE__ */ import_react44.default.createElement(Viewport.Views, null, /* @__PURE__ */ import_react44.default.createElement(InvitationManagerView, {
1869
+ id: "showing qr",
1870
+ emoji
1871
+ }, /* @__PURE__ */ import_react44.default.createElement("p", {
1872
+ className: "text-sm mlb-1 font-normal text-center"
1873
+ }, t(multiUse ? "invite many qr label" : "invite one qr label")), /* @__PURE__ */ import_react44.default.createElement("div", {
1874
+ role: "none",
1875
+ className: (0, import_react_ui_theme23.mx)(import_react_ui_theme23.descriptionText, "is-full max-is-[14rem] relative")
1876
+ }, /* @__PURE__ */ import_react44.default.createElement(import_react_qr_rounded.QR, {
1877
+ rounding: 100,
1878
+ backgroundColor: "transparent",
1879
+ color: "currentColor",
1880
+ className: (0, import_react_ui_theme23.mx)("is-full bs-full p-2", showAuthCode && "invisible"),
1881
+ "aria-labelledby": qrLabel,
1882
+ errorCorrectionLevel: "Q",
1883
+ cutout: true
1884
+ }, invitationUrl ?? "never"), /* @__PURE__ */ import_react44.default.createElement(Centered, null, /* @__PURE__ */ import_react44.default.createElement(Emoji, {
1885
+ text: emoji
1886
+ }))), /* @__PURE__ */ import_react44.default.createElement("span", {
1887
+ id: qrLabel,
1888
+ className: "sr-only"
1889
+ }, t("qr label")), /* @__PURE__ */ import_react44.default.createElement(CopyButton, {
1890
+ variant: "ghost",
1891
+ value: invitationUrl ?? "never"
1892
+ })), /* @__PURE__ */ import_react44.default.createElement(InvitationManagerView, {
1893
+ id: "showing auth code"
1894
+ }, /* @__PURE__ */ import_react44.default.createElement(Label, null, t("auth code message")), /* @__PURE__ */ import_react44.default.createElement(AuthCode, {
1895
+ code: authCode,
1896
+ large: true,
1897
+ classNames: "text-black dark:text-white"
1898
+ }), /* @__PURE__ */ import_react44.default.createElement(Label, null, t("auth other device emoji message")), emoji && /* @__PURE__ */ import_react44.default.createElement(Emoji, {
1899
+ text: emoji
1900
+ })), /* @__PURE__ */ import_react44.default.createElement(InvitationManagerView, {
1901
+ id: "showing final"
1902
+ }, statusValue > 0 ? /* @__PURE__ */ import_react44.default.createElement(import_react43.Check, {
1903
+ className: (0, import_react_ui_theme23.mx)("m-1.5", (0, import_react_ui_theme23.getSize)(6))
1904
+ }) : /* @__PURE__ */ import_react44.default.createElement(import_react43.X, {
1905
+ className: (0, import_react_ui_theme23.mx)("m-1.5", (0, import_react_ui_theme23.getSize)(6))
1906
+ })))), /* @__PURE__ */ import_react44.default.createElement(Actions, {
1907
+ classNames: "mbs-4"
1908
+ }, /* @__PURE__ */ import_react44.default.createElement(Action, {
1909
+ disabled: !active,
1910
+ onClick: () => send?.({
1911
+ type: "deselectInvitation"
1912
+ })
1913
+ }, t("back label"))));
1914
+ };
1915
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/steps/ConfirmReset.tsx";
1916
+ var ConfirmReset = ({ active, onCancel, onConfirm, mode }) => {
1917
+ const { t } = (0, import_react_ui21.useTranslation)("os");
1918
+ const [validationMessage, setValidationMessage] = (0, import_react46.useState)("");
1919
+ const [pending, setPending] = (0, import_react46.useState)(false);
1920
+ const processReset = async () => {
1921
+ setPending(true);
1922
+ return onConfirm?.().then(() => setPending(false), (error) => {
1923
+ import_log6.log.catch(error, void 0, {
1924
+ F: __dxlog_file5,
1925
+ L: 38,
1926
+ S: void 0,
1927
+ C: (f, a) => f(...a)
1928
+ });
1929
+ setValidationMessage(t("failed to reset identity message"));
1930
+ setPending(false);
1931
+ });
1932
+ };
1933
+ return /* @__PURE__ */ import_react46.default.createElement(ConfirmResetImpl, {
1934
+ disabled: !active,
1935
+ pending,
1936
+ validationMessage,
1937
+ onConfirm: processReset,
1938
+ onCancel,
1939
+ mode
1940
+ });
1941
+ };
1942
+ var ConfirmResetImpl = ({ disabled, pending, validationMessage, onConfirm, onCancel, mode }) => {
1943
+ const { t } = (0, import_react_ui21.useTranslation)("os");
1944
+ const confirmationValue = t("confirmation value");
1945
+ const [inputValue, setInputValue] = (0, import_react46.useState)("");
1946
+ const testIdAffix = mode === "join new identity" ? "join-new-identity" : mode === "recover" ? "recover" : "reset-storage";
1947
+ return /* @__PURE__ */ import_react46.default.createElement(import_react46.default.Fragment, null, /* @__PURE__ */ import_react46.default.createElement("div", {
1948
+ role: "none",
1949
+ className: "grow flex flex-col gap-2 justify-center"
1950
+ }, /* @__PURE__ */ import_react46.default.createElement(import_react_ui21.Message.Root, {
1951
+ valence: "error"
1952
+ }, /* @__PURE__ */ import_react46.default.createElement(import_react_ui21.Message.Title, null, /* @__PURE__ */ import_react46.default.createElement(import_react45.Warning, {
1953
+ className: (0, import_react_ui_theme24.mx)((0, import_react_ui_theme24.getSize)(6), "inline mie-2")
1954
+ }), t("sign out chooser title")), /* @__PURE__ */ import_react46.default.createElement(import_react_ui21.Message.Body, null, t("sign out chooser message"))), /* @__PURE__ */ import_react46.default.createElement(Input, {
1955
+ validationMessage,
1956
+ label: /* @__PURE__ */ import_react46.default.createElement(StepHeading, {
1957
+ className: "text-start mlb-2"
1958
+ }, t(mode === "join new identity" ? "join new identity input label" : mode === "recover" ? "recover reset input label" : "reset storage input label", {
1959
+ confirmationValue
1960
+ })),
1961
+ disabled,
1962
+ "data-testid": `${testIdAffix}.reset-identity-input`,
1963
+ placeholder: t("confirmation placeholder", {
1964
+ confirmationValue
1965
+ }),
1966
+ onChange: ({ target: { value } }) => setInputValue(value)
1967
+ })), /* @__PURE__ */ import_react46.default.createElement(Actions, null, onCancel && /* @__PURE__ */ import_react46.default.createElement(Action, {
1968
+ disabled,
1969
+ onClick: onCancel,
1970
+ "data-testid": `${testIdAffix}.reset-identity-cancel`
1971
+ }, t("cancel label")), onConfirm && /* @__PURE__ */ import_react46.default.createElement(Action, {
1972
+ variant: "destructive",
1973
+ disabled: disabled || pending || inputValue !== confirmationValue,
1974
+ onClick: onConfirm,
1975
+ "data-testid": `${testIdAffix}.reset-identity-confirm`
1976
+ }, pending ? t("reset in progress label") : t("reset device label"))));
1977
+ };
1978
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/IdentityPanel/IdentityPanel.tsx";
1979
+ var viewStyles = "pbs-1 pbe-3 pli-3";
1980
+ var getHueValue = (identity) => identity?.profile?.data?.hue || (0, import_util5.hexToHue)(identity?.identityKey.toHex() ?? "0");
1981
+ var getEmojiValue = (identity) => identity?.profile?.data?.emoji || (0, import_util5.hexToEmoji)(identity?.identityKey.toHex() ?? "0");
1982
+ var IdentityHeading = ({ titleId, title, identity, hideRecover, onDone, onUpdateProfile, connectionState, onChangeConnectionState }) => {
1983
+ const client = (0, import_react_client2.useClient)();
1984
+ const fallbackValue = (0, import_util5.keyToFallback)(identity.identityKey);
1985
+ const { t } = (0, import_react_ui18.useTranslation)("os");
1986
+ const [displayName, setDisplayName] = (0, import_react37.useState)(identity.profile?.displayName ?? "");
1987
+ const [emoji, setEmojiDirectly] = (0, import_react37.useState)(getEmojiValue(identity));
1988
+ const [hue, setHueDirectly] = (0, import_react37.useState)(getHueValue(identity));
1989
+ const { textValue, setTextValue } = useClipboardContext();
1990
+ const identityHex = identity.identityKey.toHex();
1991
+ const publicKeyCopied = textValue === identityHex;
1992
+ const setEmoji = (nextEmoji) => {
1993
+ setEmojiDirectly(nextEmoji);
1994
+ void onUpdateProfile?.({
1995
+ ...identity.profile,
1996
+ data: {
1997
+ ...identity.profile?.data,
1998
+ emoji: nextEmoji
1999
+ }
2000
+ });
2001
+ };
2002
+ const setHue = (nextHue) => {
2003
+ setHueDirectly(nextHue);
2004
+ void onUpdateProfile?.({
2005
+ ...identity.profile,
2006
+ data: {
2007
+ ...identity.profile?.data,
2008
+ hue: nextHue
2009
+ }
2010
+ });
2011
+ };
2012
+ const handleRecoveryCode = async () => {
2013
+ (0, import_invariant.invariant)(client.services.services.IdentityService, "IdentityService not available", {
2014
+ F: __dxlog_file6,
2015
+ L: 77,
2016
+ S: void 0,
2017
+ A: [
2018
+ "client.services.services.IdentityService",
2019
+ "'IdentityService not available'"
2020
+ ]
2021
+ });
2022
+ const { seedphrase } = await client.services.services.IdentityService.createRecoveryPhrase();
2023
+ void setTextValue(seedphrase);
2024
+ };
2025
+ const isConnected = connectionState === import_mesh2.ConnectionState.ONLINE;
2026
+ return /* @__PURE__ */ import_react37.default.createElement(Heading, {
2027
+ titleId,
2028
+ title,
2029
+ corner: /* @__PURE__ */ import_react37.default.createElement(CloseButton, {
2030
+ onDone
2031
+ })
2032
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Avatar.Root, {
2033
+ size: 16,
2034
+ variant: "circle",
2035
+ status: isConnected ? "active" : "error",
2036
+ hue: hue || fallbackValue.hue
2037
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Root, {
2038
+ classNames: "flex justify-center"
2039
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Avatar.Frame, {
2040
+ classNames: "relative z-[2] -mli-4 chromatic-ignore"
2041
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Avatar.Fallback, {
2042
+ text: emoji || fallbackValue.emoji
2043
+ }))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Avatar.Label, {
2044
+ classNames: "sr-only",
2045
+ "data-testid": "identityHeading.displayName"
2046
+ }, identity.profile?.displayName ?? (0, import_display_name3.generateName)(identity.identityKey.toHex())), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Input.Root, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Input.Label, {
2047
+ srOnly: true
2048
+ }, t("display name input label")), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Input.TextInput, {
2049
+ variant: "subdued",
2050
+ "data-testid": "display-name-input",
2051
+ placeholder: t("display name input placeholder"),
2052
+ classNames: "mbs-2 text-center font-light text-xl",
2053
+ value: displayName,
2054
+ onChange: ({ target: { value } }) => setDisplayName(value),
2055
+ onBlur: ({ target: { value } }) => onUpdateProfile?.({
2056
+ ...identity.profile,
2057
+ displayName: value
2058
+ })
2059
+ })), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Root, {
2060
+ classNames: "flex justify-center items-center gap-1 pt-3"
2061
+ }, /* @__PURE__ */ import_react37.default.createElement(EmojiPickerToolbarButton, {
2062
+ emoji,
2063
+ onChangeEmoji: setEmoji,
2064
+ classNames: "bs-[--rail-action]"
2065
+ }), /* @__PURE__ */ import_react37.default.createElement(HuePickerToolbarButton, {
2066
+ hue,
2067
+ onChangeHue: setHue,
2068
+ classNames: "bs-[--rail-action]"
2069
+ }), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Root, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Trigger, {
2070
+ asChild: true
2071
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Button, {
2072
+ classNames: "bs-[--rail-action]",
2073
+ "data-testid": "update-profile-form-copy-key",
2074
+ onClick: () => setTextValue(identityHex)
2075
+ }, /* @__PURE__ */ import_react37.default.createElement("span", {
2076
+ className: "sr-only"
2077
+ }, t(publicKeyCopied ? "copy success label" : "copy self public key label")), /* @__PURE__ */ import_react37.default.createElement(import_react36.Key, {
2078
+ className: (0, import_react_ui_theme22.getSize)(5)
2079
+ }))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Portal, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Content, {
2080
+ side: "bottom",
2081
+ classNames: "z-50"
2082
+ }, t(publicKeyCopied ? "copy success label" : "copy self public key label"), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Arrow, null)))), !hideRecover && /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Root, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Trigger, {
2083
+ asChild: true
2084
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Button, {
2085
+ classNames: "bs-[--rail-action]",
2086
+ onClick: handleRecoveryCode
2087
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react36.FirstAidKit, {
2088
+ className: (0, import_react_ui_theme22.getSize)(5)
2089
+ }))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Portal, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Content, {
2090
+ side: "bottom",
2091
+ classNames: "z-50"
2092
+ }, t("create recovery code label"), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Arrow, null)))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Root, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Trigger, {
2093
+ asChild: true
2094
+ }, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Toolbar.Button, {
2095
+ classNames: [
2096
+ "bs-[--rail-action]",
2097
+ !isConnected && "text-error-500"
2098
+ ],
2099
+ onClick: () => onChangeConnectionState?.(isConnected ? import_mesh2.ConnectionState.OFFLINE : import_mesh2.ConnectionState.ONLINE)
2100
+ }, /* @__PURE__ */ import_react37.default.createElement("span", {
2101
+ className: "sr-only"
2102
+ }, t(isConnected ? "disconnect label" : "connect label")), isConnected ? /* @__PURE__ */ import_react37.default.createElement(import_react36.PlugsConnected, {
2103
+ className: (0, import_react_ui_theme22.getSize)(5)
2104
+ }) : /* @__PURE__ */ import_react37.default.createElement(import_react36.Plugs, {
2105
+ className: (0, import_react_ui_theme22.getSize)(5)
2106
+ }))), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Portal, null, /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Content, {
2107
+ side: "bottom",
2108
+ classNames: "z-50"
2109
+ }, t(isConnected ? "disconnect label" : "connect label"), /* @__PURE__ */ import_react37.default.createElement(import_react_ui18.Tooltip.Arrow, null)))))));
2110
+ };
2111
+ var IdentityPanelImpl = (props) => {
2112
+ const { identity, titleId, activeView, onUpdateProfile, onResetStorage, onRecover, onJoinNewIdentity, IdentityActionChooser: IdentityActionChooserComponent = IdentityActionChooser, InvitationManager: InvitationManagerComponent = InvitationManager, connectionState, onChangeConnectionState, onDone, ...rest } = props;
2113
+ const { t } = (0, import_react_ui18.useTranslation)("os");
2114
+ const title = (0, import_react37.useMemo)(() => {
2115
+ switch (activeView) {
2116
+ case "device invitation manager":
2117
+ return t("choose add device label");
2118
+ default:
2119
+ return t("identity heading");
2120
+ }
2121
+ }, [
2122
+ activeView,
2123
+ t
2124
+ ]);
2125
+ const onCancelReset = () => rest.send?.("unchooseAction");
2126
+ const hideRecover = rest.agentStatus !== "created";
2127
+ return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement(IdentityHeading, {
2128
+ identity,
2129
+ titleId,
2130
+ title,
2131
+ hideRecover,
2132
+ onDone,
2133
+ onUpdateProfile,
2134
+ connectionState,
2135
+ onChangeConnectionState
2136
+ }), /* @__PURE__ */ import_react37.default.createElement(Viewport.Root, {
2137
+ activeView
2138
+ }, /* @__PURE__ */ import_react37.default.createElement(Viewport.Views, null, /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2139
+ id: "identity action chooser",
2140
+ classNames: viewStyles
2141
+ }, /* @__PURE__ */ import_react37.default.createElement(IdentityActionChooserComponent, {
2142
+ active: activeView === "identity action chooser",
2143
+ ...rest,
2144
+ connectionState
2145
+ })), /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2146
+ id: "device invitation manager",
2147
+ classNames: viewStyles
2148
+ }, /* @__PURE__ */ import_react37.default.createElement(InvitationManagerComponent, {
2149
+ active: activeView === "device invitation manager",
2150
+ ...rest,
2151
+ invitationUrl: rest.createInvitationUrl(rest.invitationCode)
2152
+ })), /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2153
+ classNames: viewStyles,
2154
+ id: "confirm join new identity"
2155
+ }, /* @__PURE__ */ import_react37.default.createElement(ConfirmReset, {
2156
+ active: activeView === "confirm join new identity",
2157
+ ...rest,
2158
+ mode: "join new identity",
2159
+ onConfirm: onJoinNewIdentity,
2160
+ onCancel: onCancelReset
2161
+ })), /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2162
+ classNames: viewStyles,
2163
+ id: "confirm recover"
2164
+ }, /* @__PURE__ */ import_react37.default.createElement(ConfirmReset, {
2165
+ active: activeView === "confirm recover",
2166
+ ...rest,
2167
+ mode: "recover",
2168
+ onConfirm: onRecover,
2169
+ onCancel: onCancelReset
2170
+ })), /* @__PURE__ */ import_react37.default.createElement(Viewport.View, {
2171
+ classNames: viewStyles,
2172
+ id: "confirm reset storage"
2173
+ }, /* @__PURE__ */ import_react37.default.createElement(ConfirmReset, {
2174
+ active: activeView === "confirm reset storage",
2175
+ ...rest,
2176
+ mode: "reset storage",
2177
+ onConfirm: onResetStorage,
2178
+ onCancel: onCancelReset
2179
+ })))));
2180
+ };
2181
+ var IdentityPanelWithInvitationImpl = ({ invitation, ...props }) => {
2182
+ const invitationStatus = (0, import_invitations2.useInvitationStatus)(invitation);
2183
+ return /* @__PURE__ */ import_react37.default.createElement(IdentityPanelImpl, {
2184
+ ...props,
2185
+ ...invitationStatus
2186
+ });
2187
+ };
2188
+ var IdentityPanel = ({ titleId: propsTitleId, createInvitationUrl = (code) => code, initialDisposition = "default", ...props }) => {
2189
+ const titleId = (0, import_react_ui18.useId)("identityPanel__heading", propsTitleId);
2190
+ const client = (0, import_react_client2.useClient)();
2191
+ const devices = (0, import_halo2.useDevices)();
2192
+ const identity = (0, import_halo2.useIdentity)();
2193
+ const invitations = (0, import_halo2.useHaloInvitations)();
2194
+ const agentProps = useAgentHandlers({
2195
+ identity,
2196
+ invitations
2197
+ });
2198
+ if (!identity) {
2199
+ import_log.log.error("IdentityPanel rendered with no active identity.", void 0, {
2200
+ F: __dxlog_file6,
2201
+ L: 288,
2202
+ S: void 0,
2203
+ C: (f, a) => f(...a)
2204
+ });
2205
+ return null;
2206
+ }
2207
+ const [identityState, identitySend, identityService] = useIdentityMachine(client, {
2208
+ context: {
2209
+ initialDisposition
2210
+ }
2211
+ });
2212
+ const { swarm: connectionState } = (0, import_mesh2.useNetworkStatus)();
2213
+ const handleChangeConnectionState = async (nextState) => client?.mesh.updateConfig(nextState);
2214
+ (0, import_react37.useEffect)(() => {
2215
+ const subscription = identityService.subscribe((state) => {
2216
+ (0, import_log.log)("[state]", state, {
2217
+ F: __dxlog_file6,
2218
+ L: 301,
2219
+ S: void 0,
2220
+ C: (f, a) => f(...a)
2221
+ });
2222
+ });
2223
+ return subscription.unsubscribe;
2224
+ }, [
2225
+ identityService
2226
+ ]);
2227
+ const activeView = (0, import_react37.useMemo)(() => {
2228
+ switch (true) {
2229
+ case identityState.matches("choosingAction"):
2230
+ return "identity action chooser";
2231
+ case identityState.matches("managingDeviceInvitation"):
2232
+ return "device invitation manager";
2233
+ case identityState.matches("confirmingResetStorage"):
2234
+ return "confirm reset storage";
2235
+ case identityState.matches("confirmingRecover"):
2236
+ return "confirm recover";
2237
+ case identityState.matches("confirmingJoinNewIdentity"):
2238
+ return "confirm join new identity";
2239
+ default:
2240
+ return "identity action chooser";
2241
+ }
2242
+ }, [
2243
+ identityState
2244
+ ]);
2245
+ const onUpdateProfile = async (profile) => {
2246
+ identitySend({
2247
+ type: "updateProfile"
2248
+ });
2249
+ await client.halo.updateProfile(profile);
2250
+ };
2251
+ const implProps = {
2252
+ ...props,
2253
+ identity,
2254
+ devices,
2255
+ activeView,
2256
+ send: identitySend,
2257
+ titleId,
2258
+ createInvitationUrl,
2259
+ onUpdateProfile,
2260
+ connectionState,
2261
+ onChangeConnectionState: handleChangeConnectionState,
2262
+ ...agentProps
2263
+ };
2264
+ return identityState.context.invitation ? /* @__PURE__ */ import_react37.default.createElement(IdentityPanelWithInvitationImpl, {
2265
+ ...implProps,
2266
+ invitation: identityState.context.invitation
2267
+ }) : /* @__PURE__ */ import_react37.default.createElement(IdentityPanelImpl, implProps);
2268
+ };
2269
+ var JoinHeading = /* @__PURE__ */ (0, import_react49.forwardRef)(({ mode, titleId, exitActionParent, onExit }, forwardedRef) => {
2270
+ const { t } = (0, import_react_ui23.useTranslation)("os");
2271
+ const exitButton = /* @__PURE__ */ import_react49.default.createElement(import_react_ui23.Button, {
2272
+ variant: "ghost",
2273
+ ...onExit && {
2274
+ onClick: onExit
2275
+ },
2276
+ classNames: (0, import_react_ui_theme25.mx)(import_react_ui_theme25.descriptionText, "plb-0 pli-2 absolute block-start-0 inline-end-0 z-[1]"),
2277
+ "data-testid": "join-exit"
2278
+ }, /* @__PURE__ */ import_react49.default.createElement(import_react48.X, {
2279
+ weight: "bold",
2280
+ className: (0, import_react_ui_theme25.getSize)(4)
2281
+ }), /* @__PURE__ */ import_react49.default.createElement("span", {
2282
+ className: "sr-only"
2283
+ }, t("exit label")));
2284
+ return /* @__PURE__ */ import_react49.default.createElement(Heading, {
2285
+ ref: forwardedRef,
2286
+ titleId,
2287
+ title: t(mode === "halo-only" ? "selecting identity heading" : "joining space heading"),
2288
+ ...mode === "halo-only" ? {
2289
+ titleSrOnly: true
2290
+ } : {
2291
+ corner: exitActionParent ? /* @__PURE__ */ (0, import_react49.cloneElement)(exitActionParent, {}, exitButton) : exitButton
2292
+ },
2293
+ titleSrOnly: mode === "halo-only"
2294
+ });
2295
+ });
2296
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/JoinPanel/joinMachine.ts";
2297
+ var getInvitationSubscribable = (Kind, invitation) => {
2298
+ (0, import_log8.log)("[subscribing to invitation]", invitation, {
2299
+ F: __dxlog_file7,
2300
+ L: 90,
2301
+ S: void 0,
2302
+ C: (f, a) => f(...a)
2303
+ });
2304
+ return {
2305
+ subscribe: (next, onError, complete) => invitation.subscribe((invitation2) => {
2306
+ switch (invitation2.state) {
2307
+ case import_invitations6.Invitation.State.CONNECTING: {
2308
+ (0, import_log8.log)("[invitation connecting]", {
2309
+ Kind,
2310
+ invitation: invitation2
2311
+ }, {
2312
+ F: __dxlog_file7,
2313
+ L: 101,
2314
+ S: void 0,
2315
+ C: (f, a) => f(...a)
2316
+ });
2317
+ return next({
2318
+ type: `connecting${Kind}Invitation`,
2319
+ invitation: invitation2
2320
+ });
2321
+ }
2322
+ case import_invitations6.Invitation.State.CONNECTED: {
2323
+ (0, import_log8.log)("[invitation connected]", {
2324
+ Kind,
2325
+ invitation: invitation2
2326
+ }, {
2327
+ F: __dxlog_file7,
2328
+ L: 106,
2329
+ S: void 0,
2330
+ C: (f, a) => f(...a)
2331
+ });
2332
+ return next({
2333
+ type: `connected${Kind}Invitation`,
2334
+ invitation: invitation2
2335
+ });
2336
+ }
2337
+ case import_invitations6.Invitation.State.READY_FOR_AUTHENTICATION: {
2338
+ (0, import_log8.log)("[invitation ready for authentication]", {
2339
+ Kind,
2340
+ invitation: invitation2
2341
+ }, {
2342
+ F: __dxlog_file7,
2343
+ L: 111,
2344
+ S: void 0,
2345
+ C: (f, a) => f(...a)
2346
+ });
2347
+ return next({
2348
+ type: `readyForAuthentication${Kind}Invitation`,
2349
+ invitation: invitation2
2350
+ });
2351
+ }
2352
+ case import_invitations6.Invitation.State.AUTHENTICATING: {
2353
+ (0, import_log8.log)("[invitation authenticating]", {
2354
+ Kind,
2355
+ invitation: invitation2
2356
+ }, {
2357
+ F: __dxlog_file7,
2358
+ L: 116,
2359
+ S: void 0,
2360
+ C: (f, a) => f(...a)
2361
+ });
2362
+ return next({
2363
+ type: `authenticating${Kind}Invitation`,
2364
+ invitation: invitation2
2365
+ });
2366
+ }
2367
+ case import_invitations6.Invitation.State.SUCCESS: {
2368
+ (0, import_log8.log)("[invitation success]", {
2369
+ Kind,
2370
+ invitation: invitation2
2371
+ }, {
2372
+ F: __dxlog_file7,
2373
+ L: 121,
2374
+ S: void 0,
2375
+ C: (f, a) => f(...a)
2376
+ });
2377
+ next({
2378
+ type: `success${Kind}Invitation`,
2379
+ invitation: invitation2
2380
+ });
2381
+ return complete?.();
2382
+ }
2383
+ case import_invitations6.Invitation.State.CANCELLED: {
2384
+ import_log8.log.warn("[invitation cancelled]", {
2385
+ Kind
2386
+ }, {
2387
+ F: __dxlog_file7,
2388
+ L: 127,
2389
+ S: void 0,
2390
+ C: (f, a) => f(...a)
2391
+ });
2392
+ return next({
2393
+ type: `fail${Kind}Invitation`,
2394
+ reason: "cancelled"
2395
+ });
2396
+ }
2397
+ case import_invitations6.Invitation.State.TIMEOUT: {
2398
+ import_log8.log.error("[invitation timeout]", {
2399
+ Kind
2400
+ }, {
2401
+ F: __dxlog_file7,
2402
+ L: 132,
2403
+ S: void 0,
2404
+ C: (f, a) => f(...a)
2405
+ });
2406
+ return next({
2407
+ type: `fail${Kind}Invitation`,
2408
+ reason: "timeout"
2409
+ });
2410
+ }
2411
+ }
2412
+ }, (error) => {
2413
+ if (error instanceof import_react_client8.AlreadyJoinedError) {
2414
+ (0, import_log8.log)("[already joined]", {
2415
+ Kind,
2416
+ error
2417
+ }, {
2418
+ F: __dxlog_file7,
2419
+ L: 139,
2420
+ S: void 0,
2421
+ C: (f, a) => f(...a)
2422
+ });
2423
+ next({
2424
+ type: `success${Kind}Invitation`,
2425
+ invitation: invitation.get()
2426
+ });
2427
+ return complete?.();
2428
+ }
2429
+ import_log8.log.error("[invitation errored]", {
2430
+ Kind,
2431
+ error
2432
+ }, {
2433
+ F: __dxlog_file7,
2434
+ L: 144,
2435
+ S: void 0,
2436
+ C: (f, a) => f(...a)
2437
+ });
2438
+ next({
2439
+ type: `fail${Kind}Invitation`,
2440
+ reason: "error"
2441
+ });
2442
+ return onError?.(error);
2443
+ })
2444
+ };
2445
+ };
2446
+ var acceptingInvitationTemplate = (Kind, successTarget) => {
2447
+ const config = {
2448
+ initial: `unknown${Kind}`,
2449
+ states: {
2450
+ [`unknown${Kind}`]: {
2451
+ always: [
2452
+ {
2453
+ cond: ({ mode }) => mode === "halo-only" && Kind === "Space",
2454
+ target: "#join.finishingJoiningHalo"
2455
+ },
2456
+ {
2457
+ cond: (context) => !!context[Kind.toLowerCase()].unredeemedCode,
2458
+ target: `acceptingRedeemed${Kind}Invitation`,
2459
+ actions: [
2460
+ `redeem${Kind}InvitationCode`,
2461
+ `invalidate${Kind}InvitationCode`,
2462
+ "log"
2463
+ ]
2464
+ },
2465
+ {
2466
+ target: `inputting${Kind}InvitationCode`,
2467
+ actions: "log"
2468
+ }
2469
+ ]
2470
+ },
2471
+ [`inputting${Kind}InvitationCode`]: {},
2472
+ [`acceptingRedeemed${Kind}Invitation`]: {
2473
+ invoke: {
2474
+ src: (context) => context[Kind.toLowerCase()].invitationSubscribable
2475
+ },
2476
+ initial: `unknown${Kind}Invitation`,
2477
+ states: {
2478
+ [`unknown${Kind}Invitation`]: {
2479
+ always: [
2480
+ {
2481
+ cond: (context) => {
2482
+ if (Kind !== "Space") {
2483
+ return false;
2484
+ } else {
2485
+ const spaceKey = context.space.invitation?.spaceKey?.toHex();
2486
+ const succeededKeys = context.space.succeededKeys;
2487
+ return spaceKey ? !!succeededKeys?.has(spaceKey) : false;
2488
+ }
2489
+ },
2490
+ target: successTarget,
2491
+ actions: "log"
2492
+ },
2493
+ {
2494
+ cond: (context) => {
2495
+ const invitation = context[Kind.toLowerCase()].invitation;
2496
+ return !invitation || invitation?.state === import_invitations6.Invitation.State.CONNECTING;
2497
+ },
2498
+ target: `connecting${Kind}Invitation`,
2499
+ actions: "log"
2500
+ },
2501
+ {
2502
+ target: `inputting${Kind}VerificationCode`,
2503
+ actions: "log"
2504
+ }
2505
+ ]
2506
+ },
2507
+ [`connecting${Kind}Invitation`]: {},
2508
+ [`inputting${Kind}VerificationCode`]: {},
2509
+ [`authenticating${Kind}VerificationCode`]: {
2510
+ on: {
2511
+ [`readyForAuthentication${Kind}Invitation`]: {
2512
+ target: `authenticationFailing${Kind}VerificationCode`,
2513
+ actions: [
2514
+ "setInvitation",
2515
+ "log"
2516
+ ]
2517
+ }
2518
+ }
2519
+ },
2520
+ [`authenticationFailing${Kind}VerificationCode`]: {},
2521
+ [`failing${Kind}Invitation`]: {},
2522
+ [`success${Kind}Invitation`]: {}
2523
+ },
2524
+ on: {
2525
+ [`reset${Kind}Invitation`]: {
2526
+ target: `#join${Kind === "Halo" ? ".choosingIdentity" : ""}.accepting${Kind}Invitation.unknown${Kind}`,
2527
+ actions: [
2528
+ "resetInvitation",
2529
+ "log"
2530
+ ]
2531
+ },
2532
+ [`connecting${Kind}Invitation`]: {
2533
+ target: `.connecting${Kind}Invitation`,
2534
+ actions: [
2535
+ "setInvitation",
2536
+ "log"
2537
+ ]
2538
+ },
2539
+ [`connected${Kind}Invitation`]: {
2540
+ target: `.connecting${Kind}Invitation`,
2541
+ actions: [
2542
+ "setInvitation",
2543
+ "log"
2544
+ ]
2545
+ },
2546
+ [`readyForAuthentication${Kind}Invitation`]: {
2547
+ target: `.inputting${Kind}VerificationCode`,
2548
+ actions: [
2549
+ "setInvitation",
2550
+ "log"
2551
+ ]
2552
+ },
2553
+ [`authenticating${Kind}Invitation`]: {
2554
+ target: `.authenticating${Kind}VerificationCode`,
2555
+ actions: [
2556
+ "setInvitation",
2557
+ "log"
2558
+ ]
2559
+ },
2560
+ [`success${Kind}Invitation`]: {
2561
+ target: successTarget,
2562
+ actions: [
2563
+ "setInvitation",
2564
+ "log"
2565
+ ]
2566
+ },
2567
+ [`fail${Kind}Invitation`]: {
2568
+ target: `.failing${Kind}Invitation`,
2569
+ actions: [
2570
+ (0, import_xstate2.assign)({
2571
+ [Kind.toLowerCase()]: (context, event) => ({
2572
+ ...context[Kind.toLowerCase()],
2573
+ failReason: event.reason
2574
+ })
2575
+ }),
2576
+ "log"
2577
+ ]
2578
+ }
2579
+ }
2580
+ }
2581
+ },
2582
+ on: {
2583
+ [`set${Kind}InvitationCode`]: {
2584
+ target: `.acceptingRedeemed${Kind}Invitation`,
2585
+ actions: [
2586
+ (0, import_xstate2.assign)({
2587
+ [Kind.toLowerCase()]: (context, event) => ({
2588
+ ...context[Kind.toLowerCase()],
2589
+ unredeemedCode: event.code,
2590
+ succeededKeys: event.succeededKeys
2591
+ })
2592
+ }),
2593
+ `redeem${Kind}InvitationCode`,
2594
+ `invalidate${Kind}InvitationCode`,
2595
+ "log"
2596
+ ]
2597
+ }
2598
+ }
2599
+ };
2600
+ return config;
2601
+ };
2602
+ var joinMachine = (0, import_xstate2.createMachine)({
2603
+ id: "join",
2604
+ predictableActionArguments: true,
2605
+ context: {
2606
+ initialDisposition: "default",
2607
+ mode: "default",
2608
+ identity: null,
2609
+ halo: {},
2610
+ space: {}
2611
+ },
2612
+ initial: "unknown",
2613
+ states: {
2614
+ unknown: {
2615
+ always: [
2616
+ {
2617
+ cond: "existingIdentity",
2618
+ target: "resettingIdentity",
2619
+ actions: "log"
2620
+ },
2621
+ {
2622
+ cond: "initiallyAcceptingHaloInvitation",
2623
+ target: "#join.choosingIdentity.acceptingHaloInvitation",
2624
+ actions: "log"
2625
+ },
2626
+ {
2627
+ cond: "initiallyRecoveringIdentity",
2628
+ target: "#join.choosingIdentity.recoveringIdentity",
2629
+ actions: "log"
2630
+ },
2631
+ {
2632
+ cond: "noSelectedIdentity",
2633
+ target: "choosingIdentity",
2634
+ actions: "log"
2635
+ },
2636
+ {
2637
+ target: "acceptingSpaceInvitation",
2638
+ actions: "log"
2639
+ }
2640
+ ]
2641
+ },
2642
+ // TODO(wittjosiah): Remove.
2643
+ choosingIdentity: {
2644
+ initial: "unknownAuthMethod",
2645
+ states: {
2646
+ unknownAuthMethod: {
2647
+ always: [
2648
+ {
2649
+ cond: "hasHaloUnredeemedCode",
2650
+ target: "acceptingHaloInvitation",
2651
+ actions: "log"
2652
+ },
2653
+ {
2654
+ target: "choosingAuthMethod",
2655
+ actions: "log"
2656
+ }
2657
+ ]
2658
+ },
2659
+ choosingAuthMethod: {},
2660
+ recoveringIdentity: {},
2661
+ creatingIdentity: {},
2662
+ acceptingHaloInvitation: acceptingInvitationTemplate("Halo", "#join.acceptingSpaceInvitation"),
2663
+ confirmingAddedIdentity: {}
2664
+ },
2665
+ on: {
2666
+ recoverIdentity: {
2667
+ target: ".recoveringIdentity",
2668
+ actions: "log"
2669
+ },
2670
+ createIdentity: {
2671
+ target: ".creatingIdentity",
2672
+ actions: "log"
2673
+ },
2674
+ acceptHaloInvitation: {
2675
+ target: ".acceptingHaloInvitation",
2676
+ actions: "log"
2677
+ },
2678
+ addIdentity: {
2679
+ target: ".confirmingAddedIdentity",
2680
+ actions: "log"
2681
+ },
2682
+ selectIdentity: {
2683
+ target: "acceptingSpaceInvitation",
2684
+ actions: [
2685
+ "setIdentity",
2686
+ "log"
2687
+ ]
2688
+ },
2689
+ deselectAuthMethod: {
2690
+ target: ".choosingAuthMethod",
2691
+ actions: "log"
2692
+ }
2693
+ }
2694
+ },
2695
+ // TODO(wittjosiah): Factor out to a machine handling recovery and device invitations.
2696
+ resettingIdentity: {},
2697
+ acceptingSpaceInvitation: acceptingInvitationTemplate("Space", "#join.finishingJoiningSpace"),
2698
+ finishingJoiningSpace: {
2699
+ type: "final"
2700
+ },
2701
+ finishingJoiningHalo: {
2702
+ type: "final"
2703
+ }
2704
+ },
2705
+ on: {
2706
+ resetIdentity: {
2707
+ target: "choosingIdentity",
2708
+ actions: "unsetIdentity"
2709
+ }
2710
+ }
2711
+ }, {
2712
+ guards: {
2713
+ existingIdentity: ({ identity, mode }, _event) => mode === "halo-only" && !!identity,
2714
+ noSelectedIdentity: ({ identity }, _event) => !identity,
2715
+ initiallyAcceptingHaloInvitation: ({ identity, initialDisposition }, _event) => !identity && initialDisposition === "accept-halo-invitation",
2716
+ initiallyRecoveringIdentity: ({ identity, initialDisposition }, _event) => !identity && initialDisposition === "recover-identity",
2717
+ hasHaloUnredeemedCode: ({ halo }, _event) => !!halo.unredeemedCode,
2718
+ noSpaceInvitation: ({ space }, _event) => !space.invitation && !space.unredeemedCode
2719
+ },
2720
+ actions: {
2721
+ setIdentity: (0, import_xstate2.assign)({
2722
+ identity: (context, event) => event.identity
2723
+ }),
2724
+ unsetIdentity: (0, import_xstate2.assign)({
2725
+ identity: () => null
2726
+ }),
2727
+ resetInvitation: (0, import_xstate2.assign)({
2728
+ halo: (context, event) => {
2729
+ if (event.type !== "resetHaloInvitation") {
2730
+ return context.halo;
2731
+ }
2732
+ if (context.halo.invitationObservable) {
2733
+ void context.halo.invitationObservable.cancel();
2734
+ }
2735
+ return {
2736
+ ...context.halo,
2737
+ invitation: void 0,
2738
+ invitationObservable: void 0,
2739
+ invitationSubscribable: void 0
2740
+ };
2741
+ },
2742
+ space: (context, event) => {
2743
+ if (event.type !== "resetSpaceInvitation") {
2744
+ return context.space;
2745
+ }
2746
+ if (context.space.invitationObservable) {
2747
+ void context.space.invitationObservable.cancel();
2748
+ }
2749
+ return {
2750
+ ...context.space,
2751
+ invitation: void 0,
2752
+ invitationObservable: void 0,
2753
+ invitationSubscribable: void 0
2754
+ };
2755
+ }
2756
+ }),
2757
+ setInvitation: (0, import_xstate2.assign)({
2758
+ halo: (context, event) => event.type.includes("Halo") ? {
2759
+ ...context.halo,
2760
+ invitation: event.invitation
2761
+ } : context.halo,
2762
+ space: (context, event) => event.type.includes("Space") ? {
2763
+ ...context.space,
2764
+ invitation: event.invitation
2765
+ } : context.space
2766
+ }),
2767
+ log: (context, event) => {
2768
+ (0, import_log8.log)("[transition]", {
2769
+ event,
2770
+ haloInvitation: context.halo.invitation,
2771
+ spaceInvitation: context.space.invitation
2772
+ }, {
2773
+ F: __dxlog_file7,
2774
+ L: 425,
2775
+ S: void 0,
2776
+ C: (f, a) => f(...a)
2777
+ });
2778
+ }
2779
+ }
2780
+ });
2781
+ var defaultCodeFromUrl = (invitationType, text) => {
2782
+ try {
2783
+ const searchParams = new URLSearchParams(text.substring(text.lastIndexOf("?")));
2784
+ return searchParams.get(`${invitationType}InvitationCode`) ?? searchParams.get(`${invitationType}Invitation`) ?? searchParams.get("invitationCode") ?? searchParams.get("invitation") ?? text;
2785
+ } catch (err) {
2786
+ import_log8.log.catch(err, void 0, {
2787
+ F: __dxlog_file7,
2788
+ L: 452,
2789
+ S: void 0,
2790
+ C: (f, a) => f(...a)
2791
+ });
2792
+ return text;
2793
+ }
2794
+ };
2795
+ var useJoinMachine = (client, options) => {
2796
+ const redeemHaloInvitationCode = (0, import_react51.useCallback)(({ halo }) => {
2797
+ if (halo.unredeemedCode) {
2798
+ try {
2799
+ const invitation = import_invitations6.InvitationEncoder.decode(defaultCodeFromUrl("halo", halo.unredeemedCode));
2800
+ const invitationObservable = client.halo.join(invitation);
2801
+ return {
2802
+ ...halo,
2803
+ invitationObservable,
2804
+ invitationSubscribable: getInvitationSubscribable("Halo", invitationObservable)
2805
+ };
2806
+ } catch (err) {
2807
+ import_log8.log.error("Could not redeem device invitation code", err, {
2808
+ F: __dxlog_file7,
2809
+ L: 473,
2810
+ S: void 0,
2811
+ C: (f, a) => f(...a)
2812
+ });
2813
+ return halo;
2814
+ }
2815
+ } else {
2816
+ return halo;
2817
+ }
2818
+ }, [
2819
+ client
2820
+ ]);
2821
+ const redeemSpaceInvitationCode = (0, import_react51.useCallback)(({ space }) => {
2822
+ if (space.unredeemedCode) {
2823
+ try {
2824
+ const invitation = import_invitations6.InvitationEncoder.decode(defaultCodeFromUrl("space", space.unredeemedCode));
2825
+ const invitationObservable = client.spaces.join(invitation);
2826
+ return {
2827
+ ...space,
2828
+ invitationObservable,
2829
+ invitationSubscribable: getInvitationSubscribable("Space", invitationObservable)
2830
+ };
2831
+ } catch (err) {
2832
+ import_log8.log.error("Could not redeem space invitation code", err, {
2833
+ F: __dxlog_file7,
2834
+ L: 495,
2835
+ S: void 0,
2836
+ C: (f, a) => f(...a)
2837
+ });
2838
+ return space;
2839
+ }
2840
+ } else {
2841
+ return space;
2842
+ }
2843
+ }, [
2844
+ client
2845
+ ]);
2846
+ const invalidateHaloInvitationCode = (0, import_react51.useCallback)(({ halo }) => {
2847
+ if (halo.unredeemedCode) {
2848
+ options?.onInvalidateInvitationCode?.(halo.unredeemedCode);
2849
+ return {
2850
+ ...halo,
2851
+ unredeemedCode: void 0
2852
+ };
2853
+ } else {
2854
+ return halo;
2855
+ }
2856
+ }, [
2857
+ options?.onInvalidateInvitationCode
2858
+ ]);
2859
+ const invalidateSpaceInvitationCode = (0, import_react51.useCallback)(({ space }) => {
2860
+ if (space.unredeemedCode) {
2861
+ options?.onInvalidateInvitationCode?.(space.unredeemedCode);
2862
+ return {
2863
+ ...space,
2864
+ unredeemedCode: void 0
2865
+ };
2866
+ } else {
2867
+ return space;
2868
+ }
2869
+ }, [
2870
+ options?.onInvalidateInvitationCode
2871
+ ]);
2872
+ return (0, import_react50.useMachine)(joinMachine, {
2873
+ ...options,
2874
+ actions: {
2875
+ ...options?.actions,
2876
+ redeemHaloInvitationCode: (0, import_xstate2.assign)({
2877
+ halo: redeemHaloInvitationCode
2878
+ }),
2879
+ redeemSpaceInvitationCode: (0, import_xstate2.assign)({
2880
+ space: redeemSpaceInvitationCode
2881
+ }),
2882
+ invalidateHaloInvitationCode: (0, import_xstate2.assign)({
2883
+ halo: invalidateHaloInvitationCode
2884
+ }),
2885
+ invalidateSpaceInvitationCode: (0, import_xstate2.assign)({
2886
+ space: invalidateSpaceInvitationCode
2887
+ })
2888
+ }
2889
+ });
2890
+ };
2891
+ var AdditionMethodChooser = (viewStateProps) => {
2892
+ const disabled = !viewStateProps.active;
2893
+ const { send } = viewStateProps;
2894
+ const { t } = (0, import_react_ui24.useTranslation)("os");
2895
+ const sharedButtonProps = {
2896
+ disabled,
2897
+ after: /* @__PURE__ */ import_react53.default.createElement(import_react52.CaretRight, {
2898
+ className: (0, import_react_ui_theme26.getSize)(4),
2899
+ weight: "bold"
2900
+ }),
2901
+ slots: {
2902
+ label: {
2903
+ className: "text-sm"
2904
+ }
2905
+ }
2906
+ };
2907
+ return /* @__PURE__ */ import_react53.default.createElement(import_react53.default.Fragment, null, /* @__PURE__ */ import_react53.default.createElement(StepHeading, null, t("addition method chooser title")), /* @__PURE__ */ import_react53.default.createElement("div", {
2908
+ role: "none",
2909
+ className: "flex flex-col gap-1 grow"
2910
+ }, /* @__PURE__ */ import_react53.default.createElement(CompoundButton, {
2911
+ ...sharedButtonProps,
2912
+ description: t("create identity description"),
2913
+ before: /* @__PURE__ */ import_react53.default.createElement(import_react52.Plus, {
2914
+ className: (0, import_react_ui_theme26.getSize)(6)
2915
+ }),
2916
+ onClick: () => send({
2917
+ type: "createIdentity"
2918
+ }),
2919
+ "data-autofocus": "choosingAuthMethod",
2920
+ "data-testid": "identity-chooser.create-identity"
2921
+ }, t("create identity label")), /* @__PURE__ */ import_react53.default.createElement(CompoundButton, {
2922
+ ...sharedButtonProps,
2923
+ description: t("join identity description"),
2924
+ before: /* @__PURE__ */ import_react53.default.createElement(import_react52.QrCode, {
2925
+ className: (0, import_react_ui_theme26.getSize)(6)
2926
+ }),
2927
+ onClick: () => send({
2928
+ type: "acceptHaloInvitation"
2929
+ }),
2930
+ "data-testid": "identity-chooser.join-identity"
2931
+ }, t("join identity label")), /* @__PURE__ */ import_react53.default.createElement(CompoundButton, {
2932
+ ...sharedButtonProps,
2933
+ description: t("recover identity description"),
2934
+ before: /* @__PURE__ */ import_react53.default.createElement(import_react52.Textbox, {
2935
+ className: (0, import_react_ui_theme26.getSize)(6)
2936
+ }),
2937
+ onClick: () => send({
2938
+ type: "recoverIdentity"
2939
+ }),
2940
+ "data-testid": "identity-chooser.recover-identity"
2941
+ }, t("recover identity label"))));
2942
+ };
2943
+ var IdentityAdded = (props) => {
2944
+ const { mode, addedIdentity, active, send, onDone, doneActionParent } = props;
2945
+ const disabled = !active;
2946
+ const { t } = (0, import_react_ui25.useTranslation)("os");
2947
+ const addedIdentityHex = addedIdentity?.identityKey.toHex() ?? "0";
2948
+ const fallbackValue = (0, import_util8.hexToFallback)(addedIdentityHex);
2949
+ const labelId = (0, import_react_ui25.useId)("identityListItem__label");
2950
+ const displayName = addedIdentity?.profile?.displayName ?? (addedIdentity && (0, import_display_name4.generateName)(addedIdentityHex));
2951
+ const doneAction = /* @__PURE__ */ import_react54.default.createElement(Action, {
2952
+ ...onDone && {
2953
+ onClick: () => onDone(null)
2954
+ },
2955
+ disabled,
2956
+ "data-autofocus": "confirmingAddedIdentity",
2957
+ "data-testid": "identity-added-done"
2958
+ }, /* @__PURE__ */ import_react54.default.createElement("span", null, t("done label")));
2959
+ return /* @__PURE__ */ import_react54.default.createElement(import_react54.default.Fragment, null, /* @__PURE__ */ import_react54.default.createElement(StepHeading, null, t("identity added label")), /* @__PURE__ */ import_react54.default.createElement("div", {
2960
+ role: "none",
2961
+ className: "grow flex flex-col items-center justify-center text-center gap-2"
2962
+ }, /* @__PURE__ */ import_react54.default.createElement(import_react_ui25.Avatar.Root, {
2963
+ status: "active",
2964
+ labelId,
2965
+ hue: addedIdentity?.profile?.data?.hue || fallbackValue.hue
2966
+ }, /* @__PURE__ */ import_react54.default.createElement(import_react_ui25.Avatar.Frame, null, /* @__PURE__ */ import_react54.default.createElement(import_react_ui25.Avatar.Fallback, {
2967
+ text: addedIdentity?.profile?.data?.emoji || fallbackValue.emoji
2968
+ })), /* @__PURE__ */ import_react54.default.createElement(import_react_ui25.Avatar.Label, {
2969
+ classNames: (0, import_react_ui_theme27.mx)("text-lg truncate", !addedIdentity?.profile?.displayName && "font-mono")
2970
+ }, displayName))), /* @__PURE__ */ import_react54.default.createElement(Actions, null, mode === "halo-only" ? doneActionParent ? /* @__PURE__ */ (0, import_react54.cloneElement)(doneActionParent, {}, doneAction) : doneAction : /* @__PURE__ */ import_react54.default.createElement(Action, {
2971
+ variant: "primary",
2972
+ disabled: disabled || !addedIdentity,
2973
+ onClick: () => addedIdentity && send({
2974
+ type: "selectIdentity",
2975
+ identity: addedIdentity
2976
+ }),
2977
+ "data-autofocus": "confirmingAddedIdentity"
2978
+ }, t("continue label"))));
2979
+ };
2980
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/JoinPanel/steps/IdentityInput.tsx";
2981
+ var IdentityInput = (props) => {
2982
+ const { send, method } = props;
2983
+ const isRecover = method === "recover identity";
2984
+ const client = (0, import_react_client9.useClient)();
2985
+ const { t } = (0, import_react_ui26.useTranslation)("os");
2986
+ const [validationMessage, setValidationMessage] = (0, import_react55.useState)("");
2987
+ const createIdentity = (value) => {
2988
+ if (isRecover) {
2989
+ void client.halo.recoverIdentity({
2990
+ seedphrase: value
2991
+ }).then((identity) => {
2992
+ send?.({
2993
+ type: "selectIdentity",
2994
+ identity
2995
+ });
2996
+ }, (error) => {
2997
+ import_log9.log.catch(error, void 0, {
2998
+ F: __dxlog_file8,
2999
+ L: 38,
3000
+ S: void 0,
3001
+ C: (f, a) => f(...a)
3002
+ });
3003
+ setValidationMessage(t("failed to recover identity message"));
3004
+ });
3005
+ } else {
3006
+ void client.halo.createIdentity({
3007
+ displayName: value
3008
+ }).then((identity) => {
3009
+ send?.({
3010
+ type: "selectIdentity",
3011
+ identity
3012
+ });
3013
+ }, (error) => {
3014
+ import_log9.log.catch(error, void 0, {
3015
+ F: __dxlog_file8,
3016
+ L: 48,
3017
+ S: void 0,
3018
+ C: (f, a) => f(...a)
3019
+ });
3020
+ setValidationMessage(t("failed to create identity message"));
3021
+ });
3022
+ }
3023
+ };
3024
+ return /* @__PURE__ */ import_react55.default.createElement(IdentityInputImpl, {
3025
+ ...props,
3026
+ onDisplayNameConfirm: createIdentity,
3027
+ validationMessage
3028
+ });
3029
+ };
3030
+ var IdentityInputImpl = (props) => {
3031
+ const { method, send, active, onDisplayNameConfirm, validationMessage } = props;
3032
+ const disabled = !active;
3033
+ const { t } = (0, import_react_ui26.useTranslation)("os");
3034
+ const [inputValue, setInputValue] = (0, import_react55.useState)("");
3035
+ const isRecover = method === "recover identity";
3036
+ return /* @__PURE__ */ import_react55.default.createElement(import_react55.default.Fragment, null, /* @__PURE__ */ import_react55.default.createElement("div", {
3037
+ role: "none",
3038
+ className: "grow flex flex-col justify-center"
3039
+ }, /* @__PURE__ */ import_react55.default.createElement(Input, {
3040
+ validationMessage,
3041
+ label: /* @__PURE__ */ import_react55.default.createElement(StepHeading, null, t(isRecover ? "recover identity input label" : "new identity input label")),
3042
+ disabled,
3043
+ "data-testid": "identity-input",
3044
+ placeholder: isRecover ? "Type your recovery phrase" : "Type a display name",
3045
+ onChange: ({ target: { value } }) => setInputValue(value)
3046
+ })), /* @__PURE__ */ import_react55.default.createElement(Actions, null, /* @__PURE__ */ import_react55.default.createElement(Action, {
3047
+ variant: "ghost",
3048
+ disabled,
3049
+ onClick: () => send?.({
3050
+ type: "deselectAuthMethod"
3051
+ }),
3052
+ "data-testid": `${method === "recover identity" ? "recover" : "create"}-identity-input-back`
3053
+ }, t("back label")), /* @__PURE__ */ import_react55.default.createElement(Action, {
3054
+ variant: "primary",
3055
+ disabled,
3056
+ onClick: () => onDisplayNameConfirm?.(inputValue),
3057
+ "data-testid": `${method === "recover identity" ? "recover" : "create"}-identity-input-continue`
3058
+ }, t("continue label"))));
3059
+ };
3060
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/JoinPanel/steps/InvitationInput.tsx";
3061
+ var invitationCodeFromUrl = (text) => {
3062
+ try {
3063
+ const searchParams = new URLSearchParams(text.substring(text.lastIndexOf("?")));
3064
+ const invitation = searchParams.get("spaceInvitationCode") ?? searchParams.get("deviceInvitationCode");
3065
+ return invitation ?? text;
3066
+ } catch (err) {
3067
+ import_log10.log.catch(err, void 0, {
3068
+ F: __dxlog_file9,
3069
+ L: 25,
3070
+ S: void 0,
3071
+ C: (f, a) => f(...a)
3072
+ });
3073
+ return text;
3074
+ }
3075
+ };
3076
+ var InvitationInput = (props) => {
3077
+ const { Kind, active, send, unredeemedCode, onExit, exitActionParent, onDone, doneActionParent, succeededKeys } = props;
3078
+ const disabled = !active;
3079
+ const { t } = (0, import_react_ui28.useTranslation)("os");
3080
+ const [inputValue, setInputValue] = (0, import_react57.useState)(unredeemedCode ?? "");
3081
+ (0, import_react57.useEffect)(() => {
3082
+ unredeemedCode && setInputValue(unredeemedCode ?? "");
3083
+ }, [
3084
+ unredeemedCode
3085
+ ]);
3086
+ const handleNext = () => {
3087
+ if (inputValue.trim().length === 0) {
3088
+ return;
3089
+ }
3090
+ send({
3091
+ type: `set${Kind}InvitationCode`,
3092
+ code: invitationCodeFromUrl(inputValue),
3093
+ ...Kind === "Space" && {
3094
+ succeededKeys
3095
+ }
3096
+ });
3097
+ };
3098
+ const exitAction = /* @__PURE__ */ import_react57.default.createElement(Action, {
3099
+ variant: "ghost",
3100
+ disabled,
3101
+ ...onExit ? {
3102
+ onClick: () => onExit()
3103
+ } : {
3104
+ onClick: () => onDone?.(null)
3105
+ },
3106
+ "data-testid": "join-exit"
3107
+ }, t("cancel label"));
3108
+ return /* @__PURE__ */ import_react57.default.createElement(import_react57.default.Fragment, null, /* @__PURE__ */ import_react57.default.createElement("div", {
3109
+ role: "none",
3110
+ className: "grow flex flex-col justify-center"
3111
+ }, /* @__PURE__ */ import_react57.default.createElement(Input, {
3112
+ label: /* @__PURE__ */ import_react57.default.createElement(StepHeading, null, t("invitation input label")),
3113
+ // TODO(burdon): Translation.
3114
+ placeholder: "Type an invitation code",
3115
+ disabled,
3116
+ value: inputValue,
3117
+ onChange: ({ target: { value } }) => setInputValue(value),
3118
+ "data-autofocus": `inputting${Kind}InvitationCode`,
3119
+ "data-testid": `${Kind.toLowerCase()}-invitation-input`,
3120
+ onKeyUp: ({ key }) => key === "Enter" && handleNext()
3121
+ })), /* @__PURE__ */ import_react57.default.createElement(Actions, null, Kind === "Halo" ? null : exitActionParent ? /* @__PURE__ */ (0, import_react57.cloneElement)(exitActionParent, {}, exitAction) : doneActionParent ? /* @__PURE__ */ (0, import_react57.cloneElement)(doneActionParent, {}, exitAction) : exitAction, /* @__PURE__ */ import_react57.default.createElement(Action, {
3122
+ variant: "primary",
3123
+ disabled: disabled || inputValue.trim().length === 0,
3124
+ onClick: handleNext,
3125
+ "data-testid": `${Kind.toLowerCase()}-invitation-input-continue`
3126
+ }, t("continue label"))));
3127
+ };
3128
+ var InvitationActions = ({
3129
+ // `invitationState` does report correct state, but here we evaluate whether `failReason` is a better source of truth
3130
+ // for the UI in particular.
3131
+ invitationState,
3132
+ onInvitationCancel,
3133
+ active,
3134
+ send,
3135
+ Kind,
3136
+ failReason
3137
+ }) => {
3138
+ const { t } = (0, import_react_ui29.useTranslation)("os");
3139
+ if (failReason) {
3140
+ return /* @__PURE__ */ import_react58.default.createElement(import_react58.default.Fragment, null, /* @__PURE__ */ import_react58.default.createElement(StepHeading, {
3141
+ className: import_react_ui_theme28.descriptionText
3142
+ }, t(failReason === "timeout" ? "timeout status label" : failReason === "cancelled" ? "cancelled status label" : "error status label")), /* @__PURE__ */ import_react58.default.createElement("div", {
3143
+ role: "none",
3144
+ className: "grow"
3145
+ }), /* @__PURE__ */ import_react58.default.createElement(Actions, null, /* @__PURE__ */ import_react58.default.createElement(Action, {
3146
+ disabled: !active,
3147
+ onClick: () => send({
3148
+ type: `reset${Kind}Invitation`
3149
+ }),
3150
+ "data-testid": "invitation-rescuer-reset"
3151
+ }, t("reset label"))));
3152
+ } else {
3153
+ return /* @__PURE__ */ import_react58.default.createElement(import_react58.default.Fragment, null, /* @__PURE__ */ import_react58.default.createElement(StepHeading, {
3154
+ className: import_react_ui_theme28.descriptionText
3155
+ }, t("connecting status label")), /* @__PURE__ */ import_react58.default.createElement("div", {
3156
+ role: "none",
3157
+ className: "grow"
3158
+ }), /* @__PURE__ */ import_react58.default.createElement(Actions, null, /* @__PURE__ */ import_react58.default.createElement(Action, {
3159
+ disabled: true,
3160
+ classNames: "order-2",
3161
+ "data-testid": "next"
3162
+ }, t("next label")), /* @__PURE__ */ import_react58.default.createElement(Action, {
3163
+ disabled: !active,
3164
+ onClick: onInvitationCancel,
3165
+ "data-testid": "invitation-rescuer-cancel"
3166
+ }, t("cancel label"))));
3167
+ }
3168
+ };
3169
+ var InvitationRescuer = (props) => {
3170
+ const { Kind, invitationState, active, send } = props;
3171
+ const { t } = (0, import_react_ui29.useTranslation)("os");
3172
+ return /* @__PURE__ */ import_react58.default.createElement(import_react58.default.Fragment, null, typeof invitationState === "undefined" ? /* @__PURE__ */ import_react58.default.createElement(import_react58.default.Fragment, null, /* @__PURE__ */ import_react58.default.createElement("div", {
3173
+ role: "none",
3174
+ className: "grow flex flex-col justify-center"
3175
+ }, /* @__PURE__ */ import_react58.default.createElement(StepHeading, {
3176
+ className: import_react_ui_theme28.descriptionText
3177
+ }, "There was a problem joining the space")), /* @__PURE__ */ import_react58.default.createElement(Actions, null, /* @__PURE__ */ import_react58.default.createElement(Action, {
3178
+ disabled: !active,
3179
+ "data-testid": "invitation-rescuer-blank-reset",
3180
+ onClick: () => send({
3181
+ type: `reset${Kind}Invitation`
3182
+ })
3183
+ }, t("reset label")))) : /* @__PURE__ */ import_react58.default.createElement(InvitationActions, props));
3184
+ };
3185
+ var pinLength = 6;
3186
+ var InvitationAuthenticator = ({ failed, Kind, authMethod, active, pending, invitationId, onInvitationAuthenticate, onInvitationCancel }) => {
3187
+ const disabled = !active || pending;
3188
+ const { t } = (0, import_react_ui30.useTranslation)("os");
3189
+ const invitationType = Kind.toLowerCase();
3190
+ const [authCode, setAuthCode] = (0, import_react59.useState)("");
3191
+ const onChange = ({ target: { value } }) => {
3192
+ setAuthCode(value);
3193
+ if (value.length === pinLength) {
3194
+ document.querySelector(`[data-autofocus-pinlength="${invitationType}"]`)?.focus();
3195
+ }
3196
+ };
3197
+ return /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, /* @__PURE__ */ import_react59.default.createElement("div", {
3198
+ role: "none",
3199
+ className: "grow flex flex-col justify-center gap-4"
3200
+ }, /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.Root, failed && {
3201
+ validationValence: "error"
3202
+ }, /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.Label, {
3203
+ asChild: true
3204
+ }, authMethod === import_invitations7.Invitation.AuthMethod.SHARED_SECRET ? /* @__PURE__ */ import_react59.default.createElement(StepHeading, null, t("auth code input label")) : /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, /* @__PURE__ */ import_react59.default.createElement(StepHeading, {
3205
+ className: import_react_ui_theme29.descriptionText
3206
+ }, t("authenticating label")), /* @__PURE__ */ import_react59.default.createElement("div", {
3207
+ role: "none",
3208
+ className: "grow"
3209
+ }))), authMethod === import_invitations7.Invitation.AuthMethod.SHARED_SECRET && /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.PinInput, {
3210
+ disabled,
3211
+ length: pinLength,
3212
+ onChange,
3213
+ inputMode: "numeric",
3214
+ autoComplete: "off",
3215
+ pattern: "\\d*",
3216
+ "data-autofocus": `connecting${Kind}Invitation inputting${Kind}VerificationCode authenticationFailing${Kind}VerificationCode authenticating${Kind}VerificationCode`,
3217
+ "data-prevent-ios-autofocus": true,
3218
+ "data-testid": `${invitationType}-auth-code-input`,
3219
+ "data-1p-ignore": true
3220
+ }), failed && /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.DescriptionAndValidation, {
3221
+ classNames: "text-center"
3222
+ }, /* @__PURE__ */ import_react59.default.createElement(import_react_ui30.Input.Validation, null, t("failed to authenticate message")))), invitationId && authMethod === import_invitations7.Invitation.AuthMethod.SHARED_SECRET && /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, /* @__PURE__ */ import_react59.default.createElement(Label, null, t("auth other device emoji message")), /* @__PURE__ */ import_react59.default.createElement("div", {
3223
+ className: "flex justify-center"
3224
+ }, /* @__PURE__ */ import_react59.default.createElement(Emoji, {
3225
+ text: (0, import_util9.hexToEmoji)(invitationId)
3226
+ })))), /* @__PURE__ */ import_react59.default.createElement(Actions, null, /* @__PURE__ */ import_react59.default.createElement(Action, {
3227
+ variant: "ghost",
3228
+ disabled,
3229
+ onClick: () => onInvitationCancel?.(),
3230
+ "data-testid": `${invitationType}-invitation-authenticator-cancel`
3231
+ }, t("cancel label")), /* @__PURE__ */ import_react59.default.createElement(Action, {
3232
+ variant: "primary",
3233
+ disabled,
3234
+ onClick: () => onInvitationAuthenticate?.(authCode),
3235
+ "data-autofocus-pinlength": invitationType,
3236
+ "data-testid": `${invitationType}-invitation-authenticator-next`
3237
+ }, t("next label"))));
3238
+ };
3239
+ var stepStyles = "pbs-1 pbe-3 pli-3";
3240
+ var inactiveBgColor = "bg-neutral-100 dark:bg-neutral-600";
3241
+ var activeBgColor = "bg-primary-500 dark:bg-primary-400";
3242
+ var successBgColor = "bg-success-500 dark:bg-success-400";
3243
+ var errorBgColor = "bg-error-500 dark:bg-error-400";
3244
+ var cancelledBgColor = "bg-warning-500 dark:bg-warning-400";
3245
+ var inactiveTextColor = "text-neutral-100 dark:text-neutral-600";
3246
+ var activeTextColor = "text-primary-400 dark:text-primary-500";
3247
+ var successTextColor = "text-success-400 dark:text-success-500";
3248
+ var errorTextColor = "text-error-400 dark:text-error-500";
3249
+ var cancelledTextColor = "text-warning-400 dark:text-warning-500";
3250
+ var inactiveStrokeColor = "stroke-neutral-100 dark:stroke-neutral-700";
3251
+ var activeStrokeColor = "stroke-primary-400 dark:stroke-primary-150";
3252
+ var successStrokeColor = "stroke-success-300 dark:stroke-primary-400";
3253
+ var errorStrokeColor = "stroke-error-300 dark:stroke-error-500";
3254
+ var cancelledStrokeColor = "stroke-warning-300 dark:stroke-warning-500";
3255
+ var resolvedStrokeColor = (status) => status === import_invitations8.Invitation.State.ERROR ? errorStrokeColor : status === import_invitations8.Invitation.State.CANCELLED || status === import_invitations8.Invitation.State.TIMEOUT ? cancelledStrokeColor : successStrokeColor;
3256
+ var resolvedBgColor = (status) => status === import_invitations8.Invitation.State.ERROR ? errorBgColor : status === import_invitations8.Invitation.State.CANCELLED || status === import_invitations8.Invitation.State.TIMEOUT ? cancelledBgColor : successBgColor;
3257
+ var resolvedTextColor = (status) => status === import_invitations8.Invitation.State.ERROR ? errorTextColor : status === import_invitations8.Invitation.State.CANCELLED || status === import_invitations8.Invitation.State.TIMEOUT ? cancelledTextColor : successTextColor;
3258
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/JoinPanel/JoinPanel.tsx";
3259
+ var JoinPanelImpl = (props) => {
3260
+ const {
3261
+ titleId,
3262
+ send,
3263
+ activeView,
3264
+ failed,
3265
+ mode,
3266
+ unredeemedCodes,
3267
+ invitationIds,
3268
+ invitationStates,
3269
+ invitationAuthMethods,
3270
+ succeededKeys,
3271
+ failReasons,
3272
+ onExit,
3273
+ onHaloDone,
3274
+ // onSpaceDone,
3275
+ exitActionParent,
3276
+ doneActionParent,
3277
+ onHaloInvitationCancel,
3278
+ onSpaceInvitationCancel,
3279
+ onHaloInvitationAuthenticate,
3280
+ onSpaceInvitationAuthenticate,
3281
+ onCancelResetStorage,
3282
+ onConfirmResetStorage,
3283
+ IdentityInput: IdentityInputComponent = IdentityInput,
3284
+ ConfirmReset: ConfirmResetComponent = ConfirmReset
3285
+ } = props;
3286
+ return /* @__PURE__ */ import_react47.default.createElement(import_react47.default.Fragment, null, mode !== "halo-only" && /* @__PURE__ */ import_react47.default.createElement(JoinHeading, {
3287
+ titleId,
3288
+ mode,
3289
+ onExit,
3290
+ exitActionParent
3291
+ }), /* @__PURE__ */ import_react47.default.createElement(Viewport.Root, {
3292
+ focusManaged: true,
3293
+ activeView
3294
+ }, /* @__PURE__ */ import_react47.default.createElement(Viewport.Views, null, /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3295
+ classNames: stepStyles,
3296
+ id: "addition method chooser"
3297
+ }, /* @__PURE__ */ import_react47.default.createElement(AdditionMethodChooser, {
3298
+ send,
3299
+ active: activeView === "addition method chooser"
3300
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3301
+ classNames: stepStyles,
3302
+ id: "reset storage confirmation"
3303
+ }, /* @__PURE__ */ import_react47.default.createElement(ConfirmResetComponent, {
3304
+ send,
3305
+ active: activeView === "reset storage confirmation",
3306
+ onCancel: onCancelResetStorage,
3307
+ onConfirm: onConfirmResetStorage
3308
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3309
+ classNames: stepStyles,
3310
+ id: "create identity input"
3311
+ }, /* @__PURE__ */ import_react47.default.createElement(IdentityInputComponent, {
3312
+ send,
3313
+ method: "create identity",
3314
+ active: activeView === "create identity input"
3315
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3316
+ classNames: stepStyles,
3317
+ id: "recover identity input"
3318
+ }, /* @__PURE__ */ import_react47.default.createElement(IdentityInputComponent, {
3319
+ send,
3320
+ method: "recover identity",
3321
+ active: activeView === "recover identity input"
3322
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3323
+ classNames: stepStyles,
3324
+ id: "halo invitation input"
3325
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationInput, {
3326
+ send,
3327
+ Kind: "Halo",
3328
+ active: activeView === "halo invitation input",
3329
+ ...unredeemedCodes?.Halo && {
3330
+ unredeemedCode: unredeemedCodes.Halo
3331
+ },
3332
+ ...succeededKeys?.Halo && {
3333
+ succeededKeys: succeededKeys.Halo
3334
+ }
3335
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3336
+ classNames: stepStyles,
3337
+ id: "halo invitation rescuer"
3338
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationRescuer, {
3339
+ send,
3340
+ Kind: "Halo",
3341
+ active: activeView === "halo invitation rescuer",
3342
+ invitationState: invitationStates?.Halo,
3343
+ onInvitationCancel: onHaloInvitationCancel,
3344
+ failReason: failReasons?.Halo
3345
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3346
+ classNames: stepStyles,
3347
+ id: "halo invitation authenticator"
3348
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationAuthenticator, {
3349
+ send,
3350
+ Kind: "Halo",
3351
+ invitationId: invitationIds?.Halo,
3352
+ authMethod: invitationAuthMethods?.Halo,
3353
+ active: activeView === "halo invitation authenticator",
3354
+ onInvitationCancel: onHaloInvitationCancel,
3355
+ onInvitationAuthenticate: onHaloInvitationAuthenticate,
3356
+ ...failed.has("Halo") && {
3357
+ failed: true
3358
+ }
3359
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3360
+ classNames: stepStyles,
3361
+ id: "identity added"
3362
+ }, /* @__PURE__ */ import_react47.default.createElement(IdentityAdded, {
3363
+ send,
3364
+ mode,
3365
+ active: activeView === "identity added",
3366
+ doneActionParent,
3367
+ onDone: onHaloDone
3368
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3369
+ classNames: stepStyles,
3370
+ id: "space invitation input"
3371
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationInput, {
3372
+ send,
3373
+ Kind: "Space",
3374
+ active: activeView === "space invitation input",
3375
+ ...unredeemedCodes?.Space && {
3376
+ unredeemedCode: unredeemedCodes.Space
3377
+ },
3378
+ ...succeededKeys?.Space && {
3379
+ succeededKeys: succeededKeys.Space
3380
+ },
3381
+ onExit,
3382
+ exitActionParent
3383
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3384
+ classNames: stepStyles,
3385
+ id: "space invitation rescuer"
3386
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationRescuer, {
3387
+ send,
3388
+ Kind: "Space",
3389
+ active: activeView === "space invitation rescuer",
3390
+ invitationState: invitationStates?.Space,
3391
+ onInvitationCancel: onSpaceInvitationCancel,
3392
+ failReason: failReasons?.Space
3393
+ })), /* @__PURE__ */ import_react47.default.createElement(Viewport.View, {
3394
+ classNames: stepStyles,
3395
+ id: "space invitation authenticator"
3396
+ }, /* @__PURE__ */ import_react47.default.createElement(InvitationAuthenticator, {
3397
+ send,
3398
+ Kind: "Space",
3399
+ invitationId: invitationIds?.Space,
3400
+ authMethod: invitationAuthMethods?.Space,
3401
+ active: activeView === "space invitation authenticator",
3402
+ onInvitationCancel: onSpaceInvitationCancel,
3403
+ onInvitationAuthenticate: onSpaceInvitationAuthenticate,
3404
+ ...failed.has("Space") && {
3405
+ failed: true
3406
+ }
3407
+ })))));
3408
+ };
3409
+ var JoinPanel = ({ titleId: propsTitleId, mode = "default", initialDisposition = "default", initialInvitationCode, exitActionParent, onExit, doneActionParent, onDone: propsOnDone, onCancelResetStorage }) => {
3410
+ const client = (0, import_react_client7.useClient)();
3411
+ const identity = (0, import_halo4.useIdentity)();
3412
+ const { hasIosKeyboard } = (0, import_react_ui22.useThemeContext)();
3413
+ const titleId = (0, import_react_ui22.useId)("joinPanel__heading", propsTitleId);
3414
+ const [joinState, joinSend, joinService] = useJoinMachine(client, {
3415
+ context: {
3416
+ mode,
3417
+ initialDisposition,
3418
+ identity,
3419
+ ...initialInvitationCode && {
3420
+ [mode === "halo-only" ? "halo" : "space"]: {
3421
+ unredeemedCode: initialInvitationCode
3422
+ }
3423
+ }
3424
+ }
3425
+ });
3426
+ (0, import_react47.useEffect)(() => {
3427
+ const subscription = joinService.subscribe((state) => {
3428
+ (0, import_log7.log)("[state]", state, {
3429
+ F: __dxlog_file10,
3430
+ L: 210,
3431
+ S: void 0,
3432
+ C: (f, a) => f(...a)
3433
+ });
3434
+ });
3435
+ return subscription.unsubscribe;
3436
+ }, [
3437
+ joinService
3438
+ ]);
3439
+ (0, import_react47.useEffect)(() => {
3440
+ const stateStack = joinState.configuration[0].id.split(".");
3441
+ const innermostState = stateStack[stateStack.length - 1];
3442
+ const autoFocusValue = innermostState === "finishingJoining" ? "successSpaceInvitation" : innermostState;
3443
+ const $nextAutofocus = document.querySelector(`[data-autofocus~="${autoFocusValue}"]`);
3444
+ if ($nextAutofocus && !(hasIosKeyboard && $nextAutofocus.hasAttribute("data-prevent-ios-autofocus"))) {
3445
+ $nextAutofocus.focus();
3446
+ }
3447
+ }, [
3448
+ joinState.value,
3449
+ hasIosKeyboard
3450
+ ]);
3451
+ const activeView = (0, import_react47.useMemo)(() => {
3452
+ switch (true) {
3453
+ case joinState.matches({
3454
+ choosingIdentity: "choosingAuthMethod"
3455
+ }):
3456
+ return "addition method chooser";
3457
+ case joinState.matches("resettingIdentity"):
3458
+ return "reset storage confirmation";
3459
+ case joinState.matches({
3460
+ choosingIdentity: "creatingIdentity"
3461
+ }):
3462
+ return "create identity input";
3463
+ case joinState.matches({
3464
+ choosingIdentity: "recoveringIdentity"
3465
+ }):
3466
+ return "recover identity input";
3467
+ case joinState.matches({
3468
+ choosingIdentity: {
3469
+ acceptingHaloInvitation: "inputtingHaloInvitationCode"
3470
+ }
3471
+ }):
3472
+ return "halo invitation input";
3473
+ case [
3474
+ {
3475
+ choosingIdentity: {
3476
+ acceptingHaloInvitation: {
3477
+ acceptingRedeemedHaloInvitation: "connectingHaloInvitation"
3478
+ }
3479
+ }
3480
+ },
3481
+ {
3482
+ choosingIdentity: {
3483
+ acceptingHaloInvitation: {
3484
+ acceptingRedeemedHaloInvitation: "failingHaloInvitation"
3485
+ }
3486
+ }
3487
+ }
3488
+ ].some(joinState.matches):
3489
+ return "halo invitation rescuer";
3490
+ case [
3491
+ {
3492
+ choosingIdentity: {
3493
+ acceptingHaloInvitation: {
3494
+ acceptingRedeemedHaloInvitation: "inputtingHaloVerificationCode"
3495
+ }
3496
+ }
3497
+ },
3498
+ {
3499
+ choosingIdentity: {
3500
+ acceptingHaloInvitation: {
3501
+ acceptingRedeemedHaloInvitation: "authenticatingHaloVerificationCode"
3502
+ }
3503
+ }
3504
+ },
3505
+ {
3506
+ choosingIdentity: {
3507
+ acceptingHaloInvitation: {
3508
+ acceptingRedeemedHaloInvitation: "authenticationFailingHaloVerificationCode"
3509
+ }
3510
+ }
3511
+ }
3512
+ ].some(joinState.matches):
3513
+ return "halo invitation authenticator";
3514
+ case [
3515
+ {
3516
+ choosingIdentity: {
3517
+ acceptingHaloInvitation: {
3518
+ acceptingRedeemedHaloInvitation: "successHaloInvitation"
3519
+ }
3520
+ }
3521
+ },
3522
+ "finishingJoiningHalo"
3523
+ ].some(joinState.matches):
3524
+ return "halo invitation accepted";
3525
+ case joinState.matches({
3526
+ choosingIdentity: "confirmingAddedIdentity"
3527
+ }):
3528
+ return "identity added";
3529
+ case joinState.matches({
3530
+ acceptingSpaceInvitation: "inputtingSpaceInvitationCode"
3531
+ }):
3532
+ return "space invitation input";
3533
+ case [
3534
+ {
3535
+ acceptingSpaceInvitation: {
3536
+ acceptingRedeemedSpaceInvitation: "connectingSpaceInvitation"
3537
+ }
3538
+ },
3539
+ {
3540
+ acceptingSpaceInvitation: {
3541
+ acceptingRedeemedSpaceInvitation: "failingSpaceInvitation"
3542
+ }
3543
+ }
3544
+ ].some(joinState.matches):
3545
+ return "space invitation rescuer";
3546
+ case [
3547
+ {
3548
+ acceptingSpaceInvitation: {
3549
+ acceptingRedeemedSpaceInvitation: "inputtingSpaceVerificationCode"
3550
+ }
3551
+ },
3552
+ {
3553
+ acceptingSpaceInvitation: {
3554
+ acceptingRedeemedSpaceInvitation: "authenticatingSpaceVerificationCode"
3555
+ }
3556
+ },
3557
+ {
3558
+ acceptingSpaceInvitation: {
3559
+ acceptingRedeemedSpaceInvitation: "authenticationFailingSpaceVerificationCode"
3560
+ }
3561
+ }
3562
+ ].some(joinState.matches):
3563
+ return "space invitation authenticator";
3564
+ case joinState.matches("finishingJoiningSpace"):
3565
+ return "space invitation accepted";
3566
+ default:
3567
+ return "never";
3568
+ }
3569
+ }, [
3570
+ joinState
3571
+ ]);
3572
+ (0, import_react47.useEffect)(() => {
3573
+ switch (activeView) {
3574
+ case "halo invitation accepted":
3575
+ onHaloDone();
3576
+ break;
3577
+ case "space invitation accepted":
3578
+ onSpaceDone();
3579
+ break;
3580
+ }
3581
+ }, [
3582
+ activeView
3583
+ ]);
3584
+ const failed = (0, import_react47.useMemo)(() => {
3585
+ const result = /* @__PURE__ */ new Set();
3586
+ switch (true) {
3587
+ case joinState.matches({
3588
+ choosingIdentity: {
3589
+ acceptingHaloInvitation: {
3590
+ acceptingRedeemedHaloInvitation: "authenticationFailingHaloVerificationCode"
3591
+ }
3592
+ }
3593
+ }):
3594
+ result.add("Halo");
3595
+ break;
3596
+ case joinState.matches({
3597
+ acceptingSpaceInvitation: {
3598
+ acceptingRedeemedSpaceInvitation: "authenticationFailingSpaceVerificationCode"
3599
+ }
3600
+ }):
3601
+ result.add("Space");
3602
+ break;
3603
+ }
3604
+ return result;
3605
+ }, [
3606
+ joinState
3607
+ ]);
3608
+ const unredeemedCodes = (0, import_react47.useMemo)(() => ({
3609
+ Halo: joinState.context.halo.unredeemedCode,
3610
+ Space: joinState.context.space.unredeemedCode
3611
+ }), [
3612
+ joinState
3613
+ ]);
3614
+ const spaces = (0, import_react_client7.useMulticastObservable)(client.spaces);
3615
+ const succeededKeys = (0, import_react47.useMemo)(() => ({
3616
+ Space: spaces ? new Set(spaces.map(({ key }) => key.toHex())) : void 0
3617
+ }), [
3618
+ spaces
3619
+ ]);
3620
+ const invitationStates = (0, import_react47.useMemo)(() => ({
3621
+ Halo: joinState.context.halo.invitationObservable?.get().state,
3622
+ Space: joinState.context.space.invitationObservable?.get().state
3623
+ }), [
3624
+ joinState
3625
+ ]);
3626
+ const invitationAuthMethods = (0, import_react47.useMemo)(() => ({
3627
+ Halo: joinState.context.halo.invitationObservable?.get().authMethod,
3628
+ Space: joinState.context.space.invitationObservable?.get().authMethod
3629
+ }), [
3630
+ joinState
3631
+ ]);
3632
+ const invitationIds = (0, import_react47.useMemo)(() => ({
3633
+ Halo: joinState.context.halo.invitationObservable?.get().invitationId,
3634
+ Space: joinState.context.space.invitationObservable?.get().invitationId
3635
+ }), [
3636
+ joinState
3637
+ ]);
3638
+ const failReasons = (0, import_react47.useMemo)(() => ({
3639
+ Halo: joinState.context.halo.failReason,
3640
+ Space: joinState.context.space.failReason
3641
+ }), [
3642
+ joinState
3643
+ ]);
3644
+ const onHaloDone = (0, import_react47.useCallback)(() => {
3645
+ propsOnDone?.({
3646
+ identityKey: joinState.context.halo.invitation?.identityKey ?? null,
3647
+ swarmKey: joinState.context.halo.invitation?.swarmKey ?? null,
3648
+ spaceKey: joinState.context.halo.invitation?.spaceKey ?? null,
3649
+ target: joinState.context.halo.invitation?.target ?? null
3650
+ });
3651
+ }, [
3652
+ joinState,
3653
+ propsOnDone
3654
+ ]);
3655
+ const onSpaceDone = (0, import_react47.useCallback)(() => {
3656
+ propsOnDone?.({
3657
+ identityKey: joinState.context.space.invitation?.identityKey ?? null,
3658
+ swarmKey: joinState.context.space.invitation?.swarmKey ?? null,
3659
+ spaceKey: joinState.context.space.invitation?.spaceKey ?? null,
3660
+ target: joinState.context.space.invitation?.target ?? null
3661
+ });
3662
+ }, [
3663
+ joinState,
3664
+ propsOnDone
3665
+ ]);
3666
+ const onConfirmResetStorage = (0, import_react47.useCallback)(() => client.reset().then(() => {
3667
+ joinSend({
3668
+ type: "resetIdentity"
3669
+ });
3670
+ }), [
3671
+ client,
3672
+ joinSend
3673
+ ]);
3674
+ return /* @__PURE__ */ import_react47.default.createElement(JoinPanelImpl, {
3675
+ titleId,
3676
+ mode,
3677
+ send: joinSend,
3678
+ activeView,
3679
+ failed,
3680
+ failReasons,
3681
+ pending: [
3682
+ "connecting",
3683
+ "authenticating"
3684
+ ].some((str) => joinState?.configuration[0].id.includes(str)),
3685
+ unredeemedCodes,
3686
+ invitationIds,
3687
+ invitationStates,
3688
+ invitationAuthMethods,
3689
+ succeededKeys,
3690
+ identity,
3691
+ onExit,
3692
+ exitActionParent,
3693
+ doneActionParent,
3694
+ onHaloDone,
3695
+ onSpaceDone,
3696
+ onHaloInvitationCancel: () => joinState.context.halo.invitationObservable?.cancel(),
3697
+ onSpaceInvitationCancel: () => joinState.context.space.invitationObservable?.cancel(),
3698
+ onHaloInvitationAuthenticate: (authCode) => {
3699
+ joinSend({
3700
+ type: "authenticateHaloVerificationCode"
3701
+ });
3702
+ return joinState.context.halo.invitationObservable?.authenticate(authCode);
3703
+ },
3704
+ onSpaceInvitationAuthenticate: (authCode) => {
3705
+ joinSend({
3706
+ type: "authenticateSpaceVerificationCode"
3707
+ });
3708
+ return joinState.context.space.invitationObservable?.authenticate(authCode);
3709
+ },
3710
+ onConfirmResetStorage,
3711
+ onCancelResetStorage
3712
+ });
3713
+ };
3714
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/SpacePanel/spaceMachine.ts";
3715
+ var spaceMachine = (0, import_xstate3.createMachine)({
3716
+ id: "space",
3717
+ predictableActionArguments: true,
3718
+ context: {
3719
+ space: null
3720
+ },
3721
+ initial: "managingSpace",
3722
+ states: {
3723
+ managingSpace: {},
3724
+ managingSpaceInvitation: {}
3725
+ },
3726
+ on: {
3727
+ deselectInvitation: {
3728
+ target: ".managingSpace",
3729
+ actions: [
3730
+ "unsetInvitation",
3731
+ "log"
3732
+ ]
3733
+ },
3734
+ selectInvitation: {
3735
+ target: ".managingSpaceInvitation",
3736
+ actions: [
3737
+ "setInvitation",
3738
+ "log"
3739
+ ]
3740
+ }
3741
+ }
3742
+ }, {
3743
+ actions: {
3744
+ setInvitation: (0, import_xstate3.assign)({
3745
+ invitation: (context, event) => event?.invitation ?? null
3746
+ }),
3747
+ unsetInvitation: (0, import_xstate3.assign)({
3748
+ invitation: () => void 0
3749
+ }),
3750
+ log: (context, event) => {
3751
+ (0, import_log12.log)("[transition]", {
3752
+ event,
3753
+ context
3754
+ }, {
3755
+ F: __dxlog_file11,
3756
+ L: 53,
3757
+ S: void 0,
3758
+ C: (f, a) => f(...a)
3759
+ });
3760
+ }
3761
+ }
3762
+ });
3763
+ var useSpaceMachine = (options) => {
3764
+ return (0, import_react62.useMachine)(spaceMachine, {
3765
+ ...options,
3766
+ context: {
3767
+ ...options?.context
3768
+ }
3769
+ });
3770
+ };
3771
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/SpacePanel/steps/SpaceManager.tsx";
3772
+ var activeActionKey = "dxos:react-shell/space-manager/active-action";
3773
+ var handleInvitationEvent = (invitation, subscription) => {
3774
+ const invitationCode = import_invitations10.InvitationEncoder.encode(invitation);
3775
+ if (invitation.state === import_invitations10.Invitation.State.CONNECTING) {
3776
+ import_log13.log.info(JSON.stringify({
3777
+ invitationCode,
3778
+ authCode: invitation.authCode
3779
+ }), void 0, {
3780
+ F: __dxlog_file12,
3781
+ L: 40,
3782
+ S: void 0,
3783
+ C: (f, a) => f(...a)
3784
+ });
3785
+ subscription.unsubscribe();
3786
+ }
3787
+ };
3788
+ var SpaceManager = (props) => {
3789
+ const { space, target } = props;
3790
+ const { t } = (0, import_react_ui32.useTranslation)("os");
3791
+ const config = (0, import_react_client10.useConfig)();
3792
+ const invitations = (0, import_echo4.useSpaceInvitations)(space?.key);
3793
+ const inviteActions = {
3794
+ inviteOne: {
3795
+ label: t("invite one label"),
3796
+ description: t("invite one description"),
3797
+ icon: import_react63.UserPlus,
3798
+ onClick: (0, import_react64.useCallback)(() => {
3799
+ const invitation = space.share?.({
3800
+ type: import_invitations10.Invitation.Type.INTERACTIVE,
3801
+ authMethod: import_invitations10.Invitation.AuthMethod.SHARED_SECRET,
3802
+ multiUse: false,
3803
+ target
3804
+ });
3805
+ if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
3806
+ const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
3807
+ }
3808
+ }, [
3809
+ space
3810
+ ])
3811
+ },
3812
+ inviteMany: {
3813
+ label: t("invite many label"),
3814
+ description: t("invite many description"),
3815
+ icon: import_react63.UsersThree,
3816
+ onClick: (0, import_react64.useCallback)(() => {
3817
+ const invitation = space.share?.({
3818
+ type: import_invitations10.Invitation.Type.DELEGATED,
3819
+ authMethod: import_invitations10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY,
3820
+ multiUse: true,
3821
+ target
3822
+ });
3823
+ if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
3824
+ const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
3825
+ }
3826
+ }, [
3827
+ space
3828
+ ])
3829
+ }
3830
+ };
3831
+ return /* @__PURE__ */ import_react64.default.createElement(SpaceManagerImpl, {
3832
+ ...props,
3833
+ invitations,
3834
+ inviteActions
3835
+ });
3836
+ };
3837
+ var headingFragment = "pis-3 pie-1 plb-1 mbe-1 font-medium";
3838
+ var SpaceManagerImpl = (props) => {
3839
+ const { active, space, createInvitationUrl, send, inviteActions: propsInviteActions, invitations, showInactiveInvitations, SpaceMemberList: SpaceMemberListComponent = SpaceMemberList, InvitationList: InvitationListComponent = InvitationList } = props;
3840
+ const { t } = (0, import_react_ui32.useTranslation)("os");
3841
+ const inviteActions = propsInviteActions ?? {
3842
+ noopInvite: {
3843
+ label: t("create space invitation label"),
3844
+ description: "",
3845
+ icon: import_react63.Placeholder,
3846
+ onClick: () => {
3847
+ }
3848
+ }
3849
+ };
3850
+ const [activeAction, setInternalActiveAction] = (0, import_react64.useState)(localStorage.getItem(activeActionKey) ?? "inviteOne");
3851
+ const setActiveAction = (nextAction) => {
3852
+ setInternalActiveAction(nextAction);
3853
+ localStorage.setItem(activeActionKey, nextAction);
3854
+ };
3855
+ const visibleInvitations = showInactiveInvitations ? invitations : invitations?.filter((invitation) => ![
3856
+ import_invitations10.Invitation.State.CANCELLED
3857
+ ].includes(invitation.get().state));
3858
+ return /* @__PURE__ */ import_react64.default.createElement(import_react64.default.Fragment, null, /* @__PURE__ */ import_react64.default.createElement(import_react_ui32.ScrollArea.Root, {
3859
+ classNames: "grow shrink basis-28 -mli-2"
3860
+ }, /* @__PURE__ */ import_react64.default.createElement(import_react_ui32.ScrollArea.Viewport, {
3861
+ classNames: "is-full pie-2"
3862
+ }, !!visibleInvitations?.length && /* @__PURE__ */ import_react64.default.createElement(import_react64.default.Fragment, null, /* @__PURE__ */ import_react64.default.createElement("h3", {
3863
+ className: (0, import_react_ui_theme30.mx)(headingFragment, import_react_ui_theme30.descriptionText)
3864
+ }, t("invitation list heading")), /* @__PURE__ */ import_react64.default.createElement(InvitationListComponent, {
3865
+ className: "mb-2",
3866
+ send,
3867
+ invitations: visibleInvitations ?? [],
3868
+ onClickRemove: (invitation) => invitation.cancel(),
3869
+ createInvitationUrl
3870
+ }), /* @__PURE__ */ import_react64.default.createElement("h3", {
3871
+ className: (0, import_react_ui_theme30.mx)(headingFragment, import_react_ui_theme30.descriptionText, "mbs-2")
3872
+ }, t("space member list heading"))), /* @__PURE__ */ import_react64.default.createElement(SpaceMemberListComponent, {
3873
+ spaceKey: space.key,
3874
+ includeSelf: true
3875
+ })), /* @__PURE__ */ import_react64.default.createElement(import_react_ui32.ScrollArea.Scrollbar, {
3876
+ orientation: "vertical"
3877
+ }, /* @__PURE__ */ import_react64.default.createElement(import_react_ui32.ScrollArea.Thumb, null))), /* @__PURE__ */ import_react64.default.createElement(Actions, null, /* @__PURE__ */ import_react64.default.createElement(BifurcatedAction, {
3878
+ disabled: !active,
3879
+ actions: inviteActions,
3880
+ activeAction,
3881
+ onChangeActiveAction: setActiveAction,
3882
+ "data-testid": "spaces-panel.create-invitation"
3883
+ })));
3884
+ };
3885
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/SpacePanel/SpacePanel.tsx";
3886
+ var SpacePanelHeading = ({ titleId, space, onDone }) => {
3887
+ const { t } = (0, import_react_ui31.useTranslation)("os");
3888
+ const name = space.properties.name;
3889
+ return /* @__PURE__ */ import_react61.default.createElement(Heading, {
3890
+ titleId,
3891
+ title: t("space panel heading"),
3892
+ corner: /* @__PURE__ */ import_react61.default.createElement(CloseButton, {
3893
+ "data-testid": "identity-panel-done",
3894
+ onDone
3895
+ })
3896
+ }, /* @__PURE__ */ import_react61.default.createElement("div", {
3897
+ role: "none",
3898
+ className: "flex gap-4 items-center justify-center mlb-4"
3899
+ }, /* @__PURE__ */ import_react61.default.createElement(import_react60.Planet, {
3900
+ size: 32,
3901
+ weight: "light"
3902
+ }), /* @__PURE__ */ import_react61.default.createElement("div", {
3903
+ className: "block text-start font-light text-xl"
3904
+ }, name ?? space.key.truncate())));
3905
+ };
3906
+ var SpacePanelImpl = (props) => {
3907
+ const { titleId, activeView, space, target, SpaceManager: SpaceManagerComponent = SpaceManager, InvitationManager: InvitationManagerComponent = InvitationManager, ...rest } = props;
3908
+ return /* @__PURE__ */ import_react61.default.createElement(import_react61.default.Fragment, null, /* @__PURE__ */ import_react61.default.createElement(SpacePanelHeading, {
3909
+ ...rest,
3910
+ titleId,
3911
+ space
3912
+ }), /* @__PURE__ */ import_react61.default.createElement(Viewport.Root, {
3913
+ activeView
3914
+ }, /* @__PURE__ */ import_react61.default.createElement(Viewport.Views, null, /* @__PURE__ */ import_react61.default.createElement(Viewport.View, {
3915
+ id: "space manager",
3916
+ classNames: stepStyles
3917
+ }, /* @__PURE__ */ import_react61.default.createElement(SpaceManagerComponent, {
3918
+ active: activeView === "space manager",
3919
+ space,
3920
+ target,
3921
+ ...rest
3922
+ })), /* @__PURE__ */ import_react61.default.createElement(Viewport.View, {
3923
+ id: "space invitation manager",
3924
+ classNames: stepStyles
3925
+ }, /* @__PURE__ */ import_react61.default.createElement(InvitationManagerComponent, {
3926
+ active: activeView === "space invitation manager",
3927
+ ...rest,
3928
+ invitationUrl: props.invitationUrl
3929
+ })))));
3930
+ };
3931
+ var SpacePanelWithInvitationImpl = ({ invitation, ...props }) => {
3932
+ const invitationStatus = (0, import_invitations9.useInvitationStatus)(invitation);
3933
+ return /* @__PURE__ */ import_react61.default.createElement(SpacePanelImpl, {
3934
+ ...props,
3935
+ ...invitationStatus,
3936
+ invitationUrl: props.createInvitationUrl(invitationStatus.invitationCode)
3937
+ });
3938
+ };
3939
+ var SpacePanel = ({ titleId: propsTitleId, createInvitationUrl = (code) => code, ...props }) => {
3940
+ const titleId = (0, import_react_ui31.useId)("spacePanel__heading", propsTitleId);
3941
+ const [spaceState, spaceSend, spaceService] = useSpaceMachine({
3942
+ context: {
3943
+ space: props.space
3944
+ }
3945
+ });
3946
+ (0, import_react61.useEffect)(() => {
3947
+ const subscription = spaceService.subscribe((state) => {
3948
+ (0, import_log11.log)("[state]", state, {
3949
+ F: __dxlog_file13,
3950
+ L: 94,
3951
+ S: void 0,
3952
+ C: (f, a) => f(...a)
3953
+ });
3954
+ });
3955
+ return subscription.unsubscribe;
3956
+ }, [
3957
+ spaceService
3958
+ ]);
3959
+ const activeView = (0, import_react61.useMemo)(() => {
3960
+ switch (true) {
3961
+ case spaceState.matches("managingSpace"):
3962
+ return "space manager";
3963
+ case spaceState.matches("managingSpaceInvitation"):
3964
+ return "space invitation manager";
3965
+ default:
3966
+ return "never";
3967
+ }
3968
+ }, [
3969
+ spaceState
3970
+ ]);
3971
+ const implProps = {
3972
+ ...props,
3973
+ activeView,
3974
+ send: spaceSend,
3975
+ titleId,
3976
+ createInvitationUrl
3977
+ };
3978
+ return spaceState.context.invitation ? (
3979
+ // TODO(wittjosiah): Unused? Remove?
3980
+ /* @__PURE__ */ import_react61.default.createElement(SpacePanelWithInvitationImpl, {
3981
+ ...implProps,
3982
+ invitation: spaceState.context.invitation
3983
+ })
3984
+ ) : /* @__PURE__ */ import_react61.default.createElement(SpacePanelImpl, implProps);
3985
+ };
3986
+ var StatusPanel = ({ titleId }) => {
3987
+ const { t } = (0, import_react_ui33.useTranslation)("os");
3988
+ return /* @__PURE__ */ import_react65.default.createElement("div", {
3989
+ className: "grid place-items-center p-2 gap-2"
3990
+ }, /* @__PURE__ */ import_react65.default.createElement("p", {
3991
+ id: titleId,
3992
+ className: "font-medium text-center"
3993
+ }, t("resetting message")), /* @__PURE__ */ import_react65.default.createElement(import_react_ui33.Status, {
3994
+ indeterminate: true
3995
+ }, t("resetting message")));
3996
+ };
3997
+ var IdentityDialog = (props) => {
3998
+ const titleId = (0, import_react_ui17.useId)("identityDialog__title", props.title);
3999
+ return /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Root, {
4000
+ defaultOpen: true,
4001
+ onOpenChange: (open) => open || props.onDone?.()
4002
+ }, /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Portal, null, /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Overlay, null, /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Content, {
4003
+ "aria-labelledby": titleId,
4004
+ onOpenAutoFocus: (e) => e.preventDefault()
4005
+ }, /* @__PURE__ */ import_react35.default.createElement(ClipboardProvider, null, /* @__PURE__ */ import_react35.default.createElement(IdentityPanel, {
4006
+ ...props,
4007
+ titleId,
4008
+ doneActionParent: /* @__PURE__ */ import_react35.default.createElement(import_react_ui17.Dialog.Close, {
4009
+ asChild: true
4010
+ })
4011
+ }))))));
4012
+ };
4013
+ var JoinDialog = (joinPanelProps) => {
4014
+ const titleId = (0, import_react_ui34.useId)("joinDialog__title");
4015
+ const { height } = (0, import_react_ui34.useVisualViewport)();
4016
+ return /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Root, {
4017
+ defaultOpen: true,
4018
+ onOpenChange: (open) => open || (joinPanelProps.onExit ? joinPanelProps.onExit() : joinPanelProps.onDone?.(null))
4019
+ }, /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Portal, null, /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Overlay, {
4020
+ classNames: "backdrop-blur",
4021
+ ...height && {
4022
+ style: {
4023
+ blockSize: `${height}px`
4024
+ }
4025
+ }
4026
+ }, /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Content, {
4027
+ "aria-labelledby": titleId
4028
+ }, /* @__PURE__ */ import_react66.default.createElement(JoinPanel, {
4029
+ ...joinPanelProps,
4030
+ titleId,
4031
+ exitActionParent: /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Cancel, {
4032
+ asChild: true
4033
+ }),
4034
+ doneActionParent: /* @__PURE__ */ import_react66.default.createElement(import_react_ui34.AlertDialog.Action, {
4035
+ asChild: true
4036
+ })
4037
+ })))));
4038
+ };
4039
+ var SpaceDialog = (spacePanelProps) => {
4040
+ const titleId = (0, import_react_ui36.useId)("spaceDialog__title");
4041
+ return /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Root, {
4042
+ defaultOpen: true,
4043
+ onOpenChange: (open) => open || spacePanelProps.onDone?.()
4044
+ }, /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Portal, null, /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Overlay, null, /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Content, {
4045
+ "aria-labelledby": titleId
4046
+ }, /* @__PURE__ */ import_react69.default.createElement(ClipboardProvider, null, /* @__PURE__ */ import_react69.default.createElement(SpacePanel, {
4047
+ ...spacePanelProps,
4048
+ titleId,
4049
+ doneActionParent: /* @__PURE__ */ import_react69.default.createElement(import_react_ui36.Dialog.Close, {
4050
+ asChild: true
4051
+ })
4052
+ }))))));
4053
+ };
4054
+ var StatusDialog = () => {
4055
+ const titleId = (0, import_react_ui37.useId)("statusDialog__title");
4056
+ return /* @__PURE__ */ import_react70.default.createElement(import_react_ui37.AlertDialog.Root, {
4057
+ open: true
4058
+ }, /* @__PURE__ */ import_react70.default.createElement(import_react_ui37.AlertDialog.Portal, null, /* @__PURE__ */ import_react70.default.createElement(import_react_ui37.AlertDialog.Overlay, null, /* @__PURE__ */ import_react70.default.createElement(import_react_ui37.AlertDialog.Content, {
4059
+ "aria-labelledby": titleId
4060
+ }, /* @__PURE__ */ import_react70.default.createElement(StatusPanel, {
4061
+ titleId
4062
+ })))));
4063
+ };
4064
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/composites/Shell/Shell.tsx";
4065
+ var blurActiveElement = () => document.activeElement?.blur?.();
4066
+ var Shell = ({ runtime }) => {
4067
+ const [{ layout, invitationCode, spaceKey, spaceId, target }, setLayout] = (0, import_react68.useState)({
4068
+ layout: runtime.layout,
4069
+ invitationCode: runtime.invitationCode,
4070
+ spaceKey: runtime.spaceKey,
4071
+ spaceId: runtime.spaceId,
4072
+ target: runtime.target
4073
+ });
4074
+ const [{ invitationUrl, deviceInvitationParam, spaceInvitationParam }, setInvitationUrl] = (0, import_react68.useState)({
4075
+ invitationUrl: runtime.invitationUrl,
4076
+ deviceInvitationParam: runtime.deviceInvitationParam,
4077
+ spaceInvitationParam: runtime.spaceInvitationParam
4078
+ });
4079
+ const client = (0, import_react_client12.useClient)();
4080
+ const space = (0, import_echo5.useSpace)(spaceId ?? spaceKey);
4081
+ const createDeviceInvitationUrl = (invitationCode2) => {
4082
+ const baseUrl = new URL(invitationUrl);
4083
+ baseUrl.searchParams.set(deviceInvitationParam, invitationCode2);
4084
+ return baseUrl.toString();
4085
+ };
4086
+ const createSpaceInvitationUrl = (invitationCode2) => {
4087
+ const baseUrl = new URL(invitationUrl);
4088
+ baseUrl.searchParams.set(spaceInvitationParam, invitationCode2);
4089
+ return baseUrl.toString();
4090
+ };
4091
+ (0, import_react68.useEffect)(() => {
4092
+ const unsubscribeLayout = runtime.layoutUpdate.on((request) => setLayout(request));
4093
+ const unsubscribeInvitationUrl = runtime.invitationUrlUpdate.on((request) => setInvitationUrl(request));
4094
+ return () => {
4095
+ unsubscribeLayout();
4096
+ unsubscribeInvitationUrl();
4097
+ };
4098
+ }, [
4099
+ runtime
4100
+ ]);
4101
+ (0, import_react68.useEffect)(() => {
4102
+ if (layout === import_react_client13.ShellLayout.SPACE && !space) {
4103
+ import_log14.log.warn("No space found for shell space invitations.", void 0, {
4104
+ F: __dxlog_file14,
4105
+ L: 67,
4106
+ S: void 0,
4107
+ C: (f, a) => f(...a)
4108
+ });
4109
+ const timeout = setTimeout(async () => {
4110
+ await runtime.setAppContext({
4111
+ display: import_react_client13.ShellDisplay.NONE
4112
+ });
4113
+ runtime.setLayout({
4114
+ layout: import_react_client13.ShellLayout.DEFAULT
4115
+ });
4116
+ });
4117
+ return () => clearTimeout(timeout);
4118
+ }
4119
+ }, [
4120
+ runtime,
4121
+ layout,
4122
+ space
4123
+ ]);
4124
+ switch (layout) {
4125
+ case import_react_client13.ShellLayout.STATUS:
4126
+ return /* @__PURE__ */ import_react68.default.createElement(StatusDialog, null);
4127
+ case import_react_client13.ShellLayout.INITIALIZE_IDENTITY:
4128
+ case import_react_client13.ShellLayout.INITIALIZE_IDENTITY_FROM_INVITATION:
4129
+ case import_react_client13.ShellLayout.INITIALIZE_IDENTITY_FROM_RECOVERY:
4130
+ return /* @__PURE__ */ import_react68.default.createElement(JoinDialog, {
4131
+ mode: "halo-only",
4132
+ initialDisposition: layout === import_react_client13.ShellLayout.INITIALIZE_IDENTITY_FROM_RECOVERY ? "recover-identity" : layout === import_react_client13.ShellLayout.INITIALIZE_IDENTITY_FROM_INVITATION ? "accept-halo-invitation" : "default",
4133
+ initialInvitationCode: invitationCode,
4134
+ onCancelResetStorage: () => runtime.setLayout({
4135
+ layout: import_react_client13.ShellLayout.IDENTITY
4136
+ }),
4137
+ onDone: async () => {
4138
+ blurActiveElement();
4139
+ await runtime.setAppContext({
4140
+ display: import_react_client13.ShellDisplay.NONE
4141
+ });
4142
+ runtime.setLayout({
4143
+ layout: import_react_client13.ShellLayout.DEFAULT
4144
+ });
4145
+ }
4146
+ });
4147
+ case import_react_client13.ShellLayout.IDENTITY:
4148
+ case import_react_client13.ShellLayout.SHARE_IDENTITY:
4149
+ case import_react_client13.ShellLayout.EDIT_PROFILE:
4150
+ return /* @__PURE__ */ import_react68.default.createElement(IdentityDialog, {
4151
+ createInvitationUrl: createDeviceInvitationUrl,
4152
+ onResetStorage: async () => {
4153
+ runtime.setLayout({
4154
+ layout: import_react_client13.ShellLayout.STATUS
4155
+ });
4156
+ await client.reset();
4157
+ return runtime.setAppContext({
4158
+ display: import_react_client13.ShellDisplay.NONE,
4159
+ reset: true
4160
+ });
4161
+ },
4162
+ onRecover: async () => {
4163
+ runtime.setLayout({
4164
+ layout: import_react_client13.ShellLayout.STATUS
4165
+ });
4166
+ await client.reset();
4167
+ return runtime.setAppContext({
4168
+ display: import_react_client13.ShellDisplay.NONE,
4169
+ reset: true,
4170
+ target: "recoverIdentity"
4171
+ });
4172
+ },
4173
+ onJoinNewIdentity: async () => {
4174
+ runtime.setLayout({
4175
+ layout: import_react_client13.ShellLayout.STATUS
4176
+ });
4177
+ await client.reset();
4178
+ return runtime.setAppContext({
4179
+ display: import_react_client13.ShellDisplay.NONE,
4180
+ reset: true,
4181
+ target: "deviceInvitation"
4182
+ });
4183
+ },
4184
+ onDone: async () => {
4185
+ blurActiveElement();
4186
+ await runtime.setAppContext({
4187
+ display: import_react_client13.ShellDisplay.NONE
4188
+ });
4189
+ runtime.setLayout({
4190
+ layout: import_react_client13.ShellLayout.DEFAULT
4191
+ });
4192
+ },
4193
+ initialDisposition: layout === import_react_client13.ShellLayout.SHARE_IDENTITY ? "manage-device-invitation" : "default"
4194
+ });
4195
+ case import_react_client13.ShellLayout.SPACE:
4196
+ return space ? /* @__PURE__ */ import_react68.default.createElement(SpaceDialog, {
4197
+ space,
4198
+ target,
4199
+ createInvitationUrl: createSpaceInvitationUrl,
4200
+ onDone: async () => {
4201
+ blurActiveElement();
4202
+ await runtime.setAppContext({
4203
+ display: import_react_client13.ShellDisplay.NONE
4204
+ });
4205
+ runtime.setLayout({
4206
+ layout: import_react_client13.ShellLayout.DEFAULT
4207
+ });
4208
+ }
4209
+ }) : null;
4210
+ case import_react_client13.ShellLayout.JOIN_SPACE:
4211
+ return /* @__PURE__ */ import_react68.default.createElement(JoinDialog, {
4212
+ initialInvitationCode: invitationCode,
4213
+ onDone: async (result) => {
4214
+ blurActiveElement();
4215
+ const target2 = result?.target ?? void 0;
4216
+ await runtime.setAppContext({
4217
+ display: import_react_client13.ShellDisplay.NONE,
4218
+ spaceKey: result?.spaceKey ?? void 0,
4219
+ target: target2
4220
+ });
4221
+ runtime.setLayout({
4222
+ layout: import_react_client13.ShellLayout.DEFAULT
4223
+ });
4224
+ },
4225
+ onExit: async () => {
4226
+ blurActiveElement();
4227
+ await runtime.setAppContext({
4228
+ display: import_react_client13.ShellDisplay.NONE
4229
+ });
4230
+ runtime.setLayout({
4231
+ layout: import_react_client13.ShellLayout.DEFAULT
4232
+ });
4233
+ }
4234
+ });
4235
+ default:
4236
+ return null;
4237
+ }
4238
+ };
4239
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/composites/Shell/shell-runtime.ts";
4240
+ var ShellRuntimeImpl = class {
4241
+ constructor(_port) {
4242
+ this._port = _port;
4243
+ this.layoutUpdate = new import_async.Event();
4244
+ this.invitationUrlUpdate = new import_async.Event();
4245
+ this._layout = import_iframe.ShellLayout.DEFAULT;
4246
+ this._invitationUrl = typeof window !== "undefined" ? window.location.origin : void 0;
4247
+ this._deviceInvitationParam = "deviceInvitationCode";
4248
+ this._spaceInvitationParam = "spaceInvitationCode";
4249
+ }
4250
+ get layout() {
4251
+ return this._layout;
4252
+ }
4253
+ get invitationCode() {
4254
+ return this._invitationCode;
4255
+ }
4256
+ /** @deprecated Use spaceId. */
4257
+ get spaceKey() {
4258
+ return this._spaceKey;
4259
+ }
4260
+ get spaceId() {
4261
+ return this._spaceId;
4262
+ }
4263
+ get invitationUrl() {
4264
+ return this._invitationUrl;
4265
+ }
4266
+ get deviceInvitationParam() {
4267
+ return this._deviceInvitationParam;
4268
+ }
4269
+ get spaceInvitationParam() {
4270
+ return this._spaceInvitationParam;
4271
+ }
4272
+ setLayout({ layout, invitationCode, spaceKey, spaceId }) {
4273
+ this._layout = layout;
4274
+ this._invitationCode = invitationCode;
4275
+ this._spaceKey = spaceKey;
4276
+ this._spaceId = spaceId;
4277
+ this.layoutUpdate.emit({
4278
+ layout,
4279
+ invitationCode,
4280
+ spaceKey,
4281
+ spaceId
4282
+ });
4283
+ }
4284
+ setInvitationUrl({ invitationUrl, deviceInvitationParam, spaceInvitationParam }) {
4285
+ this._invitationUrl = invitationUrl;
4286
+ this._deviceInvitationParam = deviceInvitationParam;
4287
+ this._spaceInvitationParam = spaceInvitationParam;
4288
+ this.invitationUrlUpdate.emit({
4289
+ invitationUrl,
4290
+ deviceInvitationParam,
4291
+ spaceInvitationParam
4292
+ });
4293
+ }
4294
+ async setAppContext(context) {
4295
+ (0, import_invariant4.invariant)(this._appRpc, "runtime not open", {
4296
+ F: __dxlog_file15,
4297
+ L: 83,
4298
+ S: this,
4299
+ A: [
4300
+ "this._appRpc",
4301
+ "'runtime not open'"
4302
+ ]
4303
+ });
4304
+ await this._appRpc.rpc.AppService.setContext(context);
4305
+ }
4306
+ async open() {
4307
+ this._appRpc = (0, import_rpc.createProtoRpcPeer)({
4308
+ requested: import_client_protocol2.appServiceBundle,
4309
+ exposed: import_client_protocol2.shellServiceBundle,
4310
+ handlers: {
4311
+ ShellService: {
4312
+ setLayout: async (request) => {
4313
+ this._layout = request.layout;
4314
+ this._invitationCode = request.invitationCode;
4315
+ this._spaceKey = request.spaceKey;
4316
+ this._spaceId = request.spaceId;
4317
+ this.layoutUpdate.emit(request);
4318
+ },
4319
+ setInvitationUrl: async (request) => {
4320
+ this._invitationUrl = request.invitationUrl;
4321
+ this._deviceInvitationParam = request.deviceInvitationParam;
4322
+ this._spaceInvitationParam = request.spaceInvitationParam;
4323
+ this.invitationUrlUpdate.emit(request);
4324
+ }
4325
+ }
4326
+ },
4327
+ port: this._port
4328
+ });
4329
+ await this._appRpc.open();
4330
+ }
4331
+ async close() {
4332
+ await this._appRpc?.close();
4333
+ this._appRpc = void 0;
4334
+ }
4335
+ };
4336
+ var en_US_exports = {};
4337
+ (0, import_chunk_Q7SFCCGT.__export)(en_US_exports, {
4338
+ os: () => os
4339
+ });
4340
+ var os = {
4341
+ "manage profile label": "Manage identity",
4342
+ "identity offline description": "Offline",
4343
+ "sidebar label": "DXOS sidebar",
4344
+ "copy invitation code label": "Copy URL",
4345
+ "copy success label": "Copied",
4346
+ "copy self public key label": "Copy public key",
4347
+ "open share panel label": "View QR code",
4348
+ "joining space heading": "Joining space",
4349
+ "join space heading": "Enter space invitation",
4350
+ "halo heading": "Initialize device identity",
4351
+ "exit label": "Exit",
4352
+ "identity selector title": "Join as",
4353
+ "identity radio group title": "Select an identity you\u2019ve associated with this device already",
4354
+ "add identity label": "Add",
4355
+ "continue label": "Continue",
4356
+ "back label": "Back",
4357
+ "next label": "Next",
4358
+ "close label": "Close",
4359
+ "auth choices label": "Choose an identity",
4360
+ "create identity label": "Create an identity",
4361
+ "create identity description": "Create a new identity.",
4362
+ "recover identity label": "Use a seed phrase",
4363
+ "recover identity description": "Enter your seed phrase to log in manually.",
4364
+ "join identity label": "Use another device",
4365
+ "join identity description": "Add this device to an identity you\u2019re already logged into on another device.",
4366
+ "deselect identity label": "Back to identities",
4367
+ "addition method chooser title": "An identity is required to continue",
4368
+ "new identity input label": "Set display name",
4369
+ "recover identity input label": "Type or paste your seed phrase",
4370
+ "failed to create identity message": "Failed to create an identity.",
4371
+ "failed to recover identity message": "Failed to recover an identity from the provided seed phrase.",
4372
+ "failed to authenticate message": "Incorrect code.",
4373
+ "identity added label": "Created identity & added to this device:",
4374
+ "join space as identity heading": "<part>as </part><part><icon/><label>{{labelValue}}</label></part>",
4375
+ "error status label": "Failed",
4376
+ "timeout status label": "Timed out",
4377
+ "cancelled status label": "Cancelled",
4378
+ "init status label": "Ready to connect",
4379
+ "connecting status label": "Connecting\u2026",
4380
+ "connected status label": "Enter authentication code",
4381
+ "authenticating status label": "Enter authentication code",
4382
+ "success status label": "Success",
4383
+ "cancel label": "Cancel",
4384
+ "done label": "Done",
4385
+ "reset label": "Start over",
4386
+ "auth code input label": "Enter the verification code",
4387
+ "invitation input label": "Paste an invitation code or URL",
4388
+ "create device invitation label": "Add device",
4389
+ "create space invitation label": "Invite",
4390
+ "qr label": "Scan to accept invitation",
4391
+ "empty invitations message": "No pending invitations",
4392
+ "empty device list message": "No devices authenticated other than this device.",
4393
+ "show all spaces label": "All spaces",
4394
+ "all spaces label": "All spaces",
4395
+ "create space label": "Create a new space",
4396
+ "join space label": "Join a space",
4397
+ "show current space label": "Current space",
4398
+ "view space invitations label": "View space invitations",
4399
+ "toggle sidebar label": "Open/close sidebar",
4400
+ "open sidebar label": "Open sidebar",
4401
+ "close sidebar label": "Close sidebar",
4402
+ "welcome message": "Welcome",
4403
+ "selecting identity heading": "Selecting identity",
4404
+ "devices heading": "Devices",
4405
+ "identity heading": "Profile settings",
4406
+ "choose add device label": "Add device",
4407
+ "choose devices label": "Manage devices",
4408
+ "choose profile label": "Edit profile",
4409
+ "choose sign out label": "Reset storage",
4410
+ "choose join new identity label": "Join existing device",
4411
+ "empty space members message": "There is nobody in this space yet.",
4412
+ "back to all invitations label": "Back to all invitations",
4413
+ "invitation heading": "Invitation",
4414
+ "invitation list heading": "Invitations",
4415
+ "device invitation list heading": "Pending device invitations",
4416
+ "space invitation list heading": "Pending invitations",
4417
+ "device list heading": "Devices",
4418
+ "space member list heading": "Members",
4419
+ "space panel heading": "Space membership",
4420
+ "auth code message": "Enter the following auth code on the joining device.",
4421
+ "auth other device emoji message": "Be sure the other device shows the following symbol:",
4422
+ "display name input label": "Display name",
4423
+ "display name input placeholder": "Enter a display name",
4424
+ "invite one label": "Single-use invitation",
4425
+ "invite one description": "Only one user may join.",
4426
+ "invite one qr label": "Single-use invitation",
4427
+ "invite one list item label": "Active single-use invitation",
4428
+ "invite many label": "Multi-use invitation",
4429
+ "invite many description": "Anyone with the link can join.",
4430
+ "invite many qr label": "Multi-use invitation",
4431
+ "invite many list item label": "Active multi-use invitation",
4432
+ "invite options label": "Change the active invite option.",
4433
+ "reset in progress label": "Resetting...",
4434
+ "confirm label": "Confirm",
4435
+ "reset storage input label": "WARNING: This will delete all data on this device. Type {{confirmationValue}} to continue.",
4436
+ "join new identity input label": "WARNING: To join an existing device all data on this device will be deleted. Type {{confirmationValue}} to continue.",
4437
+ "failed to reset identity message": "Failed to reset identity.",
4438
+ "confirmation value": "RESET",
4439
+ "confirmation placeholder": "Enter {{confirmationValue}} to continue.",
4440
+ "sign out chooser title": "Danger zone",
4441
+ "sign out chooser message": "Proceeding with the action below will erase all data on this device.",
4442
+ "join new identity label": "Join a new identity",
4443
+ "reset device label": "Reset storage",
4444
+ "reset device confirm message": "Are you sure you want to reset your device? All data will be lost.",
4445
+ "emoji and color label": "Emoji and color",
4446
+ "clear label": "Use default",
4447
+ "select emoji label": "Avatar emoji",
4448
+ "select hue label": "Avatar background color",
4449
+ "resetting message": "One moment while the device is reset\u2026",
4450
+ "red label": "Red",
4451
+ "orange label": "Orange",
4452
+ "amber label": "Amber",
4453
+ "yellow label": "Yellow",
4454
+ "lime label": "Lime",
4455
+ "green label": "Green",
4456
+ "emerald label": "Emerald",
4457
+ "teal label": "Teal",
4458
+ "cyan label": "Cyan",
4459
+ "sky label": "Sky",
4460
+ "blue label": "Blue",
4461
+ "indigo label": "Indigo",
4462
+ "violet label": "Violet",
4463
+ "purple label": "Purple",
4464
+ "fuchsia label": "Fuchsia",
4465
+ "pink label": "Pink",
4466
+ "rose label": "Rose",
4467
+ "current device tag label": "This device",
4468
+ "device name placeholder": "{{platform}} on {{os}}",
4469
+ "more options label": "More options",
4470
+ "disconnect label": "Go offline.",
4471
+ "connect label": "Go online.",
4472
+ "edit device label": "Edit device name & avatar",
4473
+ "agent heading": "Agent",
4474
+ "create agent clickwrap": 'By creating an agent, you agree to our <tosLink href="https://dxos.org/tos">Terms of\xA0Service</tosLink>.',
4475
+ "create agent description": "Creating an agent helps keep your devices and peers in-sync. An agent is like any other device, but since it\u2019s always online your changes will sync even when all your physical devices are\xA0asleep.",
4476
+ "create agent label": "Start an agent",
4477
+ "destroy agent label": "Shut down agent",
4478
+ "agent device label": "Your agent",
4479
+ "shell fallback title": "Shell failed to connect",
4480
+ "creating agent label": "Starting agent\u2026",
4481
+ "destroying agent label": "Stopping agent\u2026",
4482
+ "getting agent label": "Checking agent status\u2026",
4483
+ "agent requested label": "Agent requested",
4484
+ "agent requested description": "The agent service is creating an agent for you. Once the agent connects, it will display in the devices list.",
4485
+ "authenticating label": "Authenticating\u2026",
4486
+ "create recovery code label": "Create recovery code",
4487
+ "choose recover identity label": "Recover identity"
4488
+ };
4489
+ var osTranslations = {
4490
+ "en-US": en_US_exports
4491
+ };
4492
+ var runShell = async (config = new import_react_client11.Config()) => {
4493
+ const runtime = new ShellRuntimeImpl((0, import_rpc_tunnel.createIFramePort)({
4494
+ channel: import_client_protocol.DEFAULT_SHELL_CHANNEL
4495
+ }));
4496
+ await runtime.open();
4497
+ try {
4498
+ const services = new import_react_client11.ClientServicesProxy((0, import_rpc_tunnel.createIFramePort)({
4499
+ channel: import_client_protocol.DEFAULT_CLIENT_CHANNEL
4500
+ }));
4501
+ (0, import_client.createRoot)(document.getElementById("root")).render(/* @__PURE__ */ import_react67.default.createElement(import_react67.StrictMode, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.ThemeProvider, {
4502
+ tx: import_react_ui_theme31.defaultTx,
4503
+ resourceExtensions: [
4504
+ osTranslations
4505
+ ]
4506
+ }, /* @__PURE__ */ import_react67.default.createElement(import_react_client11.ClientProvider, {
4507
+ config,
4508
+ services,
4509
+ noBanner: true
4510
+ }, /* @__PURE__ */ import_react67.default.createElement(ClipboardProvider, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Tooltip.Provider, null, /* @__PURE__ */ import_react67.default.createElement(import_react_client11.AgentHostingProvider, null, /* @__PURE__ */ import_react67.default.createElement(Shell, {
4511
+ runtime
4512
+ }))))))));
4513
+ } catch {
4514
+ (0, import_client.createRoot)(document.getElementById("root")).render(/* @__PURE__ */ import_react67.default.createElement(import_react67.StrictMode, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.ThemeProvider, {
4515
+ tx: import_react_ui_theme31.defaultTx,
4516
+ resourceExtensions: [
4517
+ osTranslations
4518
+ ]
4519
+ }, /* @__PURE__ */ import_react67.default.createElement(Fallback, {
4520
+ onClose: () => runtime.setAppContext({
4521
+ display: import_react_client11.ShellDisplay.NONE
4522
+ })
4523
+ }))));
4524
+ }
4525
+ };
4526
+ var Fallback = ({ onClose }) => {
4527
+ const { t } = (0, import_react_ui35.useTranslation)("os");
4528
+ return /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Root, {
4529
+ modal: true,
4530
+ open: true,
4531
+ onOpenChange: () => onClose?.()
4532
+ }, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Overlay, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Content, null, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Title, null, t("shell fallback title")), /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Dialog.Close, {
4533
+ asChild: true,
4534
+ onClick: () => onClose?.()
4535
+ }, /* @__PURE__ */ import_react67.default.createElement(import_react_ui35.Button, {
4536
+ variant: "primary"
4537
+ }, t("close label"))))));
4538
+ };
4539
+ var MemoryShellRuntime = class {
4540
+ constructor({ layout, invitationCode, spaceKey, invitationUrl, deviceInvitationParam, spaceInvitationParam } = {}) {
4541
+ this.layoutUpdate = new import_async2.Event();
4542
+ this.invitationUrlUpdate = new import_async2.Event();
4543
+ this.contextUpdate = new import_async2.Event();
4544
+ this._layout = layout ?? import_react_client15.ShellLayout.DEFAULT;
4545
+ this._invitationCode = invitationCode;
4546
+ this._spaceKey = spaceKey;
4547
+ this._invitationUrl = invitationUrl ?? window.location.origin;
4548
+ this._deviceInvitationParam = deviceInvitationParam ?? "deviceInvitationCode";
4549
+ this._spaceInvitationParam = spaceInvitationParam ?? "spaceInvitationCode";
4550
+ }
4551
+ get layout() {
4552
+ return this._layout;
4553
+ }
4554
+ get invitationCode() {
4555
+ return this._invitationCode;
4556
+ }
4557
+ get spaceKey() {
4558
+ return this._spaceKey;
4559
+ }
4560
+ get invitationUrl() {
4561
+ return this._invitationUrl;
4562
+ }
4563
+ get deviceInvitationParam() {
4564
+ return this._deviceInvitationParam;
4565
+ }
4566
+ get spaceInvitationParam() {
4567
+ return this._spaceInvitationParam;
4568
+ }
4569
+ setLayout(request) {
4570
+ this._layout = request.layout;
4571
+ this._invitationCode = request.invitationCode;
4572
+ this._spaceKey = request.spaceKey;
4573
+ this.layoutUpdate.emit(request);
4574
+ }
4575
+ setInvitationUrl(request) {
4576
+ this._invitationUrl = request.invitationUrl;
4577
+ this._deviceInvitationParam = request.deviceInvitationParam;
4578
+ this._spaceInvitationParam = request.spaceInvitationParam;
4579
+ this.invitationUrlUpdate.emit(request);
4580
+ }
4581
+ async setAppContext(context) {
4582
+ this.contextUpdate.emit(context);
4583
+ }
4584
+ };
4585
+ var ShellContext = /* @__PURE__ */ (0, import_react71.createContext)({});
4586
+ var useShell = () => {
4587
+ const client = (0, import_react_client14.useClient)();
4588
+ const { runtime, setDisplay } = (0, import_react71.useContext)(ShellContext);
4589
+ const setLayout = async (layout, options) => {
4590
+ if (runtime) {
4591
+ if (layout === import_react_client14.ShellLayout.DEFAULT) {
4592
+ setDisplay?.(import_react_client14.ShellDisplay.NONE);
4593
+ } else {
4594
+ setDisplay?.(import_react_client14.ShellDisplay.FULLSCREEN);
4595
+ }
4596
+ runtime.setLayout({
4597
+ layout,
4598
+ ...options
4599
+ });
4600
+ }
4601
+ await client.shell.open(layout, options);
4602
+ };
4603
+ return {
4604
+ setLayout
4605
+ };
4606
+ };
4607
+ var ShellProvider = ({ space, deviceInvitationCode, spaceInvitationCode, onJoinedSpace, children }) => {
4608
+ const client = (0, import_react_client14.useClient)();
4609
+ const identity = (0, import_halo5.useIdentity)();
4610
+ const [display, setDisplay] = (0, import_react71.useState)(!identity || spaceInvitationCode || deviceInvitationCode ? import_react_client14.ShellDisplay.FULLSCREEN : import_react_client14.ShellDisplay.NONE);
4611
+ const shellRuntime = (0, import_react71.useMemo)(() => {
4612
+ if (client.config.get("runtime.app.env.DX_VAULT") !== "false") {
4613
+ return;
4614
+ }
4615
+ if (spaceInvitationCode) {
4616
+ return new MemoryShellRuntime({
4617
+ layout: import_react_client14.ShellLayout.JOIN_SPACE,
4618
+ invitationCode: spaceInvitationCode
4619
+ });
4620
+ }
4621
+ if (deviceInvitationCode) {
4622
+ return new MemoryShellRuntime({
4623
+ layout: import_react_client14.ShellLayout.INITIALIZE_IDENTITY,
4624
+ invitationCode: deviceInvitationCode
4625
+ });
4626
+ }
4627
+ return new MemoryShellRuntime({
4628
+ layout: identity ? import_react_client14.ShellLayout.DEFAULT : import_react_client14.ShellLayout.INITIALIZE_IDENTITY
4629
+ });
4630
+ }, [
4631
+ client,
4632
+ identity,
4633
+ spaceInvitationCode,
4634
+ deviceInvitationCode
4635
+ ]);
4636
+ const handleKeyDown = (0, import_react71.useCallback)((event) => {
4637
+ if (!space || !shellRuntime) {
4638
+ return;
4639
+ }
4640
+ const modifier = event.ctrlKey || event.metaKey;
4641
+ if (event.key === ">" && event.shiftKey && modifier) {
4642
+ shellRuntime.setLayout({
4643
+ layout: import_react_client14.ShellLayout.SHARE_IDENTITY
4644
+ });
4645
+ setDisplay(import_react_client14.ShellDisplay.FULLSCREEN);
4646
+ } else if (event.key === "." && modifier) {
4647
+ shellRuntime.setLayout({
4648
+ layout: import_react_client14.ShellLayout.SPACE,
4649
+ spaceKey: space.key
4650
+ });
4651
+ setDisplay(import_react_client14.ShellDisplay.FULLSCREEN);
4652
+ }
4653
+ }, [
4654
+ space,
4655
+ shellRuntime
4656
+ ]);
4657
+ (0, import_react71.useEffect)(() => {
4658
+ if (!shellRuntime) {
4659
+ return;
4660
+ }
4661
+ window.addEventListener("keydown", handleKeyDown);
4662
+ return () => window.removeEventListener("keydown", handleKeyDown);
4663
+ }, [
4664
+ shellRuntime,
4665
+ handleKeyDown
4666
+ ]);
4667
+ (0, import_react71.useEffect)(() => {
4668
+ if (!shellRuntime) {
4669
+ return;
4670
+ }
4671
+ return shellRuntime.contextUpdate.on(({ display: display2, spaceKey }) => {
4672
+ if (display2) {
4673
+ setDisplay(display2);
4674
+ }
4675
+ onJoinedSpace?.(spaceKey);
4676
+ });
4677
+ }, [
4678
+ shellRuntime
4679
+ ]);
4680
+ return /* @__PURE__ */ import_react71.default.createElement(import_react71.default.Fragment, null, shellRuntime && /* @__PURE__ */ import_react71.default.createElement("div", {
4681
+ className: (0, import_react_ui_theme32.mx)(display === import_react_client14.ShellDisplay.NONE ? "hidden" : "")
4682
+ }, /* @__PURE__ */ import_react71.default.createElement(Shell, {
4683
+ runtime: shellRuntime
4684
+ })), /* @__PURE__ */ import_react71.default.createElement(ShellContext.Provider, {
4685
+ value: {
4686
+ runtime: shellRuntime,
4687
+ setDisplay
4688
+ }
4689
+ }, children));
4690
+ };
4691
+ // Annotate the CommonJS export names for ESM import in node:
4692
+ 0 && (module.exports = {
4693
+ Action,
4694
+ Actions,
4695
+ AgentConfig,
4696
+ AuthCode,
4697
+ BifurcatedAction,
4698
+ Centered,
4699
+ ClipboardContext,
4700
+ ClipboardProvider,
4701
+ CloseButton,
4702
+ CompoundButton,
4703
+ ConfirmReset,
4704
+ ConfirmResetImpl,
4705
+ CopyButton,
4706
+ CopyButtonIconOnly,
4707
+ DeviceList,
4708
+ Emoji,
4709
+ EmojiPickerBlock,
4710
+ EmojiPickerToolbarButton,
4711
+ Heading,
4712
+ HuePickerBlock,
4713
+ HuePickerToolbarButton,
4714
+ IdentityDialog,
4715
+ IdentityListItem,
4716
+ IdentityPanel,
4717
+ IdentityPanelImpl,
4718
+ Input,
4719
+ InvitationList,
4720
+ InvitationListContainer,
4721
+ InvitationListItem,
4722
+ InvitationListItemImpl,
4723
+ InvitationManager,
4724
+ JoinDialog,
4725
+ JoinPanel,
4726
+ JoinPanelImpl,
4727
+ Label,
4728
+ Shell,
4729
+ ShellContext,
4730
+ ShellProvider,
4731
+ SpaceDialog,
4732
+ SpaceListItem,
4733
+ SpaceMemberList,
4734
+ SpaceMemberListImpl,
4735
+ SpacePanel,
4736
+ SpacePanelImpl,
4737
+ StatusPanel,
4738
+ StepHeading,
4739
+ Viewport,
4740
+ activeBgColor,
4741
+ activeStrokeColor,
4742
+ activeTextColor,
4743
+ cancelledBgColor,
4744
+ cancelledStrokeColor,
4745
+ cancelledTextColor,
4746
+ createViewportScope,
4747
+ errorBgColor,
4748
+ errorStrokeColor,
4749
+ errorTextColor,
4750
+ inactiveBgColor,
4751
+ inactiveStrokeColor,
4752
+ inactiveTextColor,
4753
+ osTranslations,
4754
+ resolvedBgColor,
4755
+ resolvedStrokeColor,
4756
+ resolvedTextColor,
4757
+ runShell,
4758
+ stepStyles,
4759
+ successBgColor,
4760
+ successStrokeColor,
4761
+ successTextColor,
4762
+ useClipboardContext,
4763
+ useShell,
4764
+ useViewportContext
4765
+ });
4766
+ //# sourceMappingURL=react.cjs.map